Shadow Volume Artifact (Screenshot Included)

Started by
11 comments, last by Mastaba 19 years, 8 months ago
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

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

Advertisement
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...
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 ?

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

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 ?

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

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 ::.
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

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

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.

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

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 ::.
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).

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

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.

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

This topic is closed to new replies.

Advertisement