Thursday, 5 July 2012

Custom Renderman Shaders & Realflow

I been writing a custom Renderman shader - it still needs work but here is the current code and examples as to what it looks like!

Video Examples:


Bob | Realfow Simulation | Custom Renderman Shader | Iskander Mellakh from iskander mellakh on Vimeo.

Custom Renderman Shader | Iskander Mellakh from iskander mellakh on Vimeo.

Here is the code:

  1. surface im_mottleNoise(
  2.           uniform color myColor = color(0,1,0);
  3.           uniform float myOc = 0.1;
  4.           uniform float roughness = 0.1;
  5.           float Km = 1.0;
  6.           float face = 1.0;
  7.           float mag = 0.0;
  8.           uniform float freqency = 1.0;
  9. )
  10. {
  11.           float size = 1.0,
  12.           magnitude = 0.0,
  13.           i;
  14.           point P2;
  15.           P2 = transform ("shader", P);
  16.           for (i = 0; i <6.0; i+= 1.0){
  17.                    magnitude += abs (.5 - noise (P2 * size) * freqency) / size;
  18.           }

  19.           P2 = P - normalize (N) *(magnitude * magnitude * magnitude) *Km * mag;
  20.           N = calculatenormal(P2);
  21.           normal Nn = normalize (N);
  22.           vector In = normalize(-I);
  23.           normal Nf = faceforward(Nn,-I);
  24.           normal Nb = faceforward(Nn,I);
  25.           //Oi = myOc * diffuse(Nf * -face);
  26.           //Oi = myOc * face + specular(Nf, In, roughness);
  27.           Oi = myOc;
  28.           Ci = myColor *Oi * diffuse(Nb) + specular(Nf, In, roughness);
  29. }

No comments: