Original Post
I have a shader which uses a time value for a sin() calculation to create a pulsing effect. The time value is measured as the # of seconds since the program started and is passed in as a float to the shader. The problem is that after a certain number of seconds (say, 10000), the time value starts to become imprecise due to the limitations of floating point. To prevent the time value from becoming too large, I have to do something stupid like this: if (shaderTime > 10000.0f) shaderTime = 0.0f; So once every 10000 seconds, you might notice the pulse suddenly flicker for a split second. I know this bug would happen very rarely so in theory this is an acceptable workaround, but it is a sloppy solution I'd prefer to avoid... If I knew the period of the function was 2PI, I could do something like this: if (shaderTime > SomeVeryLargeMultipleOfTwoPi) shaderTime -= SomeVeryLargeMultipleOfTwoPi; This would prevent that flicker from happening, but then if you ever changed the period of the function in the shader (e.g. sin(1.5 * PI)) then I think this wouldn't work. Sorry for the long post, hope that makes sense! Thanks Kuro