I have a GLSL ES 3.0 shader and in certain scenario, I want to read from two textures instead of one and do a lerp between them.
However, I am not sure what is a better solution.
Use standard runtime if like:
vec4 res = vec4(0);
if (enable2Tex){
res = mix(texture2d(s1, tx), texture2d(s2, tx), t)
}
else {
res = texture2d(s1, tx);
}
or should I create two versions of the same shader like:
vec4 res = vec4(0);
#ifdef ENABLE_2_TEX
res = mix(texture2d(s1, tx), texture2d(s2, tx), t)
#else
res = texture2d(s1, tx);
#endif
and switch between two shaders in code?
...by trying each method you've proposed, and measuring which gives you better performance...
This is problematic for mobile phones which performance can vary significantly (or based on used GPU at least), so I was thinking that maybe someone has some insight or prior knowledge of this problem \$\endgroup\$