shadow volumes

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

If the camera is inside the shadow volume, there is two solutions :

  • use the Carmack’s Reverse algorithm,
  • cap the near plane.

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

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.

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.

Originally posted by vincoof:
[b]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.[/b]

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.

-SirKnight

but when i have set my far clipping plane to infinity like in Kilgards (Practical and Robust Stenciled Shadow Volumes) it should go ?

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

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

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

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

Are you sure that all rendered objects write the depth buffer ?

Yes, all writes at the depth buffer.

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

I do it in this way:

  1. render all objects (ambient,depth buffer =less)
  2. shadow volumes (depth mask=0)
  3. render all objects (full light, depth buffer=equal)

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

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

Originally posted by helda:
[b]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[/b]

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.

-SirKnight

Ah, algorithmus is the german translation for algorithm. Gotcha.

-SirKnight

Sorry for this, it depents on my high quality english.