Textual Shading Language



Shader compiler must:

// Define and compile shader
glmanShaderProgram(1,"
    radiance (
         color4 a[2], 
         color4 b[2], 
         signed color4 c[2], 
         signed color4 d[2]
    ) {
         // generate parabolic map texture coordinates for hv
         float hv[2] = parabolic(halfvector[0],
			tangent1,tangent2,normal);

         // generate parabolic map texture coordinates for lv
         float lv[2] = parabolic(lightvector[0],
			tangent1,tangent2,normal);

         // Reconstruct BRDF from separable representation and scale
         color4 f = 8*(a[hv]*b[lv] + c[hv]*d[lv]);

         // Multiply by irradiance and return
         return f*irradiance(0);
     }
", a,b,c,d);  // Texture object parameters

//--- Activate shader
glShader(1);
A toolkit for Renderman shaders could be implemented this way in a device-independent manner (note: this ISN'T a Renderman shader... I've taken lots of liberties).