PDA

View Full Version : Lighting with waving flag. Lets say.. "double direction normals"



unreal
12-20-2004, 11:21 AM
Hello.
I was making a wave flag demo.
For lighting I made an ARB fragment program shader. For Phong simple lighting. not Phong bump mapping. just one texture only.
But there is a problem. A waving flag is a field/spring of polygons. and the polygons are facing one direction.lets say that the vertex normals of a flag is (-1,0,0). Everything is ok with the lighting as soon as the light is at the left of the flag (the vertex normals is facing the light).
If the light now goes at the right of the flag that the flag lighting goes black because the normals is not facing the light! this is correct for the most cases. but for a flag is not correct.
what i should to to fix it?

here is my vertex and fragment program code:
http://rafb.net/paste/results/dWCTyj78.html

thanks in advance

Sunray
12-20-2004, 12:04 PM
|N.L|?

unreal
12-20-2004, 12:21 PM
yeah! you are right! it works now!! :)
thanks!

cass
12-21-2004, 05:46 AM
I think what you're looking for is a "faceforward" kind of operator, isn't it?

If you google for "faceforward renderman" you'll see some examples.

Essentially, when the normal is pointing away from
the eye (E.N < 0), you negate N. That way you have the normal for the side of the surface facing you.

Taking |L.N| isn't the same thing, and it may not be what you really want.

Thanks -
Cass