I found this piece of code (source: http://www.fundza.com/rfm/osl/repeats/index.html)
Code: Select all
// Returns a value in the range 0 to 1.
// 0 indicates the x,y point is outside the square, and
// 1 indicates the x,y point is fully within the squere.
float pntInSquare(float x,
float y,
float x_center,
float y_center,
float x_width,
float y_width,
float blur)
{
float minx = x_center - x_width/2;
float maxx = x_center + x_width/2;
float miny = y_center - y_width/2;
float maxy = y_center + y_width/2;
return smoothstep(minx, minx + blur, x) * (1 - smoothstep(maxx, maxx + blur, x)) *
smoothstep(miny, miny + blur, y) * (1 - smoothstep(maxy, maxy + blur, y));
}
//----------------------------------------------------
shader
square(float s_center = 0.5,
float t_center = 0.5,
float s_width = 0.4,
float t_width = 0.4,
float blur = 0.01,
color bakcolor = 1,
color patcolor = 0,
float s = 0 [[int lockgeom = 0]],
float t = 0 [[int lockgeom = 0]],
output color resultRGB = 0)
{
float blend = pntInSquare(s, t, s_center, t_center, s_width, t_width, blur);
resultRGB = mix(bakcolor, patcolor, blend);
}
Could someone guide me on what needs to change for Octane to make it work.
Many thanks in advance