material.frag raw
1 #version 310 es
2
3 // SPDX-License-Identifier: Unlicense OR MIT
4
5 precision mediump float;
6
7 layout(binding = 0) uniform sampler2D tex;
8
9 layout(location = 0) in vec2 vUV;
10
11 layout(location = 0) out vec4 fragColor;
12
13 vec3 RGBtosRGB(vec3 rgb) {
14 bvec3 cutoff = greaterThanEqual(rgb, vec3(0.0031308));
15 vec3 below = vec3(12.92)*rgb;
16 vec3 above = vec3(1.055)*pow(rgb, vec3(0.41666)) - vec3(0.055);
17 return mix(below, above, cutoff);
18 }
19
20 void main() {
21 vec4 texel = texture(tex, vUV);
22 texel.rgb = RGBtosRGB(texel.rgb);
23 fragColor = texel;
24 }
25