Re: pfdTMesher.c improvement

New Message Reply Date view Thread view Subject view Author view

Steve Baker (sbaker++at++link.com)
Thu, 16 Oct 1997 13:56:12 -0500 (CDT)


On Thu, 16 Oct 1997 ROBERT_REIF++at++ntsc.navy.mil wrote:

> A few weeks ago I was having problems getting the Performer tmesher
> to convert some coplanar triangles into triangle strips. I looked
> into the problem and discovered that the tmesher was able to retessellate
> some quads into triangles that could be striped. It does this by
> retessellating future quads as they are added to the strip. However, if
> the strip starts out wrong, the retessellation code wont help.
  
CAVEAT: It's a long time since I looked at this - and it might have been
fixed recently - but....

IIRC, there is a bad problem with the Performer tmesher in the area of this
retessellate code. What ideally happens is this:

1) You shove a quad into the tmesher somewhere in the DB loader.
2) It splits it (arbitrarily) into two (coplanar) triangles along
   a diagonal.
3) The tmesher decides to retesselate to make a longer strip.
4) This is A GOOD THING.

However, what *can* happen is this:

1) You shove two coplanar triangles that share a common edge and which
   have the same texture, etc into the tmesher.
2) The tmesher thinks this could be a quad and retesselates to make
   a longer strip.
3) Your original pair of triangles have now been switched into a
   new pair of triangles.
4) This *sounds* like A GOOD THING.

What I found can happen is that the two triangles can have different colour
shading gradients. Then, the retessellation causes a change in the appearance
of the model.

Consider two colour shaded triangles:

    Red ______ Green
| /|
| / |
| / |
| / |
| / |
|/_____|
   Green Blue

As drawn, the point in the very center of the square is green.
However, when the tmesher retesselates the new colour at the center of
the square is halfway between red and blue (a dark shade of magenta)
- a colour that was never supposed to be in the model.

This isn't a problem (I suppose) for a TRUE quadrilateral - since I
didn't have any reason to assume what the colour of the middle of the
quad would be (it's undefined) - but for a pair of triangles, I have
a reasonable expectation that the colour along the diagonal is known -
and more importantly, that the colour of the pixels within the triangle
lie somewhere between the colours at its vertices.

The problem can also show up when surface normals are attached to the vertices
and the 'curvature' of the surface is not uniform. Even worse things happen
when the texture map is stretched more over one triangle than the other.

Here are the texture coordinates at the vertices:

   (0,1)______(1,1)
| /|
| / |
| / |
| / |
| / |
|/_____|
   (0,0) (10,1)

The texture coord at the center of the square should be (0.5,0.5) - but
if the retesselator gets it's hands on it, it'll come out to (5,1).

Apologies if this has been fixed - I doubt that it has though.

What we did to provide a better retesselate check is to check the 'planarity'
of the two triangles - not just in (X,Y,Z) space [as the existing tmesher does],
but in (X,Y,Z,S,T,nX,nY,nX,R,G,B,A) space. We form a 12-dimensional coordinate
for each vertex, figure out the 12D hyper-plane equations and check that they
are the same (to some tolerance).

It's not often you get to do 12-dimensional math - Cool or what?! :-)

Steve Baker 817-619-8776 (Vox/Vox-Mail)
Hughes Training Inc. 817-619-4028 (Fax)
2200 Arlington Downs Road SBaker++at++link.com (eMail)
Arlington, Texas. TX 76005-6171 SJBaker1++at++airmail.net (Personal eMail)
http://www.hti.com http://web2.airmail.net/sjbaker1 (personal)

** Beware of Geeks bearing GIF's. **

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:05 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.