Shadow Volume on Vertex Buffer problem

Started by
2 comments, last by mattm 18 years, 10 months ago
Hi, I have been reading the SahderX2 Introductions and Tutorials and trying to get the finite shadow on HLSL working. However, i cannot get it to successfully calculate the sillouete and degenerative quads. After trying with my own algorithm i imported the one from the book CD (with no changes) and when i attempt to perfrom the processing on a sphere (generated from the D3DXCreateSphere method) it logs that the sphere is not a closed mesh and i get weird shadows (although teh rest appears to be working from what i can see)! Is there anything i need to do with the sphere generated in this way to make it a closed mesh as i thought it already was! In addition, does anyone know of any good articles for the calculation of the sillouete and degenerative quads for performing shadow rendering on the vertex shader to help me expand my knoweldge on this? Matt
Advertisement
Hi,

First, when using the shader version of the shadow volume algorithm, you don't have any silouhette to compute. You just need to precompute your geometry to add the degenerative triangles.

Well, for the "bug" of the algorithm you picked up from the book ... it seems that the sphere generated by D3DX is not a good example ^^ Did you try to test it with a mesh exported from Maya or 3DSMax ?? (I'm pretty sure the sphere generated by D3DX is not closed e.g. duplicated vertices)

And the last : the algorithm to add degenerative triangles is really simple. First, get the list of segments, and which triangle they're linked to. Then, check if each segment is linked to exactly 2 triangles (if not, you'll get artefacts) After that, for a segment formed by 2 vertices v0 and v1, you simply have to add 2 vertices v2 and v3 in the vertex shader (these vertices are the exact copy of v0 and v1) and then to add 2 triangles (in the index buffer) formed by (v0, v1, v2) and (v1, v3, v2)

The only thing you have to take care of is the CCW order of the 2 triangle you add ! Be carefull about that.
Thanks for he rely.

I got it to work with the example in the book so i knew the algorithm worked for this, but i was doing all my testing with a sphere so wanted to use this. I don't have access to those 3D programs (unfortunately) but i will try an export from blender and see how i go.

Thanks,

Matt
OK, figured this out. I was specifiying a vertex declaration of Position, Normal and UV coords for my source mesh just prior to the inserting of degenerative quads. Some of the objects I was importing, and the default sphere created as above, did not have UV coordinates. Obviously this meant my "jump" distance, to get to the start of the next vertex in the vertex buffer, was wrong and i was putting normals into positions etc etc.

Just thought i would post incase someone else experienced such an issue.

Matt

This topic is closed to new replies.

Advertisement