View Full Version : Shadow Volumes Problems! plz help! NEW!! with screenshots and Demo!

06-24-2004, 11:22 PM
Hello! I have some problems when i draw shadow volumes.
I first implement the shadows like this:


The idea is this:
for each light
end for

everything was correct exept the color of the shadows!
lets say the first light is a red light, the second a green and the third a blue;
the first shadow(from the red light) is correct. it has all the other colors exept the red.
the second shadow(from green) is not correct!it has only the blue color!
and the third shadow(from blue light) is black!

if I had this light colors:
1)yellow 2)blue 3)red 4)pink 5)purple 6)green
look at this:

yellow ------------------------> blue,red,pink,purple,green
blue -------------------------------> red,pink,purple,green
red ------------------------------------> pink,purple,green
pink ----------------------------------------> purple,green
purple ---------------------------------------------> green
green -------------------------------------> nothing = black

how i can fix this problem?
some people said to me to don't render the scene like this but like this:
for each light
end for

i try this way but i have problem with casting the shadow(no matter the number of the lights) It seems that all the vertices of the shadow are calculated correct but i does not draw correct.
maybe something with stencil going wrong?

this is the code for the new algorithm:

.. something else.. as you can see in the code i use ARB_fragment_program. The pixel shader does not do any shadow calculation. only Per pixel lighting .

thanks in advanvce!

here is the pack with the demos and screenshots
www.csd.uoc.gr/~hatzibod/Bek3DEngine.zip (http://www.csd.uoc.gr/~hatzibod/Bek3DEngine.zip)

06-25-2004, 12:49 AM
It is bad approach "darkening lighted scene". Switch to "lightening dark scene".


06-25-2004, 01:50 AM
the first or the second way is better to use? and any idea how i can fox this problems?

06-25-2004, 02:11 AM
I had the same problem a few months ago:
http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_to pic;f=3;t=011712 (http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=011712)
Hope this helps.

06-25-2004, 03:29 AM
One point that you maybe missed :

you "ADD" each light contribution to the scene.
Meaning, you render the ambient term, and then ADD each light contribution on top of it. you can use additive blending (GL_ONe, GL_ONE) for this. As you can imagine, adding black doesn't do anything.


06-27-2004, 03:37 AM
SeskaPeel: I disable the fragment program and blending but i forget to paste it! :D

heya!! I am back again! I was some days off...

Here is a zip pack with some screeshots and two versions of my 3dengine. one with the INFINITY value for the shadow volume very small and the other with very big! also you can read the readme file witch is in there!!!

www.csd.uoc.gr/~hatzibod/Bek3DEngine.zip (http://www.csd.uoc.gr/~hatzibod/Bek3DEngine.zip)

the demos is with the second way:

first draw the depth of the room
then for each light
draw the shadow volume
draw the room with light

the problem for now with this aproach is not the color problems but the shadow volume is not correct and i dont know why!!

DON'T run the demo if you dont have a VGA with Pixel shader v2.0 support!

06-29-2004, 02:31 AM
Do you have silhouette finder? If so, then check your code..


07-15-2004, 06:17 PM
The answer seems simple, and yet I haven't seen it.

You need to clear the stencil buffer after rendering each light. If you don't, the shadow from light 1 will appear in light 2 and so on.