Archived

This topic is now archived and is closed to further replies.

New shadowing techniques...

This topic is 5023 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK, so I''ve implemented stencil shadowing before, but I want something better now. What are the latest updates on shadowing techniques? I know all about shadow-mapping, and penumbra wedges, but I''d like to know about some of the cutting-edge techniques for creating real-time soft shadows, including those methods which use vertex and fragment programs. Can someone point me in the direction of some tutorials, or give me a quick rundown of what I should be looking for? Thanks in advance...
Windows 95 - 32 bit extensions and a graphical shell for a 16 bit patch
to an 8 bit operating system originally coded for a 4 bit microprocessor,
written by a 2 bit company that can''t stand 1 bit of competition.

Share this post


Link to post
Share on other sites
Moved to graphics forum.

----------------------------------------
"Before criticizing someone, walk a mile in their shoes.
Then, when you do criticize them, you will be a mile away and have their shoes." -- Deep Thoughts
"If you have any trouble sounding condescending, find a Unix user to show you how it''s done." - Scott Adams
FaceHat Software -- Wear the hat.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Advanced shadowing, ie. algorithms that support good self shadowing, no work from the CPU, etc ?

Stencil shadows and shadow maps. That''s about it. There have been some extensions to both recently (GPU volume extrusion for stencil shadows, and PSM, TSM, etc, for shadow maps), but all in all, it''s still the same.

Share this post


Link to post
Share on other sites
So the soft shadowing in Max Payne 2, and the soft shadows in Half-Life 2 and the Unreal 3 test are all just optimized and enhanced versions of either stencil shadows or shadow-mapping? I suppose that shadow-mapping, being geometry indepedent, is now completely taking over from stencil shadows, as polygon counts get higher?

[edited by - iNsAn1tY on April 16, 2004 11:32:46 AM]

Share this post


Link to post
Share on other sites
I noticed that the sample Cg shaders section of NVIDIA had info on stencil shadow volumes in the Vertex Shader section and soft stencil shadows and hardware shadow maps in the pixel shaders section. Don''t know if it''s new, but might be worth a look..

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by iNsAn1tY
So the soft shadowing in Max Payne 2, and the soft shadows in Half-Life 2 and the Unreal 3 test are all just optimized and enhanced versions of either stencil shadows or shadow-mapping?


Don''t know about Max Payne 2, but about the other two, they are a combination of shadow maps (I think) and standard lightmapping. There might also bit a little good old projection shadows involved, which might still be a good choice for dynamic entities.

quote:

I suppose that shadow-mapping, being geometry indepedent, is now completely taking over from stencil shadows, as polygon counts get higher?


Yes. The inherent problems of shadow mapping (mostly precision issues) are starting to be addressed with the said extensions, and more research is underway. Stencil shadows are nice in theory, but they take an insane amount of fillrate, tremendeously increase the number of faces to render, and fail on certain types of geometry.

Share this post


Link to post
Share on other sites
I've done a bit of work with shadows recently, so I'll kick in my views:

I can't speak for HL2 or Unreal3, but in Max Payne 2, they're actually projected shadows.

If you notice while playing the game, Max's shadow projects onto the world, but not other people or objects. Instead of actually rendering a shadow map, they rendered the object from the POV of the light (basically the same as a shadow map only they don't reoord depth), and then blur that just a tiny bit (I'm not sure if they run it through a blur pass or if the bilinear filtering takes care of it - I'm guessing the latter). Thus, a soft-looking shadow on the environment, but no self-shadowing.

Advances? There was a thread a while back about large-environment shadow mapping, which tried to come up with a 5-map (max) method of rendering shadows for a large outdoor scene, but the method fell flat in practice (The size of texels along one direction of the shadow map remained constant with distance, which is what's expected, but the texels on the other direction grew exponentially with distance, giving really bad resolution far from the screen).

Here is the thread if you're interested.

Perspective Shadow Maps have their advantages, but I believe there are too many disadvantages to them. They have a few good cases where the resolution is near-perfect, but there are a lot of bad cases. And they're really, really bad cases. Also, it may be the hardest shadow algorithm to implement. It's complex, and there are parts of it that seem rather glossed-over by the paper.

Trapezoidal Shadow Maps seem pretty good, though I haven't tried to implement them yet. The nice thing about TSMs is that the worst case (which, like PSMs is when you're looking directly into or directly away from the light) is no worse than a normal shadow map. So, while it's arguable for PSMs, the average case is definitely better than normal shadow mapping (as it never gets worse). Also, it seems to be a very easy-to-implement method, especially using vertex shaders (which most, if not all, shadow-map capable hardware supports).

