Suppose we have the following fragment shader:
varying vec2 vUv; // uv coordinates
varying float vTexture; // texture index in array of textures
uniform sampler2D textures[2]; // number of textures
void main() {
int textureIndex = int(floor(vTexture)); // convert texture index to int for equality checks
if (textureIndex == 0) {
gl_FragColor = texture2D(textures[0], vUv);
}
if (textureIndex == 1) {
gl_FragColor = texture2D(textures[1], vUv);
}
}
If a given value coming through this shader has a textureIndex = 0, will that value check the second if conditional, or will the establishment of gl_FragColor cause the main()
function to "return" or exit? Is there a way to force a fragment shader to exit or return at a given point?