point_fragment.glsl 726 B

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