5 vec3 srgb_to_linear(vec3 color)
7 bvec3 near_zero = lessThan(color, vec3(0.04045));
8 vec3 gamma = pow((color.rgb+0.055)/1.055, vec3(2.4));
9 return mix(color.rgb/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 vec3 srgb_to_linear(vec3 color)
48 return mix(color.rgb/12.92, pow((color.rgb+0.055)/1.055, vec3(2.4)), lessThan(color, vec3(0.04045)));
50 vec4 srgb_to_linear(vec4 color)
52 return vec4(srgb_to_linear(color.rgb), color.a);
54 layout(location=0) out vec4 frag_color;
55 in vec2 _vs_out_texcoord;
58 frag_color = srgb_to_linear(texture(tex, _vs_out_texcoord));