Advertisement

Stenciled Shadow Volumes(Tutorial 28)

Started by March 07, 2002 09:09 PM
5 comments, last by bakery2k1 22 years, 11 months ago
I got the stenciled shadows working as in tutorial 28. I now want to apply this to my own models. When rendering the shadow volume, we increment the stencil buffer for front facing polygons, and decrement for back facing ( I think thats right ). My question is - how, in this tutorial, does it know that all front facing polygons (of the shadow volume) have clockwise winding and all back facing polygons have anticlockwise winding? i.e. how is it sure that the winding of the polygons of the shadow volume is consistent? Are the vertices of the cross declared in a certain order, or is the winding confirmed in the code somewhere? Thanks
If the polygon is front facing, its vertices (in order of being specified) will form a clockwise rotating on the screen. Its something thats handled by OpenGL, and if you dont want to you dont have to worry about it at all.

-----------------------
"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else''s drivers, I assume it is their fault" - John Carmack
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Advertisement
Sorry, I seem to have phrased my question wrongly, I know how polygon winding works . What I need to know is how (In this particular tutorial) can we be sure that all of the polygons making up the shadow volume have their front faces facing outward?
That''s up to you to decide if polygons are front in cw or ccw.
In the tutorial, the model is supposed to be correctly winded.
There''s no check anywhere.

It''s just like when you enable "classic" backface culling (ie without worrying about stencil shadows) : if your model is correctly winded it will display front faces and cull back faces, but if it is not correctly winded some faces will seem to be displayed when they should not and vice versa.

Once you can apply "classic" backface culling on a model, you can use volume stencil shadows.
I''ll try to explain again:
We extrude the shadow volume along edges of polygons.

Lets say we have a quad:    |  viewer   \ /    V1        0----------|        ||        ||        |----------2        3the light lies on your side of the screen. Lets extrude the 0-1 side:         o light      0-----1     /       \    /         \   ------------   0''          1''We want to be looking at the front of the volume.Now, if we draw in the order 0, 1, 1'', 0'', then front faces are clockwise.Now put the light below the poly and extrude:  0''         1''    -----------  \         /   \       /    0-----1We still want to see the front of the quad. Drawing 0, 1, 1'', 0'' as before is now counter-clockwise. 

Why is this not a problem?
Don''t Worry, I Get It!
Only front facing (to the light) polygons are extruded. In order to have tha above situation, 2 quads must be used back-to-back. They must have opposite winding, thus cancelling out the problem of opposite winding on the shadow volume.

Thanks very much for your help, Vincoof.
Advertisement
I think you got it.
It''s one of the most complex NeHe tutorials. Congrats.
Keep up the good work !
Cheers

This topic is closed to new replies.

Advertisement