##
How quickly one forgets (Basic algebra and geometry...)

Written by
on
in
Snaking.

Spent the rest of the evening working on tessellation code, but never did get around to fixing the problem with the Jelle-project tessellation. Instead I realised that I had no test cases for a "combining" tessellation. To understand what that is, consider this shape...

When we render this shape, we want it to look something like this:

To make that happen, we have to create a new vertex at the point where the lines AE and BC intersect. This vertex needs to be a blending of the coordinates, texture-coordinates, colours, and normals of the four contributing vertices. Until this evening, there was some grotty, and incorrect, code in the polygon tessellator which was pretending to do a combine of the vertices, but given that it was broken, I think it's safe to assume we never actually had it run :) . This evening I constructed a test case (which is what's shown above) in order to make sure it works correctly. The shallow error in the combiner for the first three attributes of the vertices was easy to fix, but it took me forever and a day to remember the (trivial) mechanism for weighted combination of normals. I spent a very long time trying to figure out a way to work with the normals using quaternions before I remembered the simple key idea: normals are vectors, you combine them by simply adding them (and then normalising the result). Weighted combinations merely add weighted multiples of the normals. Only complication is that if the normals add to [0,0,0] you have to choose an arbitrary vector perpendicular to*something*, but I just sort of punted on that and made it perpendicular to one contributing vector in the x,y or x,z plane. I figure you'd really want a calculus solution for perfect results, but given how rarely this code is needed it's probably not worth it to solve the problem this evening. You can see the combination of normals in the top shape. The original points all have normals that project forward and away from the center, but the combined point projects pretty much directly forward, that's why the center point is brighter than the outside (the light is shining in the same direction the camera is pointing). Also, realised that there is an over-optimisation in the polygon tessellation code. It takes any four-vertex contour and converts it to two triangles regardless of the position of the vertices. It really should be checking first to see if the vertices are coplanar, and if they are, whether they are producing two polygons with the same winding order (normal) or not, if not, they should likely be going through the tessellator to produce a shape similar to that above. Oh well, something to work on some other time.### Pingbacks

Pingbacks are closed.

## Comments

Comments are closed.