Skip to main content
gamedev.net
🔒 Locked

Shadow Volumes

Started by Kyardan Dec 18, 2002 at 8:40 PM 3 replies 800+ views
Original Post
Kyardan
Kyardan
Greetings I apologize in advance if this has been asked before, but with the search function dead, and being unable to manualy look back past page 2 makes it difficult to find existing threads. Links to past threads that anyone may have bookmarked would be greatly appriciated. I currently have a partly working z-fail shadow volume implimentation in DirectX, using degenerate triangles and a vertex shader to do the shadow volume extrusion. Its "partly" working because I haven''t yet made it extrude to infinity, which is what I''m having problems with. So I have a few questions trying to understand how this should be setup before I try to impliment it. And I''ve read through the article here on gamedev, as well as many of the references provided in that tutorial, but non seem to quite clear up these things for me. 1) Its my understanding that for verticies that need to be extruded, you pass in the vector along which the extrusion should be done (with w=0). However I''m not quite sure at what point these vectors should be applied. The article on here says not to set w=0 untill after the world-view-projection transformation, but that seems to dissagree with the other material I''ve read. 2) For a directional light, because the light extrusion direction is constant, would this mean all points to be extruded would become identical vectors pointing in the direction of the light? 3) For point lights, the extusion vector seems to become (LightPosition.w*Vertex.xyz-LightPosition.xyz,0) (might be wrong, taking it from memory). Multiplying by LightPosition.w would seem to imply the lights been transformed and thus has a non-one w. Would this be the light coordinate passed through world-view-projection? And thus the vertex coordinate would also be passed through world-view-projection, and the output vector would be the difference between the two in projection space? (This would answer 1 I guess) 4) The infinite view projection matrix. I tried throwing this into my existing setup in hopes of getting rid of the far-clipping problem with the result of the shadows vanishing completely. This wasn''t using the w=0 setup, just extruding the shadow volumes a fixed amount. Question here is, does that matrix not work with non-semi-infinite shadow volumes, or did I just mess up in setting up that matrix somehow? Thank you in advance for any responses, I''ve been puzzling over how this works for a few days now and feeling kinda frustrated ;P Also if any of my questions are unclear I''ll try to rephrase them. Kyardan
ga
ga
1.) the extrued vertices should be the vectors from the light source to the original vertex with w = 0
... and you won''t set vertices after their transformation (i think you mean the world -> eye transformation... you should set those vertices with w=0 in world space i think)

2.)yes, pointing not to the light but to the opppsite direction

3.)the formula is correct and works also for directional lights (where light.w == 0; in all other cases the light.w will be 1 i suppose)

to get the extruded point you could w-transform both the vertex and the light position, subtract the light position from the vertex and set w=0:
(Vertex.xyz/Vertex.w-LightPosition.xyz/LightPosition.w,0)
if the vertex.w will always be 1 (don''T use w coordinate for finite scaling) you don''t need to write it...

if there''s a vector with w = 0 you can multiply it with any constant != 0 without changing it (because only the direction is important).... so you can multiply the extruded point with LightPosition.w to get
(LightPosition.w*Vertex.xyz-LightPosition.xyz,0)

now you don''t have the division - by - zero problem if LightPosition.w is zero.

4.)you don''t necessarily need a matrix with infinite far clipping plane if you''re using the extruded shadow volume vertices...
and finite shadow volumes should also work with infinite view projection...

GA
Visit our homepage: www.rarebyte.de.stGA
Kyardan
Kyardan
GA: Thanks for your reply. I got the infinite extrusion working, (though my infinite projection matrix isn''t right apparently, probably a typo or something similar I''m not seeing, will figure it out soon), so it should be completely working soonish. Thanks again. =)

And I had completely missed that scaling the vector here still keeps the direction the same, thank''s for pointing that out.

Kyardan
ga
ga
there was a tip of the day at flipcode about the projection matrix without far clipping.

GA
Visit our homepage: www.rarebyte.de.stGA
Kyardan
Kyardan
Yea I got it, was a stupid bug from me throwing the matrix in hastily (one of the values was wrong). So everythings working now, thanks

Kyardan

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.