5 vec3 srgb_to_linear(vec3 color)
7 bvec3 near_zero = lessThan(color, vec3(0.04045));
8 vec3 gamma = pow((color+0.055)/1.055, vec3(2.4));
9 return mix(color/12.92, gamma, near_zero);
11 vec4 srgb_to_linear(vec4 color)
13 return vec4(srgb_to_linear(color.rgb), color.a);
16 #pragma MSP stage(vertex)
17 layout(location=0) in vec4 position;
18 layout(location=1) in vec2 texcoord;
22 gl_Position = mvp*position;
25 #pragma MSP stage(fragment)
26 layout(location=0) out vec4 frag_color;
29 frag_color = srgb_to_linear(texture(tex, texcoord));
32 /* Expected output: vertex
34 layout(location=0) in vec4 position;
35 layout(location=1) in vec2 texcoord;
36 out vec2 _vs_out_texcoord;
39 _vs_out_texcoord = texcoord;
40 gl_Position = mvp*position;
44 /* Expected output: fragment
45 uniform sampler2D tex;
46 layout(location=0) out vec4 frag_color;
47 in vec2 _vs_out_texcoord;
50 vec4 color = texture(tex, _vs_out_texcoord);
51 vec3 color_1 = color.rgb;
52 frag_color = vec4(mix(color_1/12.92, pow((color_1+0.055)/1.055, vec3(2.4)), lessThan(color_1, vec3(0.04045))), color.a);