ST Coloration

stcolor

ST Coloration

The following patterns are created using RenderMan Shading Language (RSL).

image.0049

The video and source code below show the step by step process of creating the custom pattern.

This browser cannot play the embedded video file.

surface
constant_custom(float    Kfb = 1;    /* fake brightness */
                float size = 0.1; /*radius of the circle*/
                float inside = 0.75; /*inside radius of the circle*/
                float inside_2 = 0.45; /*radius of the small circle*/
                float cross_size = 0.45; /*size of the cross*/
                color forecolor = color(0.996, 0.624, 0.616);
                color backcolor = color(0.796, 0.424, 0.416);
                color opacity = 1)
                
{
color    surfcolor = backcolor;
  
//left-top
if (((s-0.1)*(s-0.1))+((t-0.1)*(t-0.1)) <= size && ((s-0.1)*(s-0.1))+((t-0.1)*(t-0.1)) >= size*inside)
    surfcolor = forecolor;
if (((s-0.1)*(s-0.1))+((t-0.1)*(t-0.1)) <= size*inside_2)
    surfcolor = forecolor;
    
//right-top
if (((s-0.9)*(s-0.9))+((t-0.1)*(t-0.1)) <= size && ((s-0.9)*(s-0.9))+((t-0.1)*(t-0.1)) >= size*inside)
    surfcolor = forecolor;
if (((s-0.9)*(s-0.9))+((t-0.1)*(t-0.1)) <= size*inside_2)
    surfcolor = forecolor;
    
//left-bottom
if (((s-0.1)*(s-0.1))+((t-0.9)*(t-0.9)) <= size && ((s-0.1)*(s-0.1))+((t-0.9)*(t-0.9)) >= size*inside)
    surfcolor = forecolor;
if (((s-0.1)*(s-0.1))+((t-0.9)*(t-0.9)) <= size*inside_2)
    surfcolor = forecolor;
    
//right-bottom
if (((s-0.9)*(s-0.9))+((t-0.9)*(t-0.9)) <= size && ((s-0.9)*(s-0.9))+((t-0.9)*(t-0.9)) >= size*inside)
    surfcolor = forecolor;
if (((s-0.9)*(s-0.9))+((t-0.9)*(t-0.9)) <= size*inside_2)
    surfcolor = forecolor;
    
//center cross
if (t>=cross_size && t <=1-cross_size)
    surfcolor = forecolor;
    
if (s >=cross_size && s <=1-cross_size)
    surfcolor = forecolor;
screenshot-jpeg

Maya integration

The custom pattern can be import into Maya' s Hypershade using Render Man Shader material.

There's a series of controls that can be used to manipulate position, size, color and opacity of each elements in the custom pattern.

And they can be keyframed into animation.

image.0008

Curve Pattern









surface
constant_curve(float    Kfb = 1;    /* fake brightness */
                float size = 1;
                color forecolor = color(0.996, 0.741, 0.588);
                color backcolor = color(0.796, 0.541, 0.388);
                color opacity = 1)
                
{
color    surfcolor = backcolor;
  
if (s*s + t*t < size)
    surfcolor = forecolor;
image.0009

Square Pattern










surface
constant_square(float    Kfb = 1;    /* fake brightness */
                float size = 0.2;
                color forecolor = color(0.875, 0.741, 0.588);
                color backcolor = color(0.675, 0.541, 0.388);
                color opacity = 1)
                
{
color    surfcolor = backcolor;
  
if (t >= size && t <= 1-size)
    surfcolor = forecolor;
  
if (s <= size || s >= 1-size)
    surfcolor = backcolor;
image.0010

Diagonal









surface
constant_diagonal(float    Kfb = 1;    /* fake brightness */
                color forecolor = color(0.749, 0.741, 0.588);
                color backcolor = color(0.549, 0.541, 0.388);
                color opacity = 1)
                
{
color    surfcolor = backcolor;
  
  
if(s <= t)
    surfcolor = forecolor;
image.0011


Cross











surface
constant_cross(float    Kfb = 1;    /* fake brightness */
                float size = 0.25;
                color forecolor = color(0.498, 0.494, 0.392);
                color backcolor = color(0.298, 0.294, 0.192);
                color opacity = 1)
                
{
color    surfcolor = backcolor;
  
  
if (t>=size && t <=1-size)
    surfcolor = forecolor;
    
if (s >=size && s <=1-size)
    surfcolor = forecolor;

Note on this project

I never thought I would be able create a pattern using shader language, because I have no previously computer programming background. The mathematic concept behind shading language is too complicated for me to understand. 

Then I try to read articles found on Professor Malcolm Kesson's website, and there're also many resources from previous student portfolio that I can take as reference. The shader shown here is just a small step of my progress.


© Ziye Liu,  2012