point_fragment.glsl 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. precision highp float;
  2. #include <material>
  3. // Inputs from vertex shader
  4. in vec3 Color;
  5. flat in mat2 Rotation;
  6. // Output
  7. out vec4 FragColor;
  8. void main() {
  9. // Compute final texture color
  10. vec4 texMixed = vec4(1);
  11. #if MAT_TEXTURES > 0
  12. vec2 pointCoord = Rotation * gl_PointCoord - vec2(0.5) + vec2(0.5);
  13. bool firstTex = true;
  14. if (MatTexVisible(0)) {
  15. vec4 texColor = texture(MatTexture[0], pointCoord * MatTexRepeat(0) + MatTexOffset(0));
  16. if (firstTex) {
  17. texMixed = texColor;
  18. firstTex = false;
  19. } else {
  20. texMixed = Blend(texMixed, texColor);
  21. }
  22. }
  23. #if MAT_TEXTURES > 1
  24. if (MatTexVisible(1)) {
  25. vec4 texColor = texture(MatTexture[1], pointCoord * MatTexRepeat(1) + MatTexOffset(1));
  26. if (firstTex) {
  27. texMixed = texColor;
  28. firstTex = false;
  29. } else {
  30. texMixed = Blend(texMixed, texColor);
  31. }
  32. }
  33. #if MAT_TEXTURES > 2
  34. if (MatTexVisible(2)) {
  35. vec4 texColor = texture(MatTexture[2], pointCoord * MatTexRepeat(2) + MatTexOffset(2));
  36. if (firstTex) {
  37. texMixed = texColor;
  38. firstTex = false;
  39. } else {
  40. texMixed = Blend(texMixed, texColor);
  41. }
  42. }
  43. #endif
  44. #endif
  45. #endif
  46. // Generates final color
  47. FragColor = min(vec4(Color, MatOpacity) * texMixed, vec4(1));
  48. }