I wrote:
> Jim Wilson wrote:
> > Wolfram Kuss wrote:
> > > I can even guess what the new info does: It says edges less than
> > > 45 degrees are smooth and more than 45 degrees are sharp.
> >
> > That might be difficult to implement in plib anyway.  I did a
> > little looking into this recently (as a parameter setting by the
> > app,not a ac3d 4.0 attribute).  Basically my investigation
> > revealed that plib would have to split vertices (create duplicates
> > on adjacent polygons) if their normal values weregreater than x
> > degrees from each other.
>
> I have working code that does this, from my game project a few
> months back.  Indeed, the idea is to start at each vertex in the
> mesh and walk around it, checking the angle of each edge you cross.
> Angles sharper than your threshold are flagged.  You end up with a
> list of "zones" of smooth edges, which each get a new vertex with an
> appropriately averaged normal.

OK, I got this code working in Plib.  It took a little hunting around,
but I finally discovered the OptVertexList stuff in ssgOptimizer which
works in pretty much the same data model that my code was expecting.
As implemented, this replaces the makeNormals() routine in the
optimizer with a further-optimizing variant which intelligently splits
vertices across sharp edges, to prevent the non-physical lighting
artifacts that are seen when a vertex normal points in a radically
different direction from that of the face to which it is attached.

Some "before & after" FlightGear screenshots are available at:

  http://www.plausible.org/vertsplit

  [Be patient if things seem slow; there is 400k of images on that page
   and my DSL line has a 128kbps upload rate.  If you don't want to
   wait, download the code instead and try it for yourself. :)]

IMHO, the geometry of the models looks much more solid and realistic
with correct lighting.  The effect that this patch has depends on the
model that is being lit, of course.  Models that are already highly
tesselated (Lee's, for example) won't see much effect, but low poly
models (like David's DC-3, 172 or Cub) look much better.

Amusingly, one thing this patch doesn't do is fix the AC3D parser
issue that started the discussion.  Right now, the definition of
"sharp" is fixed in code at an (interior) edge angle of 52�.  It
shouldn't be hard to get this parsed and turned into a property of the
resulting ssg branch, but since I don't know much about either area of
the code I thought I'd leave it for someone with more ssg experience.
The new code isn't AC3D-specific, of course.  It will work
automatically for any Plib objects that call the optimizer to
calculate their normals.

Anyway, grab the new code (two new files, associated additions to
Makefile.am and a modified ssgOptimizer.cxx) from
http://www.plausible.org/vertsplit/vertsplit.tar.gz and try it out.
Let me know what breaks; I've tested it only with FlightGear.

Andy



_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to