Saturday, January 24, 2009

pow(0,0) = NaN ... Sometimes

Thanks to the folks on the Mac OpenGL lists who helped me figure this out.
pow(0,0) is undefined in the GLSL spec.
On ATI hardware, it seems to return 0.
On NV hardware, it seems to return 0 if the inputs are known at compile time but NaN if they are only available at runtime.
Now it's my fault for ever sending pow(0,0) to GLSL in the first place!  But what threw me was not just that the artifacts (propagating a NaN through your fragment shader generally results in black) were NV specific, but that when I put in test code to identify the problem, they went away. This was because the test code was constant and thus the compile-time pow behavior kicked in.

No comments:

Post a Comment

Post a Comment