Float precision error on iOS

classic Classic list List threaded Threaded
3 messages Options
dcremoux dcremoux
Reply | Threaded
Open this post in threaded view
|

Float precision error on iOS

Hello all,

I've faced a strange behavior: a ShaderGenerator generated shader program is inserting a "precision mediump float" in the middle of the shader program. It is worth noticing that before this, a "precision highp float" has been already defined for the same program, but due to GLSL ES 3.00 specifications, the last one is taken into account for the (global) scope.
Then due to floating point precision errors (i.e.: matrices computations), some vertices are not displayed, "probably" clipped (i.e.: when graphic debugging on iOS, when removing the mediump line, vertices appear).

I was thinking of modifiying the ShaderGenerator.cpp #define GLSL_PRECISION from mediump to highp.

Is there something I should be aware before doing that? Is it a good idea to do it or not? (beside maybe some performance implications).

Thanks in advance !
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Float precision error on iOS

Honestly I really do not know the implications of changing that.
Perhaps we need to make it configurable?
Glenn Waldron / Pelican Mapping
dcremoux dcremoux
Reply | Threaded
Open this post in threaded view
|

Re: Float precision error on iOS

Thanks for your answer,

Yes it could be something configurable indeed. In some sort, it already is, as it is defined as a macro (#define GLSL_PRECISION) in ShaderGenerator.cpp.
Though it is worth noticeable that the same purpose macro is used in VirtualProgram (#define GLSL_DEFAULT_PRECISION_FLOAT) but with a different value (highp in this case).

Maybe using the same macro for both of these files could be a start?

Thanks again