34 lines
1.0 KiB
GLSL
34 lines
1.0 KiB
GLSL
// All of the interesting code and settings are in Buffer A.
|
|
|
|
/// Convert a color from linear RGB to the sRGB color space.
|
|
vec3 linear2srgb(vec3 color);
|
|
|
|
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
vec2 uv = fragCoord/iResolution.xy;
|
|
vec3 color = texture(iChannel0, uv).rgb;
|
|
fragColor = vec4(linear2srgb(color), 1.0);
|
|
}
|
|
|
|
//////// ================================
|
|
//////// VENDOR: Vendored code
|
|
//////// ================================
|
|
|
|
////
|
|
//// AUTHOR: unknown
|
|
////
|
|
|
|
vec3 linear2srgb(vec3 linear_rgb) {
|
|
// I believe the first version is technically more accurate,
|
|
// but the difference is usually negligable in practice.
|
|
#if 1
|
|
// copied from somewhere on the internet
|
|
bvec3 cutoff = lessThan(linear_rgb, vec3(0.0031308));
|
|
vec3 higher = vec3(1.055)*pow(linear_rgb, vec3(1.0/2.4)) - vec3(0.055);
|
|
vec3 lower = linear_rgb * vec3(12.92);
|
|
|
|
return mix(higher, lower, cutoff);
|
|
// end copied from somewhere on the internet
|
|
#else
|
|
return pow(linear_rgb, vec3(1./2.2));
|
|
#endif
|
|
} |