PDA

View Full Version : MD2 model shadow volume wierdness



FatalXC
11-05-2002, 01:46 AM
Hi,

I've just got md2 models going in my engine. I've done the bumpmapping and all that and it looks quite cool (Doom3-esque ;-) j/k)

The problem is though when i watch the model animating i see these wierd flickers of black across it. They are related to the shadow volumes becuse when I disable shadows they go away.

Also, when I disable silhouette optimisations and simply extrude every triangle, it doesn't happen, though I then get little shimmering pixels.

When I say silhouette optimisations i mean only extruding the possible silhouette edges rather than every edge.

I can't seem to track this down, and it's really wierd. I'm using the test model from the nvidia infinte shadow volume code so the model should be alright, and im using the same shadow volume method as well, so I'm not sure what could be causing this.

The part that is causing the flickering is the local to infinite extruded quads.

Could it be problems with my edge connectivity code or am I just imagining it :-p

Thanks for any suggestions,
- Richard

SirKnight
11-05-2002, 03:41 AM
This has been discussed on this board not long ago. What you see is triangles popping in and out of shadow. Cass proposed a way to fix this, his fix works well but there are still cases where it failes. He updated the infinite shadow volume code to do this. There is also the trick of insetting the volume into the model along the normal a small amount.

Also if you look closely, even Doom 3 has this popping problem. http://www.opengl.org/discussion_boards/ubb/smile.gif

-SirKnight

FatalXC
11-05-2002, 06:59 PM
Thanks for your reply, but I'm having trouble finding this thread you are talking about. What is the solution Cass proposed?

Thanks
- Richard

yakuza
11-05-2002, 07:54 PM
It was way back on page 10. http://www.opengl.org/discussion_boards/ubb/smile.gif
http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/007479.html

FatalXC
11-05-2002, 09:39 PM
After reading that I don't think that is what I'm seeing.

What happens is that as i watch the md2 animate, occasionally there are wierd black streaks across it. I don't think they are individual triangles. The problem doesnt happen when I extrude every edge on the mesh, but does happen when I only extrude possible silhouette edges.

I'm more than slightly confused :-p

Thanks,
- Richard

dorbie
11-05-2002, 09:55 PM
It's not popping, he'd still get it without optimizations.

Something's up with your optimizations. You must be dropping too many edges. Look at your algorithm for only processing silhouette edges and consider what might be broken. For example does it preserve concave silhouette edges as well as convex?

cass
11-05-2002, 10:33 PM
The other thing to be careful about is that some MD2 models are not closed.

When Doom3 comes out, people will finally start authoring closed models. :-)

Thanks -
Cass

SirKnight
11-06-2002, 03:54 AM
Well if it's streaks, strips, or whatever going black and not just individual triangles then it must be something else. http://www.opengl.org/discussion_boards/ubb/smile.gif



The problem doesnt happen when I extrude every edge on the mesh, but does happen when I only extrude possible silhouette edges.



Hmm, I extrude the possible sil edges and it works ok for me. I'm using the knight md2 model as seen in many opengl demos, including cass's. Could you post your algorithm for finding the edges or something?

-SirKnight


[This message has been edited by SirKnight (edited 11-06-2002).]

FatalXC
11-06-2002, 06:34 PM
Dorbie what are concave and convex sihouette edges? I've never heard that term used before.

I'm using the knight model from the md2 shadow volume demo so the model is closed.

Here is my routine for matching up edges:




const bool ModelMD2::computeWingedEdges()
{
unsigned int i, j, k, l, index0, index1, ind0, ind1, openEdgeCount = 0;
bool found;
for (i = 0; i < m_triCount; ++i)
{
for (j = 0; j < 3; ++j)
{
if (m_tris[i].getEdge(j) != -1)
continue;

found = false;
index0 = m_tris[i][j].index;
index1 = m_tris[i][(j + 1) % 3].index;
for (k = 0; k < m_triCount; ++k)
{
if (k == i) continue;
for (l = 0; l < 3; ++l)
{
ind0 = m_tris[k][l].index;
ind1 = m_tris[k][(l + 1) % 3].index;
if (ind0 == index1 &amp;&amp; ind1 == index0)
{
// Match up edges
m_tris[i].getEdge(j) = k;
m_tris[k].getEdge(l) = i;
found = true;
break;
}
}
if (found) break;
}
if (!found) ++openEdgeCount;
}
}
if (openEdgeCount) logfile << ", open edges = " << openEdgeCount;
return true;
}


I think it is correct because every edge gets matched up.

I'll take a closer look at the quad drawing code, maybe try immediate mode to see if that makes any difference.

Thanks,
- Richard


[This message has been edited by FatalXC (edited 11-06-2002).]

FatalXC
11-06-2002, 09:23 PM
YAY!! I fixed it.

It was nothing to do with the winged edge stuff at all.

What was happening was the code wasn't handling the case where the light is on the triangles plane. It now does correctly handle it and seems to be working fine.

Thank you to everyone for your suggestions, I will have a look at that other thread now because it seems relevant to correct model shading.

Thanks,
- Richard