2
0

opengl_fragment.glsl 502 B

1234567891011121314151617181920212223
  1. uniform sampler2D baseTexture;
  2. uniform sampler2D normalTexture;
  3. uniform sampler2D textureFlags;
  4. #define leftImage baseTexture
  5. #define rightImage normalTexture
  6. #define maskImage textureFlags
  7. varying mediump vec4 varTexCoord;
  8. void main(void)
  9. {
  10. vec2 uv = varTexCoord.st;
  11. vec4 left = texture2D(leftImage, uv).rgba;
  12. vec4 right = texture2D(rightImage, uv).rgba;
  13. vec4 mask = texture2D(maskImage, uv).rgba;
  14. vec4 color;
  15. if (mask.r > 0.5)
  16. color = right;
  17. else
  18. color = left;
  19. gl_FragColor = color;
  20. }