GLES 2.0 doesn’t support nointerpolation (which is normally translated to the varying identifier flat in OpenGL). The alternative of using derivatives in the fragment shader can work, but derivative support is optional for OpenGL ES 2.0, so there’s no guarantee that’ll work either.
It your intent is to support OpenGLES 2.0 android devices, you have to modify the meshes to be actually flat shaded with duplicated vertices.
Thank you, i am trying to use the derivatives method but had no luck with it, do you have a simple on how to do that?
Unfortunately i can not go with doubling the vertices because the mesh gets constantly manipulated over time so doubling them and setting them back would eat too much performance, i think i will limit this shader to just OpenGLES 3.0, to detect it i can use SystemInfo.graphicsShaderLevel >= 35 right?
You don’t have to handle the shader switching on the C# side, you can just use one of the multi-compile directives in the shader to avoid using the nointerpolation if shader level is too low.
#if SHADER_TARGET < 30
float2 cap : TEXCOORD0;
#else
nointerpolation float2 cap : TEXCOORD0
#endif
or
#if SHADER_API_GLES
float2 cap : TEXCOORD0;
#else
nointerpolation float2 cap : TEXCOORD0
#endif
Yes thank you, i did it in both, in the shader so i can build it and in c# because switching to the shader is the user’s choice so i have to hide that option in the interface as well.