PDA

View Full Version : How to fight with t-junctions?



Optimizer
11-28-2003, 09:10 AM
Hello,

I am developing own game and faced with an issue of t-junctions (when I move around the level some pixels at a distence flash).

How to avoir t-junction? Is there any solution to prevent this?

davepermen
11-28-2003, 09:18 AM
first and best way: don't create them at all first
second and hackish, but sometimes useful way:
fill them. how to do that? depending on your data you can fast determine where they are (heightmaps with geomipmapping for example), and then you can just add a triangle with the help of indexing into it.

SirKnight
11-28-2003, 04:59 PM
Do you happen to have access to the book Game Programming Gems 3 by any chance? Eric Lengyel (doesnt he post here?) wrote an article about how to find and eliminate t-junctions. It's a bit too much info to post all here. If you can take a look at that book it would be just what you need.


-SirKnight

[This message has been edited by SirKnight (edited 11-28-2003).]

Humus
11-29-2003, 08:32 AM
Coincidentally, I faced the same problem and wrote some code to fix that today. I usually use the Unreal editor to create my worlds. That editor however is notoriously bad at creating t-junctions. So I wrote a piece of code that fixes it. If you're interested you can go to my website and grab my framework. The code can be found in model.cpp. http://esprit.campus.luth.se/~humus/

Basically, what you do is to just for each vertex check if it lies on the edge on any other triangle. If it does, then split that triangle into two at that vertex, either by reusing the existing vertex or by creating a new one if needed.

Eric Lengyel
11-29-2003, 01:42 PM
Yes, Eric Lengyel is lurking about. The GPG3 article mentioned by SirKnight does describe a possible solution to the problem. A slightly updated version can be found in Chapter 9 of the just-released second edition of Mathematics for 3D Game Programming and Computer Graphics:

http://www.terathon.com/books/mathgames2.html

Implementing general T-junction elimination is a significant amount of work, but the results are nice seamless environments (which are necessary for certain types of engines -- e.g., those that use stencil shadows).