Thursday, April 29, 2010

random snippets 01

result = 0;
point stspace = point((scale*s)+offset,(scale*(1-t))+offset,0);
float i;
float x[100],y[100],line[100],defuzz[100];
point p[100]; p[0] = point(.2,.6,0);
for (i=0;i<100;i+=1) {
 x[i] = 2*noise(.5+i);
 y[i] = 2*noise(.5+i+13);     p[i] = point(x[i],y[i],0);
 line[i] = ptlined(p[i],p[i-1],stspace);
 defuzz[i] = 1-smoothstep(width-fuzz,width+fuzz,line[i]);
 result += defuzz[i];

Tuesday, April 20, 2010

desaturating individual color components

result = 0;
float r = comp(v1,0); 
float g = comp(v1,1); 
float b = comp(v1,2);
float lumr = .2125*comp(v1,0);
float lumg = .7154*comp(v1,1);
float lumb = .0721*comp(v1,2);
color desatr = mix(color(lumr), color(r,0,0), saturationr);
color desatg = mix(color(lumg), color(0,g,0), saturationg);
color desatb = mix(color(lumb), color(0,0,b), saturationb);
result = desatr+desatg+desatb;

Friday, April 16, 2010

Graphearea, color coding shaders

laying out a typical shader. In this example is a character with clothes and some accessories. The blue nodes are AOV nodes(as in bluescreen mattes, get it?), the green nodes are control mattes. The red nodes are global control nodes, occ. Yellow are ensembles, and purple are unused. If there's a way to define our own custom colors, please share.

Wednesday, April 7, 2010

shading normals

straight from Renderman pro server documentation,

P += normalize(N) * a * amplitude;t a;
P = transform("object", P);
N = transform("object", N + point "object" (0,0,0));
P = transform("object", "current", P);
N = calculatenormal(P);

with some errors in the above code, we can use this in a vector slbox to slightly alter the shading normal which we can then plug into a shading component(specular and reflection). say we want to break up the specular reflection of specular to make it look like water droplets on skin. we use the above code, use a fractal for "a", create our own point p and normal n, and normalize the final n. It'll look like this,

point p = transform("object", P);
normal n = transform("object", N + point "object" (0,0,0));
p += normalize(n) * a * amplitude;
p = transform("object", "current", p);
n = calculatenormal(p);
result = normalize(n);

The addition of point "shader" (0,0,0) in the second line accounts for the fact that N is really a vector (or normal), and thus should not transform in the same way as a point.
This is the old way of transforming vectors and normals. These days, we encourage you to use the following equivalent (but less confusing and cheaper!) construct:
normal Nsh; Nsh = ntransform ("shader", N); For vectors (as opposed to normals), one should use the vtransform function.