Sometimes you might think that its enough to clamp an uninitialized variable to a known range, for instance [0, 1]. You might then think that you don't need no stinkin initializer, I got this handled.
I'm here to tell you that this is not sufficient.
Turns out floating point values have Special Places, where you can't ever touch. For instance, QNAN. Any operation on a QNAN is a QNAN, so these tend to migrate, and what's more, is since the number of possible 4 byte values that will give you a QNAN is fairly small, this bug will appear quite sporadically.
In my case, it would turn the entire game world black (or white, depending), as the value in question was the desaturation lerp parameter. Nominally clamped to [0, 1], when passed as a QNAN, it makes it all the way to the pixel shader, to turn the color of anything affected by the material to QNAN. Sweet action.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment