copy.frag 533 B

123456789101112131415161718192021222324
  1. #version 310 es
  2. // SPDX-License-Identifier: Unlicense OR MIT
  3. precision mediump float;
  4. layout(binding = 0) uniform sampler2D tex;
  5. layout(location = 0) in highp vec2 vUV;
  6. layout(location = 0) out vec4 fragColor;
  7. vec3 sRGBtoRGB(vec3 rgb) {
  8. bvec3 cutoff = greaterThanEqual(rgb, vec3(0.04045));
  9. vec3 below = rgb/vec3(12.92);
  10. vec3 above = pow((rgb + vec3(0.055))/vec3(1.055), vec3(2.4));
  11. return mix(below, above, cutoff);
  12. }
  13. void main() {
  14. vec4 texel = texture(tex, vUV);
  15. texel.rgb = sRGBtoRGB(texel.rgb);
  16. fragColor = texel;
  17. }