RSL Shader II - Renderman's Maya shader integration
This section of the project covers the use Renderman shader description files and how it integrates into Maya’s shading interface. By incorporating all that I have learnt from the ST coloration exercise into a complete shader.
Notes!
This project may differ from the initial assignment writeup written for Professor Malcolm Kesson. It would have been edited to also reflect my later experiences, clearer tutorial techniques/codes and also later advancements made to the projects as well.
Pattern Animation with RSL shaders in Maya
After completion of our earlier ST Coloration exercise, we have began to closely examine how we can create cerrtain values and attributes into controllable values in Maya using the "slim" format.
But first, inorder to achieve that, we have to first create a pattern what we can animated using this set of controls.
Using the same rainbow colors from the previous exercise, I have decided to create a somewhat hyponotic pattern using mathematical scripting in RSL. My concept... a spinning whirlpool of circles.
To do that, I have first defined the variables that would make up my circles...Using the earlier Pythagoras' theorem
Understanding that in Radius² = s²+t²... I immediately created the required variables:-
► Radius (of the first circle)
► Csa (change in s axis to compensate for the shift in Origin)
► Cta (change in t axis to compensate for the shift in Origin)
Using both Csa and Cta to redefine the new origin away from the 0,0 point, I then used Pythagoras' theorem to test the area around the new origin where the formula any point's distance from the new origin will be test via
(Distance aka Radius)² <= (s-Csa)² + (t-Cta)²
This formula will test true if the point is measured to be within the distance aka radius of the circle from the new origin...
Using this concept, I then proceeded to create a loop and some new variables and commands
► Iterations (number of circles to create)
► Step (How much to scale the radius by, per iteration)
for(i = 0; i < Iterations; i += 1)
{
if(pow(clamp(radius-((Step*0.05)*i),0,1),2) >= pow(s-Csa),2) + pow((t-Cta),2))
*command*
};
We all know that in my command tab, it is likely that I do something like surfcolor = color (1,0,0) or in my case of rainbow patterns... surfcolor = color (cos(s*3)cos(s*3-1.5),cos(s*3-3).
However, doing so gave me a big problem. Because when a surfcolor is set on a larger overlapping circle, its color value will mask and hide away all other smaller circles placed on it.
Thankfully, there are solutions. I have decided to use the command line surfcolor = color (1,0,0) for the setting of my rainbow color. A seperate line is added at a later part of the script to tell a point that if it was Red, it will become rainbow and that if it was Blue, it will becomes white.
So for my command under the loop, it was merely the chore of adding a test script to identify and recolor the circles accordingly.
if(surfcolor == color (1,0,0))
(If i'm already red......)
surfcolor = color (0,0,1);
(turn me blue......)
else
surfcolor = color (1,0,0);;
(else turn me red......)
Replacement of all reds into the rainbow color
if(surfcolor == color (1,0,0))
surfcolor = color (cos(s*3),cos(s*3-1.5),cos(s*3-3));
(Turn all red into RAINBOW)
and replacement of all blues into the white color
if(surfcolor == color (0,0,1))
surfcolor = color 1;
(Turn all blue into WHITE)
So now that I have my hypnotic circles and my colors correct, I then begin to manipulate movement... Using the concepts of shifting the new origin per circle using sine and cosine rules, I should beable to get the animation of a perfect circular loop on the S and T axis. To better see an example, please note the video example below...
Using the wave formulas on together with the Cta and Csa and delaying each value of the formula's frequence by the loop i which increase by 1 per circle in the iteration. This means that any circle within will have a gradually increasing i number....
Please also note that I have added a variable Phase which will represent a keyable value which can determine phase of the rotation the circles are in.....
► Phase (Represents time. This value determines the frequency time of the Cosine and Sine waves)
for(i = 0; i < Iterations; i += 1){
if(pow(clamp(radius-((Step*0.05)*i),0,1),2) >= pow(s-Csa+cos(Phase-i)*(Step*0.05),2) + pow(t-Cta+sin(Phase-i)*(Step*0.05),2))
if(surfcolor == color (1,0,0))
surfcolor = color (0,0,1);
else
surfcolor = color (1,0,0);;
The result: -
The resultant shader was then compiled into slo and slim files for maya usage and the below variable comments made...
float Kfb = 1; /* Ambient Brightness */
float trans = 1; /* Opacity Setting */
float radius = 1; /* Radius of the Largest Circle*/
float Iterations = 20; /* Number of Circles */
float Step = 1; /* [1,10,1] Step Sizing*/
float Phase = 1; /*[1,100,1] Phase of Animation */
float Csa = 0.5; /* Change in S axis */
float Cta = 0.5; /* Change in T axis */
The value for Phase was then animated to give us the below....
Content on this page requires a newer version of Adobe Flash Player.
This "constant" type shader was then given diffuse and specular attribute... however, at very small value as I want to preserve the hypnotic essense of the pattern. The Renderman render settings was also adjusted to give a smoother pattern.
I then applied the shader onto a sphere and 3 planes. Please note that for the sphere, I had shifted the Csa and Cta value so the origin of the circle would be at the very top of the circle's polar coordinates.
And viola~ be hypnotised....
Content on this page requires a newer version of Adobe Flash Player.
dave kin chang wei - visual effects artist / technical director - davekcw@yahoo.com.sg - www.kamid.net