I have a thorny issue I'm trying to solve inside a webgl GLSL fragment shader. For context, I'm implementing a flocking simulation using a ping-pong technique. Everything works properly on PC & Mac, but is buggy on IOS (in Safari/Chrome/Firefox). There is no error, just behavior that is incorrect.
I've tracked it down to a place where I'm using a vec4 that is sampled from a texture, and that value seems corrupt in some way. If I do not use the sampled value, the results are similar on IOS as other devices.
I believe the sampled value has a corrupt, or otherwise unexpected value because of this behavior:
vec4 sampled = texture2D( inputTexture, textureCoordinate);
// a condition that shouldn't fire
// except perhaps for a 'special value' -
// (e.g. something like nil, null, NaN, undefined)
if (sampled.x > 0.0 && sampled.x <= 0.0) {
// do something that modifies behavior
// THIS FIRES! WHY!
}
Anyone have any clues that might point me in the right direction? Is there a good way to debug values within fragment shaders that might help?