i've only played with shaders once and i remember nothing about 'em but i believe someone here could get
this shader:
/*
Cross hatch shader code.
by Jeff Feasel.
*/
surface
crosshatch2(
float density = 1,
thickness = 0.3,
silhouette = 0.3;
color pencil = color(0,0,0);
float cutoff1 = 0.7,
cutoff2 = 0.5,
thresh1 = 0.4,
thresh2 = 0.4,
scale = 1;
float nx1 = 0,
ny1 = 2,
nz1 = 3,
nx2 = 0,
ny2 = 3,
nz2 = -2;
float Ka = 0.2,
Kd = 0.8,
Ks = 0.6,
roughness = 0.1 )
{
point PP;
float x, y, z, r;
float a, b, c, d;
float dense,thick;
float i;
float which;
float cut, thr;
/*
* Compute the forward-facing normal NN and the vector
* toward the ray origin V, both normalized.
* These vectors are used by "specular" and "diffuse". */
normal NN = faceforward(normalize(N),I);
vector V = -normalize(I);
PP = transform("shader", P);
x = xcomp(PP);
y = ycomp(PP);
z = zcomp(PP);
/* Compute illumination at this point. */
i = comp(Oi* color(1,1,1) * (Ka * ambient() + Kd * diffuse(NN))
+ Ks * specular(NN, V, roughness), 0);
/* Ci = Cs;*/
Ci = color(1,1,1);
/* What to do with Opactity? */
/* Hatch 1 */
a = nx1;
b = ny1;
c = nz1;
d = 0;
r = abs(a*x+b*y+c*z+d)/sqrt(a*a+b*b+c*c);
/* map radial distance r into ring position [0,1] */
dense = density * 30;
r *= dense;
which = mod(floor(r),2); /* 0 or 1 */
r -= floor(r); /* == mod(r,1) */
/* Vary line thickness according to darkness */
cut = cutoff1 * scale * pow(0.5,which);
thr = thresh1 * scale * pow(0.5,which);
thick = thickness;
thick = thick * (1-smoothstep(cut-thr/2, cut+thr/2, i));
r = smoothstep(0, thick*0.25, r) - smoothstep(thick, thick*1.25, r);
Ci = mix(Ci, pencil, r);
/* Hatch 2 */
a = nx2;
b = ny2;
c = nz2;
d = 0;
r = abs(a*x+b*y+c*z+d)/sqrt(a*a+b*b+c*c);
/* map radial distance r into ring position [0,1] */
dense = density * 30;
r *= dense;
which = mod(floor(r),2); /* 0 or 1 */
r -= floor(r); /* == mod(r,1) */
/* Vary line thickness according to darkness */
cut = cutoff2 * scale * pow(0.5,which);
thr = thresh2 * scale * pow(0.5,which);
thick = thickness;
thick = thick * (1-smoothstep(cut-thr/2, cut+thr/2, i));
r = smoothstep(0, thick*0.25, r) - smoothstep(thick, thick*1.25, r);
Ci = mix(Ci, pencil, r);
/* Darken silhouette. */
float edge = smoothstep(silhouette-0.05, silhouette, NN.V);
Ci = mix(pencil, Ci, edge);
}
working in dbpro?
oops: i just re-read the OP and you just want cross-hatch
shadows. sorry about that
Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit