Shawn Hargreaves Blog
I keep thinking I'm done writing about MotoGP, but then more topics occur to me.
And then I think, is this just self indulgent rambling through the meadows of nostalgia? "Here's a tall tale from back when I was a lad, when computers were still programmed in binary and Tony Blair was popular..." But people seem to be enjoying this series, so I guess you'll have to bear with me a while longer.
Now where was I?
MotoGP tracks were split into sectors using a kd-tree (similar to an octree). Each sector was tessellated at three levels of detail, so we could draw the nearby environment with nice smooth curves but use fewer triangles for more distant pieces.
When you join pieces of environment that are tessellated differently, there will be cracks where they do not exactly meet up. This is a common problem in terrain rendering, often solved by adding fringes or stitching in extra triangles to fill the holes.
We chose an easier solution. Our content build process simply detected which edges were shared by patches from more than one sector, and always tessellated those edges at maximum detail, even when creating the medium or low detail geometry. This freed the game code to draw each sector at whatever detail level it liked, and everything was guaranteed to join up without requiring special runtime logic. Sure, this added a few extra triangles to our low detail geometry, but the vast majority of patch edges did not lie on sector boundaries, so the cost was insignificant.
Takeaway: moving work from game engine to content build process = good stuff.
Tesselating edges to the same level of detail solves T-junction problems, but there may still be precision problems. Were you storing your geometry positions as full-precision floats? If not, were there any problems with gaps because of precision, and if there were, how did you solve them?
You're absolutely right, I am really enjoying this series! Clever solution to avoid the cracks.
Shawn, even if this is "self indulgent rambling through the meadows of nostalgia," I've found the series facinating. The game was ahead of its time when it came out, and it's still enjoyable to hear how it was done after so many years.
You even lured Dr. Pepper in here to provide his comments. Brings back some good memories.
- Brian, aka "Dark Gekko"
> Tesselating edges to the same level of detail solves T-junction problems, but there may still be precision problems. Were you storing your geometry positions as full-precision floats?
Precision is only a problem if you use a different coordinate system for each sector. We stored all our environment geometry in worldspace rather than sector-relative coordinates, so that was not a problem.
If I remember the right the track used 32 bit float vertex positions, but bikes and riders used 16 bit integer to save space & bandwidth.