Black and White Lines
Goal: Create a shader that generates white lines where a surface
would normally gradate from light to dark. Be able to manipulate
the width of the lines and the number of lines generated.
With Shader applied to
a Maya model Black and White lines without
smoothstep function
With 20 lines and 3 lights
With 5 lines and 2 lights
Maya Scene
Adjusting Number of Lines
Varying Line Width
Shader Settings in Maya This set of sliders in Slim be used to
effect the number of lines and the weight of the line.
Probelm Solving smoothstep Black and White lines with the smoothstep function
Code For Smoothstep for(i = 0; i < num; i = i+1)
{
grey02 += smoothstep(base01,base02,grey)
* (1-smoothstep(base01,base02,grey));
base01 += wt*2;
base02 += wt*2;
}
Lines are appearing grey. This is probably
due to the gradients fom the edges of the smoothstep are overlapping
each other. I need to add a variable to adjust the smoothness factor.
Shader with
smoothstep on a Maya Model I increased the Kd value and
used two lights.
/* high contrast shader:
Where lights are forced to white and darks are forced to black.*/
surface
high_contrast( float Kd = 1,
smoothness = .2,
cutoff = 1,
num = 1,
wt = .5;
string texmap = "")
{
/*color surfcolor = texture(texmap,s,t);*/
color surfcolor = 1;
normal n = normalize(N);
normal nf = faceforward(n, I);
color c1 = diffuse(nf);
float grey = (comp(c1,0)+comp(c1,1)+comp(c1,2))/3;
float i, base01 = 0, base02 = wt, grey02 = 0;
Oi = Os;
/* make either black or white - force threshold to .5 so light
greys become white
*//*This generates the lines with smoothstepping but with a lot of greyness
....I think because the smoothstep is overcoming the white.*/
/*for(i = 0; i < num; i = i+1) {
grey02 += smoothstep(base01,base02,grey) *
(1-smoothstep(base01,base02,grey));
base01 += wt*2;
base02 += wt*2;
}
*/
/*This creates lines without smoothstepping */
for(i = 0; i < num; i = i+1) {
if(grey > base01 && grey < base02)
grey02 = 1;
else
grey02 += 0;
base01 += wt*2;
base02 += wt*2;
}
Ci = Oi * Cs * surfcolor * grey02 * Kd;
}