Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Graphics > RenderMan interface > Problem with sh...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 718 of 788
Post > Topic >>

Problem with shader from SIG92 Course 21

by dave@[EMAIL PROTECTED] Feb 24, 2007 at 02:46 AM

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
 




 3 Posts in Topic:
Problem with shader from SIG92 Course 21
dave@[EMAIL PROTECTED]   2007-02-24 02:46:44 
Re: Problem with shader from SIG92 Course 21
Hannu Parviainen <hppa  2007-02-24 18:44:02 
Re: Problem with shader from SIG92 Course 21
dave@[EMAIL PROTECTED]   2007-02-24 09:47:33 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 0:13:14 CST 2008.