Skip to content

Instantly share code, notes, and snippets.

@ChrisHinde
ChrisHinde / instance_grid.osl
Last active August 21, 2023 15:25
Calculate an "Instance ID" based on UV coordinates
shader InstanceGrid(
point proj = point(u, v, 0) [[string label = "Projection"]],
int cols = 10 [[string label = "Columns", int min=0, int max=1000]],
int rows = 10 [[string label = "Rows", int min=0, int max=1000]],
int fulluv = 0 [[string label = "Use full UV", string widget = "boolean"]],
int invert_u = 0 [[string label = "Invert U", string widget = "boolean"]],
int invert_v = 0 [[string label = "Invert V", string widget = "boolean"]],
output color c = 0 [[string label = "Instance ID"]]
)
{
@ChrisHinde
ChrisHinde / instance_grid_random.osl
Last active August 21, 2023 15:26
OSL-script that generates a random (greyscale) value per “instance”
shader InstanceGrid_Random(
point proj = point(u, v, 0) [[string label = "Projection"]],
int cols = 10 [[string label = "Columns", int min=0, int max=1000]],
int rows = 10 [[string label = "Rows", int min=0, int max=1000]],
int utime=1 [[string label = "Time", int min=0, float max=1000, float sliderexponent=2]],
int fulluv = 0 [[string label = "Use full UV", string widget = "boolean"]],
int invert_u = 0 [[string label = "Invert U", string widget = "boolean"]],
int invert_v = 0 [[string label = "Invert V", string widget = "boolean"]],
output color c = 0 [[string label = "Instance ID"]]
)