top of page

OSL ST_Shading

Shader2__CrossCupsShape_beauty.0001.jpg
Shader2__CrossCubesShape_beauty.0001149.

shader

Cross(
  float s = 0 
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
    float t = 0
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
        float s_offset = 0.5,
        float s_width = 0.2,
        float t_offset = 0.5,
        float t_width = 0.2,
        
        color base_color = color(1,1,1),
        color pat_color = color(1,0,0),
        output color resultRGB = 0)
{
float ss = s - floor(s);
float tt = t - floor(t);

float left = s_offset - s_width/2;
float right = s_offset + s_width/2;
float top = t_offset + t_width/2;
float bottom = t_offset - t_width/2;

if (ss >= left && ss <= right || tt >= bottom && tt <= top)
    resultRGB = pat_color;
else
    resultRGB = base_color;
}

Shader2__DonutCupsShape_beauty.0001.jpg
Shader2__DonutCubesShape_beauty.0001.jpg

shader
target(
    float s = 0 
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
    float t = 0
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
        float s_center = 0.5,
        float t_center = 0.5,
        float radius_outside = 0.4,
        float radius_inside = 0.2,
        color bakcolor = color(1,1,1),
        color patcolor = color(1,0,0),
    output color resultRGB = 0)
{
float ss = s - floor(s);
float tt = t - floor(t);

float a = s_center - ss;
float b = tt - t_center;
float dist_sqrd = a * a + b * b;

if(dist_sqrd <= radius_outside * radius_outside && dist_sqrd >= radius_inside * radius_inside )
    resultRGB = patcolor;
else
    resultRGB = bakcolor;
}

Shader2__CircleCubesShape_beauty.0001003
Shader2__CircleCupShape_beauty.0001149.j

shader
st2color(
    float s = 0 
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
    float t = 0
        [[
        int lockgeom = 0,
        string widget = "null",
        ]],
        float s_center = 0.5,
        float t_center = 0.5,
        float radius = 0.4,
        color bakcolor = color(1,1,1),
        color patcolor = color(1,0,0),
    output color resultRGB = 0)
{
float ss = s - floor(s);
float tt = t - floor(t);

float a = s_center - ss;
float b = tt - t_center;
float dist_sqrd = a * a + b * b;

if(dist_sqrd <= radius * radius)
    resultRGB = patcolor;
else
    resultRGB = bakcolor;
}

bottom of page