Pre-Complied vs. Interactive Shading

Pre-Complied shading and Interactive Shading have their own cons and pros. This page demonstrates a brief comparison between these two methods of shading. RenderMan has been used for pre-compiled shading and Maya Hypershade for interactive shading.

"Normal Coloration" Shader in Renderman:


 surface
 Normal_Coloration(float Kfb = 1;
                   color Kcol[3]={color(1,0,0),
				  color(0,1,0),
				  color(0,0,1)}, 
                         Kopac= 1)
 {

 normal n = normalize(N);
  
 float X = n[0] * 0.5 + 0.5;
 float Y = n[1] * 0.5 + 0.5;
 float Z = abs(n[2]);
            

 color c = (X * Kcol[0] + Y * Kcol[1] + Z * Kcol[2]);
  
 Oi = Os * Kopac;
 Ci = Oi * c * Kfb;
 }


The purpose of this shader is to colorize an object by calculating the angle between the normal vector of each point on its surface and the camera view direction. Red is assigned to X direction, Green to Y and Blue to Z (or depth) as default colors; though the freedom to choose arbitrary colors and opacity has also been offered to the user.

The source code of such a shader is shown on the left.

Final Render (RenderMan):

Here is the final render using Pixar's RenderMan.


"Normal Coloration" Shader in Maya Hypershade:

This is the implementation of the same shader in Maya Hypershade. Basically a Sampler Info node is used to get information of every point on the surface (Normal Camera X,Y and Z). These information are fed into Remap Value node the remap them from (0,1) to (-1,1). These data drives the V Coordination of 3 Ramps each of which defines the color of each direction. Those three ramps are added together by a Layered Texture node with "add" blending mode. Then this node feeds the color value of a Surface shader.

The Hypershade graph is displayed on the left. (clickable)

Final Render (RenderMan):

Here is the final render using Maya Software.


A Brief Comparison

Pre-Compiled Shader Interactive Shader
Requires highly specialized knowledge Artist friendly
Locked and frozen Prone to being altered / broken
Inflexible Flexible / Easily edited
The source code is generally short and highly optimized Prone to being inefficient; specially when made by inexperienced artists