zmaterial.frag.0.glsl150 811 B

123456789101112131415161718192021222324252627282930313233343536
  1. #version 150
  2. struct Color
  3. {
  4. float emulateSRGB;
  5. };
  6. uniform Color _color;
  7. uniform sampler2D tex;
  8. in vec2 vUV;
  9. out vec4 fragColor;
  10. vec3 RGBtosRGB(vec3 rgb)
  11. {
  12. bvec3 cutoff = greaterThanEqual(rgb, vec3(0.003130800090730190277099609375));
  13. vec3 below = vec3(12.9200000762939453125) * rgb;
  14. vec3 above = (vec3(1.05499994754791259765625) * pow(rgb, vec3(0.416660010814666748046875))) - vec3(0.054999999701976776123046875);
  15. return vec3(cutoff.x ? above.x : below.x, cutoff.y ? above.y : below.y, cutoff.z ? above.z : below.z);
  16. }
  17. void main()
  18. {
  19. vec4 texel = texture(tex, vUV);
  20. if (_color.emulateSRGB == 0.0)
  21. {
  22. vec3 param = texel.xyz;
  23. vec3 _71 = RGBtosRGB(param);
  24. texel.x = _71.x;
  25. texel.y = _71.y;
  26. texel.z = _71.z;
  27. }
  28. fragColor = texel;
  29. }