Reputation: 75
I am trying to alter the texture coordinates in the fragment shader. Precision is set to medium. It works on some devices but causes severe pixelation on some (cheaper) devices. I assume this is a precision problem but its odd because I have set default to medium which should be available on all devices. Any idea? Thanks for your time.
+"mediump vec2 coords=v_TexCoordinate; \n"
+"coords+=0.1; \n"
Upvotes: 1
Views: 286
Reputation: 6766
mediump is only defined in the spec in terms of a minimum allowable precision. There are devices out there which can implement mediump as a highp (i.e. as more or less a single precision 32 bit float).
There may be other devices which genuinely have a mediump (half precision float alike) and separate highp in hardware, but use some heuristic to notice that it's a texture coordinate and decide that you're better off with the higher precision.
Other devices still, may move your trivial tex coordinate modification to the vertex shader, and will use the texture coordinates output by the vertex shader to prefetch the texels before the fragment shader even executes (and thus avoid the fragment shader's shonky precision altogether).
So just because you ask for mediump everywhere, it's not unusual that you can only repro precision issues on a subset of your devices.
In terms of fixing it - from what you've included in your question, you could just do the tex coordinate modification on the vertex shader.
Upvotes: 1