sprite_fragment.glsl 698 B

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