You are allowed to arbitrarily calculate the texture coordinates, and the shader will act accordingly ... within one constraint. Your calculations cannot contain conditional logic. These can include changes, uniforms, constants, values ββselected from other textures, no matter what you want. But at the moment when you glide the same way as the operator ?: There (not to mention the if-statement), you have problems.
And since you're in an OpenGL ES environment, you really don't have the tools to get rid of this problem. Desktop GL 3.0 provides a set of textureGrad functions that allows you to calculate gradients before you achieve conditional logic. But without this you cannot do much.
source share