PDA

View Full Version : shadow volumes

helda
01-13-2003, 05:15 AM
Hello guys,

I have a problem with shadow volumes. when i'm in the shadow, and look to infinity of the shadow volume i see a hole that is not in the shadow. i think this will happen, while i'm not closing my shadow volume at infinity. But how can i do this?

thank you for reply

helda

vincoof
01-13-2003, 05:20 AM
If the camera is inside the shadow volume, there is two solutions :
- use the Carmack's Reverse algorithm,
- cap the near plane.

helda
01-13-2003, 05:23 AM
i want to use carmaks reverse algorithm, but when i draw my object at infinity, and i'm outside of the volume i can see the object as a small shadow outside of the real shadow. Perhaps i make something wrong, but i don't know what.

helda

PH
01-13-2003, 05:33 AM
There are lots of posts on this board about how to make shadow volumes work. I posted a solution about 1½ years ago, do a search on "shadow volumes" and you should have this working in no time.

vincoof
01-13-2003, 06:07 AM
Carmack's reverse need closed volumes, thus you can NOT used infinite volumes.

Carmack's reverse algorithm supposes that the volume projection is limited AND the projection does not go beyond the far clipping plane. If your far clipping plane is not "far enough", you'll experience hole-type artefacts.

SirKnight
01-13-2003, 06:12 AM
Originally posted by vincoof:
Carmack's reverse need closed volumes, thus you can NOT used infinite volumes.

Carmack's reverse algorithm supposes that the volume projection is limited AND the projection does not go beyond the far clipping plane. If your far clipping plane is not "far enough", you'll experience hole-type artefacts.

I think you're confused. The technique known as "carmack's reverse" is also called the zfail technique. This is what is described in the infinite shadow volume paper nvidia put out last year. So you CAN use volumes extruded to infinity with zfail, or "carmack's reverse." Read the paper I talk of if you don't believe me. I have it working just fine. http://www.opengl.org/discussion_boards/ubb/biggrin.gif

-SirKnight

helda
01-13-2003, 06:16 AM
but when i have set my far clipping plane to infinity like in Kilgards (Practical and Robust Stenciled Shadow Volumes) it should go ?

PH
01-13-2003, 06:52 AM
Yes, SirKnight is correct. Cass Everitt posted some additional details on this board that you won't find in the paper. Specifically, you will need to nudge the infinite far plane slightly, to avoid holes in the shadows ( on some hardware ).

Helda, the problem you're seeing is more likely due to not using closed shadow volume meshes ( or calculating them incorrectly ).

SirKnight
01-13-2003, 07:57 AM
Originally posted by PH:
Yes, SirKnight is correct. Cass Everitt posted some additional details on this board that you won't find in the paper. Specifically, you will need to nudge the infinite far plane slightly, to avoid holes in the shadows ( on some hardware ).

Yeah Cass's demo also shows this in the infinite projection matrix setup function. Be sure to get that demo and study it. It's pretty straight forward I think. The demo also shows (obviously) how to cap a volume extruded to infinity. It's pretty easy, one of the caps is the all the trianges that are front facing w.r.t. the light and the other cap is all the back facing triangles w.r.t the light but with the w component set to 0 to extrude them to infinity.

-SirKnight

helda
01-13-2003, 08:39 AM
i have found my problem, i have first rendered my volume and than closed. my problem was i have decremented from 0 and than incremented (this was the small shadow).
Now i first increment (shadow close) and than decrement the shadow volume (front faces).

Now it works well.

helda

helda
01-14-2003, 06:50 AM
i have only a last question, when i render my szene the shadows are there, but several pixels that should be in the shadow are illuminated. I don't understand this.

I hope, someone can help me.

helda

vincoof
01-14-2003, 07:59 AM
Are you sure that all rendered objects write the depth buffer ?

helda
01-15-2003, 01:39 AM
Yes, all writes at the depth buffer.

vincoof
01-15-2003, 03:11 AM
Is that possible that your 3D engine renders the scene in that order :
1- render (almost) all objects into depth buffer
2- perform shadow volumes algorithm
3- render some other objects

helda
01-15-2003, 04:45 AM
I do it in this way:

1. render all objects (ambient,depth buffer =less)
3. render all objects (full light, depth buffer=equal)

helda
01-15-2003, 04:50 AM
I have found a really big bug in my algorithmus. its the following one:
I have a sphere, which throws a shadow on a cube. The sphere and the cube have the same position only the y coordinate is not the same. The sphere is over the cube. Now i have the following problem, There is a shadow at the upper side of the cube(that's OK) but there is the same shadow at the front side of it(that's not really good).

Whats wrong with my algorithmus?

helda

JustHanging
01-15-2003, 05:03 AM
Make sure you don't have any ambient while rendering the light with shadow volumes. Sound like the light shouldn't affect the front side of the cube at all, so it doesn't matter whether there's a shadow there or not. But if you have some ambient with that pass, light will be added there too, and the unwanted shadow becomes visible.

-Ilkks

SirKnight
01-15-2003, 07:56 AM
Originally posted by helda:
I have found a really big bug in my algorithmus. its the following one:
I have a sphere, which throws a shadow on a cube. The sphere and the cube have the same position only the y coordinate is not the same. The sphere is over the cube. Now i have the following problem, There is a shadow at the upper side of the cube(that's OK) but there is the same shadow at the front side of it(that's not really good).

Whats wrong with my algorithmus?

helda

Could you show us a screenshot? I think that the cube face on the front that is dark should be, but I really don't know where your light is positioned so I'm guessing it's behind the front face which is shading that face dark obviously.

BTW, just for the record, it's algorithm not algorithmus. Almost got it there. http://www.opengl.org/discussion_boards/ubb/biggrin.gif

-SirKnight

SirKnight
01-15-2003, 07:58 AM
Ah, algorithmus is the german translation for algorithm. Gotcha. http://www.opengl.org/discussion_boards/ubb/smile.gif

-SirKnight

helda
01-15-2003, 10:21 PM
Sorry for this, it depents on my high quality english. http://www.opengl.org/discussion_boards/ubb/tongue.gif

helda
01-15-2003, 11:12 PM
Hello, i have found (i hope my last bug) http://www.opengl.org/discussion_boards/ubb/frown.gif

You can see it there

www.planet-held.de (http://www.planet-held.de) (I hope this will do)

i don't know where it comes from.

helda

vincoof
01-16-2003, 12:17 AM
Not a solution, but an idea to help finding the problem : if I were you I would render the wireframe model of the shadow volume, with depth test disabled for the wireframe.

dorbie
01-16-2003, 12:31 AM
What happened to the "Shadow Volume" thread on exactly this a few days ago? It seems gone now although it's still in the search database.

dare
01-16-2003, 02:49 AM
Originally posted by dorbie:
What happened to the "Shadow Volume" thread on exactly this a few days ago? It seems gone now although it's still in the search database.
I don't know why it is still in search machine, but I know why it's gone : I delete it! This 'hot' thread is enough, although my demo is not only producing shadow, but is also wide C++ cover for OpenGL - so it covers several threads on this forum; don't know where to put it...