Sign in to follow this  
VladR

Shadow Volume Artifact (Screenshot Included)

Recommended Posts

Following Picture consists of two screens: Scr2 displays working volume shadows with torus (from SDK`s .x file). Scr1 displays my character model (1500 tris). As you can see, the character`s shadow is messed up. What could be the problem, when the torus has correct shadow ? The only thing I`m changing is shader where the only difference is in declaration where there is also a texture coordinate (I know it`s not needed for shadows, but it`s OK for start since I don`t need to create separate Stream). Torus doesn`t have texture coordinates but this shouldn`t be an issue, since the character model renders correctly in first pass. Any ideas what could be wrong ? Thanks

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
When computing the shadow volume from your mesh, you need to take into account its vertex stride, in order to get each vertex position.
If your mesh has a UV coordinate, its vertex stride is bigger than if it hasn't...
Check the FVF declaration (or vertex declaration) when computing shadow volume in order to properly get vertices positions from the VB...

Share this post


Link to post
Share on other sites
But, isn`t stride important only in fixed-function pipeline ? I mean, I don`t have to set FVF for my character shader, since its DWORD [] Declaration has all that a shader needs , right ?
Besides, if it is a stride problem, how come that the character model is rendered correctly without shadow passes, i.e. when i render only the character ?
And another difference is that the torus is rendered with DrawIndexedPrimitive, while the character is rendered only with DrawPrimitive (i.e. no idices). But that shouldn`t matter, right ?

Share this post


Link to post
Share on other sites
Ok, it took me a half an hour, but I created a separate VB (to make sure that stride isn`t a problem)without texture coordinates from original data, therefore now I`m using same FVF&Shader declaration as with what is present with torus (that works). Still the same problem, when I render torus, it`s ok, but when i render character, its shadow is same as in above picture - though the character is rendered properly, so it might be something with the mesh itself ? Or something completely different ?

Share this post


Link to post
Share on other sites
hi,

In the left screenshot, your mesh is simply not a closed shape (well, the artefacts are really similar to the ones you have when rendering a non closed mesh)
e.g. some edges are connected to only 1 face.
You've got 2 choices here : close your mesh using your favorite 3D software, or implementing an algorithm that add faces to close the mesh just after loading it.

.:: Paic Citron ::.

Share this post


Link to post
Share on other sites
Hm,thanks, but what is the problem with non-closed triangles (if that is really the problem), when I`m using non-indexed rendering through DrawPrimitive ? I mean, vertex shader receives triangle after triangle, how can it know if some edge is shared by one/two/more triangles ? I obviosuly seem to misss some fundamental issue here. I already did some basic search on closed meshes here on gamedev, but only one topic discussed it a little further so far.

The only thing I`m thinking of now is the difference in position for same vertex in different edges (although it might be a difference in a range of 0,0001), which could after projection be bigger and therefore visible.

Can anyone shed some light why that [closed tris] is problem ?

Thanks

Share this post


Link to post
Share on other sites
How big is the buffer for the shadow volume? It might work fine with a torus that only has 500 vertices, but then crap out when you're building a volume for something with 1500 for a pretty simple reason -- there isn't enough room in the buffer.

Share this post


Link to post
Share on other sites
hi again

question : how do you compute your shadow volume : do you compute it in software, are do you use a shader to do the extrusion of the vertices ?

I will give more details after your answer ^^

And i'm pretty sure that the problem comes from the mesh which is not closed.

You can try something : model a simple closed shape with the program you used to model your character (a sphere then move some vertices for example) and then export it as .x the same way you did for your character and test the result.

If you don't see artefacts, that means that the problem comes from what I said (not a closed mesh)

.:: Paic Citron ::.

Share this post


Link to post
Share on other sites
Quote:
Original post by Etnu
How big is the buffer for the shadow volume? It might work fine with a torus that only has 500 vertices, but then crap out when you're building a volume for something with 1500 for a pretty simple reason -- there isn't enough room in the buffer.
Hm, I`m not sure what you are talking about, you`re not talking about vertex buffer, right ? Because those are created separately for both torus and character. It`s just render functions that I rename - i.e. either it renders torus or character, the rest of code remains unchanged so that i can easily find the source of problems.
If you mean some other buffer, maybe that`s the problem, since I`m not creating one, although it`s strange that torus casts shadows just OK (if this buffer is the problem, that is).

Share this post


Link to post
Share on other sites
Quote:
Original post by paic
hi again
question : how do you compute your shadow volume : do you compute it in software, are do you use a shader to do the extrusion of the vertices ?
I will give more details after your answer ^^
And i'm pretty sure that the problem comes from the mesh which is not closed.

You can try something : model a simple closed shape with the program you used to model your character (a sphere then move some vertices for example) and then export it as .x the same way you did for your character and test the result.

If you don't see artefacts, that means that the problem comes from what I said (not a closed mesh)

.:: Paic Citron ::.

Within an hour the modeller should come to my place and we`ll try exporting simpler objects first to .X file and then to our formats, although format is 99% problem-free. We`ll try parts of character and later whole character.

Regarding algorithm, I use shader to extrude the volume (move vertices along normal), first render it normally (to color buffer), then change the shader to extrude shader and render to stencil twice (increment, decrement). Of course there are plenty of render-state changes in-between. But the code is probably OK, since it works with torus, so the more probable answer is that the problem is in closed shape.

I`ll report back as soon as we try different exported objects. Thanks.

Share this post


Link to post
Share on other sites
I had similar problem. My meshes were not closed too... I even tried this algorithm on boxes (which is far from closed)... very ugly results ;)
Now I use shadow mapping instead 0:-)

Share this post


Link to post
Share on other sites
Quote:
Original post by Bulma
I had similar problem. My meshes were not closed too... I even tried this algorithm on boxes (which is far from closed)... very ugly results ;)
Now I use shadow mapping instead 0:-)
In the mean-time I`ve searched gamedev with google (wow it works finally after the recent site changes, never worked before during last years) and everybody seems to offer same advice go with shadow maps. Just a quick question, shadow-maps don`t care if a mesh is not closed ? Because we`ve got about 8 characters fully animated and imported into engine. I don`t want to start exporting them again,that would be a nightmare. And that`s considering that all holes would be closed in modelling program easilly, which doesn`t seem to be the case based on what i`ve read so far...

Either way, circular shadows aren`t that bad, are they ;) ?

Share this post


Link to post
Share on other sites
The DirectX 9.0c SDK (and perhaps earlier I'm not sure) shadow volume sample documentation explains how to modify your mesh so that it remains closed when extruded by the shader.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this