PDA

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



unreal
06-25-2004, 12:22 AM
Hello! I have some problems when i draw shadow volumes.
I first implement the shadows like this:

http://rafb.net/paste/results/aiA0zn64.html

The idea is this:
for each light
DrawRoom(light[i]);
DrawShadows(lights[i]);
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:

SHADOW FROM LIGHT ----------------- SHADOW COLOR
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:
DrawRoomWithNoLight();
for each light
DrawShadowVolume(lights[i]);
DrawRoom(lights[i]);
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:
http://rafb.net/paste/results/CaiEdO65.html

.. 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)

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

yooyo

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

BoSoft
06-25-2004, 03:11 AM
Hi,
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.

SeskaPeel
06-25-2004, 04: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.

SeskaPeel.

unreal
06-27-2004, 04: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...
well..

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!

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

yooyo

147-2
07-15-2004, 07: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.