Friday, August 20, 2010

co shaders

After some weeks of hard work, the monkeys @ pandaka are finally wrapping up sequences for delivery! ^_^

Since more projects are starting now, it's time to update&test&deploy||deprecate some stuff around. And since more pieces are being added, it was a nice opportunity to start with co shaders:

// class based shader calling a co-shader
class simple_layer(
float displacement_weight = 1;
string displacement_map = "";

shader co_shader_dummy1 = null;
shader co_shader_dummy2 = null;

)
{
// displacement method
public void displacement (output point P; output normal N)
{
if (displacement_map != "" && displacement_weight != 0)
{
float _disp = displacement_weight * float texture (displacement_map, s, t);
P += _disp * normalize (N);
N = calculatenormal (P);
}
}


normal Nn = normalize(N);
vector V = normalize(-I);
// surface method
public void surface (output color Ci, Oi)
{

uniform float i = 0;

shader co_shader_ [] = getshaders ();
for (i = 0; i < 1 ="=">diffuse(Nn, P);
}

if (co_shader_ [i] != null && 1 == hasmethod (co_shader_ [i], "occlusion"))
{
occlusion variable *= co_shader_ [i]->occlusion(Nn, P);
}
// more inputs here...
}

Oi = Os;
Ci = composite stuff
Ci *= Oi;
}
}

So, it's a modular way to connect stuff... you already know how they work but this is great if you think in the possibilities within maya or any other high end application ;) And I'm fresh to classes and the idea of clean, organized and reusable pieces of code in a single shader is just exciting (not like my all-in-one+patches shader)...

edit: I hate the lack of code tags.

No comments: