zmaterial.frag.0.glsl100es 863 B

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