Hi
I am just starting out on the journey of learning the Shading Language
and have been working through the course notes. Need to get some books
though ;-).
Anyway I have typed in and tried to compile the brick shader on p44 in
order to understand what is going on. It seems to be ok apart from one
error which says I have an undeclared normalize function on ln25.
here is my code, I'm compiling with shaderdl which comes with 3Delight
6.5.
#define BRICKWIDTH 0.25
#define BRICKHEIGHT 0.08
#define MORTARTHICKNESS 0.01
#define BMWIDTH (BRICKWIDTH + MORTARTHICKNESS)
#define BMHEIGHT (BRICKHEIGHT + MORTARTHICKNESS)
#define MWF (MORTARTHICKNESS * 0.5 /BMWIDTH)
#define MHF (MORTARTHICKNESS * 0.5 /BMHEIGHT)
surface
brick(
uniform float Ka = 1;
uniform float Kd = 1;
uniform color Cbrick = color (0.5, 0.15, 0.14);
uniform color Cmortar = color (0.5, 0.5, 0.5);
)
{
color Ct;
point NN;
float ss, tt, sbrick, tbrick, w, h;
float scoord = s;
float tcoord = t;
NN = nomalize(faceforward(N,I));
ss = scoord / BMWIDTH;
tt = tcoord / BMHEIGHT;
if (mod(tt * 0.5, 1) > 0.5)
ss += 0.5; /* ****ft alternate rows */
tbrick = floor(tt); /* which brick? */
sbrick = floor(ss); /* which brick? */
ss -= sbrick;
tt -= tbrick;
w = step(MWF,ss) - step(1-MWF,ss);
h = step(MHF,tt) - step(1-MHF,tt);
Ct = mix (Cmortar, Cbrick, w*h);
/* matte reflection model */
Ci = Os * Ct * (Ka * ambient() + Kd * diffuse(NN));
}
Any help would be really cool.
Cheers
Dave


|