When the fractional part of a float fixes your shader
a day ago
- The author implemented a Voronoi diagram shader for a music video background and encountered a stutter on a Windows PC with an RTX 4070.
- Debugging involved isolating the issue to the noise function; replacing `fract(x)` with `x - floor(x)` temporarily fixed it.
- Further investigation using RenderDoc and disassembly revealed that changing a literal float from 398.0 to 398.1 eliminated the stutter.
- The root cause was identified as a miscompilation in the DirectX FXC compiler, which optimized away the `fract` call for integer-like inputs via the ANGLE transpilation layer.
- The issue was specific to Windows systems using ANGLE to convert GLSL to HLSL for DirectX 11, and did not occur on other platforms or APIs.