st coloration

customizing shaders

This web page displays the results of writing custom surface shaders

These images show the results of using the RenderMan Shading Language (RSL) to write a variety of non physically plausible surface shaders. The notes and RSL code accompanying each image explain how each pattern was achieved.

Master Shot of shapes

rwMaster

Shader 1

stcoloration3

/* Square Shader */
surface
constant_test(    float    Kfb = 1;    /* fake brightness */
)
{
  
color    surfcolor = (1, 1, 1);
  
if (s>=0.3 && s<=0.7 && t>=0.3 && t<=0.7) surfcolor = (1.0, 0.2, 1.0);
  
 
  
/* STEP 1 - set the apparent surface opacity */
Oi = Os;
  
/* STEP 2 - calculate the apparent surface color */
Ci = Oi * Cs * surfcolor * Kfb;
}

Shader 2

stcoloration4

/* Cross Shader */
surface
constant_test(    float    Kfb = 1;    /* fake brightness */
)
{
  
color    surfcolor = (1, 1, 1);
  
  
if (s>=0.2 && s<=0.8) surfcolor = (0.0, 1.0, 1.0);
  
if (t>=0.25 && t<=0.75) surfcolor = (0.0, 1.0, 1.0);
  
  
/* STEP 1 - set the apparent surface opacity */
Oi = Os;
  
/* STEP 2 - calculate the apparent surface color */
Ci = Oi * Cs * surfcolor * Kfb;
}

Shader 3

stcoloration2

/* Quarter Circle */
surface
constant_test(    float    Kfb = 1;    /* fake brightness */
)
{
  
color    surfcolor = (1, 1, 1);
  
if ((s+1)*(s-0.61)+(t-0.63)*(t+1)<=sqrt(0.02))  surfcolor = (0.2, 1.0, 0.2); 
  
/* STEP 1 - set the apparent surface opacity */
Oi = Os;
  
/* STEP 2 - calculate the apparent surface color */
Ci = Oi * Cs * surfcolor * Kfb;
}

Shader 4

stcoloration5

/* Custom Shape (Heart) */
surface
constant_test(float Kfb = 1 /* fake brightness */; 
              float scale = 1; 
              float xs = 0.5;
              float ys = 0.6;
              float swap = 0; /* [0 or 1] */
              color backcolor = 1;
              color heartcolor = (1.0, 0.0, 0.0);
)
{
color    surfcolor = backcolor;
float    x = (s-xs)/scale;
float   y = (t-ys)/scale;
  
if(swap < 1) if((x*x+y*y-0.1)*(x*x+y*y-0.1)*(x*x+y*y-0.1)-x*x*y*y*y <=0) surfcolor = heartcolor;
  
if(swap == 1) {surfcolor = heartcolor; 
if((x*x+y*y-0.1)*(x*x+y*y-0.1)*(x*x+y*y-0.1)-x*x*y*y*y <=0) surfcolor = backcolor;}
  
  
  
/* STEP 1 - set the apparent surface opacity */
Oi = Os;
  
/* STEP 2 - calculate the apparent surface color */
Ci = Oi * Cs * surfcolor * Kfb;
}

stcoloration7

Conclusion - It is really difficult to work with these initially. I am trying my best to understand the logic behind the scripts and use them effectively. It goes back to basic mathematics and that does make it very interesting and challenging at the same time.