Email Me Course Link
Matrix Level-Of-Detail St Coloration Pattern Animation Fire Shader
Home

ST Coloration - Winner of Pixar's Stupid Renderman Tricks 2009

These images show the results of using the RenderMan Shading Language (RSL) to write a variety of special effects surface shaders. The notes and RSL code accompanying each image explain how each effect was achieved. This shader trick, along with the method described on my Pattern Animation page, was presented during the renderman user's group meeting at Siggraph 2009. My original keynote presentation in PDF format can be downloaded here.

 

if((s*s)+(t*t) < 1)

if(-0.125*(sin((s)* (PI) *5)-1.75) <= (0.5/(1/t)))

if(s >= 0.25 && s <= 0.75)

if(t >= 0.25 && t <= 0.75)

if((((s-.5)*(s-.5))+((t-.5)*(t-.5))<.1) && (((s-.6)*(s-.6))+((t-.5)*(t-.5))>.1)) if(t + s > 1)

 

Representing more Detail

So after doing basic shapes I wanted to experiment with a technique to represent extremely complex patterns and images on the ST grid. It would be basically impossible to do this by manually coding the .sl files, but I figured that I can do it by defining point attribute informaiton and extract that information using python. Information will be fed into Renderman using the same basic instructions used to generate the geometric shapes. With this technique, I can represent any image quite accurately. Because of the procedural nature of this technique, very complex shaders can be defined.

Gathering Information In Houdini

In houdini, I projected an image onto a grid consisting of 2499 points.


http://karenswhimsy.com/celtic-patterns.shtm
The Houdini Network is nothing complex. It is just a grid with an image projected onto it via the "uvproject" node. I add "color" attributes to the points of the grid using the "point" node. These colors are sampled directly from the image. What I am really looking for here is 2 sets of point attributes: location (P) and color (Cd). These can be found in details view and will help me to re-create my image in a renderman shader. I also scaled my grid into a 0 to one world space, to conform to renderman shader's ST world units.

So the details in houdini is telling me that my image is generated through 2499 points. The X and Z location of these points will help me define the grid in my shader. What I want to do is to represent any image or pattern I would like using these points or more. Additionally, I want to do this in a very efficient way.

...So I started a one day task of learning python's implementation within the Houdini Object Model. Through some language syntax lessons, along with fervent research on Houdini's python functions I was able to design a custom script to extract the information that I need.

The two main functions I use are:
point.position()
point.attribValue()
(to extract RGB information)

Here is my python code:

ShaderGenerate.py

This is the main operation in python:
f.write("if (s = %.12f && t = %.12f) \n" % (t,s))
f.write( " surfcolor = color(%.f, %.f, %.f);\n" % (r,g,b))

Which writes this to my shader file for every point defined:
if (s >= 1.000000000000 && t >= 0.942028999329)
surfcolor = color(0.967320203781,0.979085087776,0.979084908962);

Through these precise floats, I can represent a wider range of colors for any image.

Results


Because I am generating these by defining every grid location and not by curve equations, it can result in a very large .sl file and could take very long to compile. Nevertheless, I can increase the resolution as I see fit to get a sharper image. This technique must be used responsibly to avoid "out of memory" errors. Above is the pattern shader, defined by my python helper script.

Representing photoreal surfaces and patterns is what this technique does best.


This is the image rendered using ST Coloration. Here is the Shader Code.

 

Results using more complicated fractals. Edited my script to add more details by excluding colors that are the same color as the background:

 

Matrix
Level-of-Detail
ST Coloration
Maya Pattern Animation
Fire
Links
Links