sprite_fragment.glsl 722 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // Fragment shader for sprite
  3. //
  4. precision highp float;
  5. #include <material>
  6. // Inputs from vertex shader
  7. in vec3 Color;
  8. in vec2 FragTexcoord;
  9. // Output
  10. out vec4 FragColor;
  11. void main() {
  12. // Combine all texture colors and opacity
  13. vec4 texCombined = vec4(1);
  14. #if MAT_TEXTURES>0
  15. for (int i = 0; i < {{.MatTexturesMax}}; i++) {
  16. vec4 texcolor = texture(MatTexture[i], FragTexcoord * MatTexRepeat(i) + MatTexOffset(i));
  17. if (i == 0) {
  18. texCombined = texcolor;
  19. } else {
  20. texCombined = mix(texCombined, texcolor, texcolor.a);
  21. }
  22. }
  23. #endif
  24. // Combine material color with texture
  25. FragColor = min(vec4(Color, MatOpacity) * texCombined, vec4(1));
  26. }