I also saw a paper (though I've forgotten where) on soft-edged stencil shadows using "Penumbra Wedges." This technique looks very promising, but it currently does not run well enough to work in realtime (though it does work at interactive rates). There's still ongoing research into this. I'm looking forward to when it's useable!

Hope that helps

EDIT: Wow...three replies while I typed this! The smoothies link looks neat...I'll have to check it out!

[edited by - Drilian on April 16, 2004 11:52:27 AM]

Share this post


Link to post
Share on other sites
Actually you should read the PSM chapter in GPU Gems, it really addresses most of the PSM issues. PSMs are actually quite usable and not too difficult to implement now.

Share this post


Link to post
Share on other sites
1-Max payne2 : The shadows of max payne 2 are projected shadows using D3DXMatrixShadow or any similar fuction.sampling is done to the shadow depending on the of the the distance from the light source. This shadow can only be projected on palns, not on characters or any other things in the world.
2-Unreal3 : They are using spherical harmonics lighting which support soft shadows and dynamic lights, but it does not support dynamic geometry.I don''t know how they are generating the shadows for characters.
3-Half life2 : for static geometry they are using radiosity and normal maps.The radiosity of course handels the shadowing.
for dynamic geometry, I don''t know what shadowing technique they are using.
I think that for dynamic geometry, only old sahdowing techniques are used.
Another thing that I want to add, the shadow volume is not affected very much with the poly count if the shadow volume was generated in a vertex shader.

Share this post


Link to post
Share on other sites
There's a link on this page to what may be the paper on penumbra edges someone mentioned:
http://www.peroxide.dk/tuts_c.shtml
It includes code for using vertex shaders for the shadow geometry and pixel shaders for the penumbras.
The results look excellent, and I imagine it's by far the best way of calculating soft shadows for dynamic geometry.

If this technique is as accurate as the paper indicates, why bother with spherical harmonics for shadows? Is it simply that the lighting calculations are more accurate?

[edited by - MumbleFuzz on April 16, 2004 3:25:05 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The "smoothie" paper looks intersting. Looks like a nice method to augment shadow maps. But it must be very performance intensive to compute all those edge smoothies on the CPU (+ reupload to the card), every time a light changes position. For multiple moving lights, you''d need multiple instances of the smoothies per frame. This will quickly saturate the AGP bus, stress the CPU, and add many faces per frame. I think this method will only become interesting with uberbuffers, ie. texture access in a vertex shader (vs 3.0 or similar).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Adding to my previous post: I wonder if there would be a method to add the smoothies on the GPU, by using a similar VS extrusion method as with stencil shadows. Hmmm.

Share this post


Link to post
Share on other sites
quote:
Original post by MumbleFuzz
If this technique is as accurate as the paper indicates, why bother with spherical harmonics for shadows? Is it simply that the lighting calculations are more accurate?

The benefit of Precomputed Radiance Transfer (spherical harmonics != PRT - spherical harmonics have other uses and PRT can be done using other representations) is that the cost of the technique is constant regardless of the complexity of the lighting environment. The technique is only really appropriate for low frequency, distant lighting environments but given those constraints the cost is independent of the number and size of the light sources. Other soft shadow techniques require n times as much work for n light sources and aren''t really suitable for really large area light sources.

PRT can also handle indirect lighting which is a pretty nice feature to have. For static models and diffuse surfaces PRT approximates full Global Illumination pretty well. The big weakness of PRT is that it doesn''t work very well with animated models.

Share this post


Link to post
Share on other sites
muhamed adel,
Do you know if extruding shadow volumes in a vertex shader is always a win over extruding volumes on the cpu? I seem to remember that vs extrusion results in a ~6x increase in vertex count. How fast is the gpu at handling all these extra degenerates + volume extrusion compared to cpu volume extrusion + uploading the volume geometry?

Share this post


Link to post
Share on other sites
quote:
Original post by DonnieDarko
I seem to remember that vs extrusion results in a ~6x increase in vertex count.?

Who told you that?? the poly count is the same (or should be the same) if you are using the depth fail in both case.if you are using depth pass, then you will not need the front and back caps of the shadow volume,which may cause the increase in the polycount,but it is ~3x increase not 6x.
BUT
1-if you are using depth fail ( and you should be for FPS at least) then the poly count should be approxiamtely the same.
2-The probelm of generating the shadow volume on the cpu is the locking of the vertex buffer of the model, and the iterating of the processor throught the edges and vertecies.this makes the preformance extremely affcted with the polycount.
3-The vertex shader for extruding the shadow volume is short (not a great number of instructions, as it can be done on a 1.1 VS, and ofcourse it can be done in software.
4- See the sample on booyah site, it is done in a vertex shader and have a very high fps (more than 500 fps on my 9700 pro).
5-No locking for veertex buffers is done when using a veretex shader.

Share this post


Link to post
Share on other sites