ZBuffer & Sorting Issues on Vehicles in Torque

We recently began adding more cars to BLUR and just ran up against an old problem. A problem we worked around for the first two cars (by removing the underlying translucent surface), but this time one of the new cars required that we fixed this little problem. A few minutes of our programmer poking around in the engine and this is what we came up with.

The Problem
Translucent glass covering the brake light cluster, and then mounting a translucent glow effect for the brake and reverse lights. The engine does not know where each object is in terms of onscreen depth, and the glows do not appear correctly in front of the glass. We get ZFighting!

The Cause
Well firstly, the ZBuffer never knows where a Translucent object is in Depth Order. Secondly, the sort system that tells the ‘Glow Mesh’ to draw after the ‘Car Mesh’ is based upon the closest point on the bounding box to the camera. So for each item if the mounts for the Glows are within the Bounds of the Car Mesh (thus placing their Bounds inside too) the engine will not know in which order to display each item, or will assume the Car Mesh takes preference.

zfighting

The Fix
A quick and dirty fix via art (without changing any code) was to simply increase the size of the bounds on the Glow Mesh. In other words, increasing the bounds outwards towards the camera, thus forcing it to be seen as the last object in the sort list.

boundsresize

Simple fix, but such an annoying little problem.

😀

Tweet about this on TwitterShare on FacebookShare on Google+Share on TumblrPin on Pinterest

Leave a Reply