Shadow Volume demo doesn't work for flat planes.

Hi,

I have noticed (with a little pain) that the shadow volume demo that comes with JOGL doesn’t work with flat planes, or meshs with deleted triangles making holes in them.

A mesh could be said to have a hole if it has a face with an edge that is not shared by another face.

The demo appears to only work with objects that are solid objects, where as a plane of two triangles doesn’t cast a correct shadow.

I think this is related to the methods for drawing the end caps of the shadow volume. Since a flat plane will only have one side facing the light source, then it doesn’t have both caps on the shadow volume.

After doing all the work of including the shadow volume rendering in my engine. I find that I can’t use it.

I’m thinking I will have to use NeHe’s shadow solution, which doesn’t work if the camera moves inside the shadow volume. Where as the JOGL demo works in this case.

Can anyone confirm my problem who understands what I might be talking about?

Thanks,

You’ve found one of the many disadvantages of shadow volumes. To get a proper shadow volume, your meshes need to be closed (two-manifold, “watertight”, etc). There are ways to overcome this limitation (e.g. a boundary edge is always a silhouette edge), but generally it’s a PITA.

Other disadvantages:

  • Only works with polygonal geometry (no alpha-tested polygons, doesn’t work with the various displacement mapping techniques, etc).
  • Problematic performance (too much geometry, doesn’t scale well) - depending on the game of course.
  • It’s practically impossible (in a real game) to do soft shadows.
  • Very CPU-hungry and you can’t use the GPU for dynamic geometry (e.g. skinning in a vertex shader).
  • PITA to code a fast and robust implementation.

In other words, if you aren’t making a Doom game, go for shadow mapping. :wink:

Thank you for your reply.

I have only found examples of shadow mapping techniques for spot lights, and my engine requires most of the shadows to come from omni lights.

I’m trying to shadow mostly room interiors such as kitchens, living rooms, and above views of houses.

So I need a solution which works well with light sources in different rooms.

Shadow maps don’t work on all video cards, so I have to have a volume back up.

Does anyone have an example of shadow maps for Omni lights??

Please! That would help out a ton!

Oh yeah, that’s the major shadow mapping disadvantage. ;D

Shadow mapping works great with infinite lights as well, but, you’re right, shadow mapping with point lights is really hard. Actually it’s doable (and relatively inexpensive), but only practical for next-gen engines. The general idea is to use cube-maps as shadow maps. The two major problems are a) no support for depth cube-map textures and b) Render to cube-map overhead. Currently, you’d need to encode/decode depth into an RGBA cube-map and render the depth pass on a pbuffer (significant overhead). Next-gen engines on the other hand, could use float textures and EXT_fbo. Either way, you’d need fragment shaders and/or features not broadly available. :-/

Anyway, both approaches are quite difficult, both have pros and cons, but certainly the shadow mapping one is the future (especially quality-wise). Depending on your project (and the time/patience you have available ;)), you’ve got two options:

a) Use shadow volumes, make your artists produce proper models (closed), make the implementation robust and live with the quality compromises.

b) Go for shadow mapping and sacrifice compatibility.

Or go for a third solution get a copy of AgentFX :wink:

If your are looking for a robust shadow volume solution you can try AgentFX. It possible to use AgentFX in combination with JOGL code if you are intressted. The engine comes in both a commercial and free non commercial evaluation version.

Cheers
// Tomas :slight_smile:

[quote]a) Use shadow volumes, make your artists produce proper models (closed), make the implementation robust and live with the quality compromises.
[/quote]
8)

There is “nice to have” and then “reality”.

Our 3D product contains over 10,000 models, and is already deployed across several customers.

So I’m stuck with the library of models. I am writting a new 3D engine to replace an older out dated one.

Also, if we get a contract from a new customer for example: ABC Toys and they provide 5,000 models in DXF format. Then we have to do the best with that we have. I can’t go to the customer and say “our shadows don’t work because your models aren’t 2-manifold”.

Then, on the other hand I have a boss who says “We need better shadows our scenes are full of artifacts”.

What am I going to do???

I need a strong shadow solution for non-2-manifold models.

I will have to use the orginal zpass approach to shadow volumes, and see if I can figure out if the camera is inside the volume of an object, and disable the shadows for that object. Still the NeHe tutorial example introduces a few other problems.

[quote]I need a strong shadow solution for non-2-manifold models.
[/quote]
From a quick search:

Robust, Geometry-Independent Shadow Volumes

They claim that it works perfectly:

[quote]As long as the requirements of the algorithm are adhered to, it will produce a shadow volume with no rendering artifacts, no matter the complexity of the geometry used to construct the volume.
[/quote]

Thanks Spasi!

Some easy reading for tonight.

I had another thought as well.

What if I kept additional copies of the meshes in memory to use as the shadow source, and when I load the models if they contain holes. I could try to cap them, and make the model solid.

Anyone see any reasons why this would be a bad idea?

Thanks Spasi!

That document was perfect. I’ve made the changes to support the counting of the winding order of meshes, and now everything is working.

Still, I am not having luck doing the JOGL demo method of z test. But, if I use the zpass method in the NeHe tutorial the shadows are perfect.

I can’t position the camera inside a shadow volume, but I should be able to fix that bug tomorrow.

Dude, thanks so much! How can I re-pay??

[quote]Dude, thanks so much! How can I re-pay??
[/quote]
Hehe, no need to, I’m just glad I was able to help! :wink: