Add gammaToLinear and linearToGamma shader helpers;

This commit is contained in:
bjorn 2023-09-28 05:10:26 -07:00
parent 684560ef81
commit 7486108462
1 changed files with 8 additions and 0 deletions

View File

@ -435,6 +435,14 @@ vec3 tonemap(vec3 x) {
}
#endif
vec3 gammaToLinear(vec3 color) {
return mix(pow((color + .055) / 1.055, vec3(2.4)), color / 12.92, lessThanEqual(color, vec3(.04045)));
}
vec3 linearToGamma(vec3 color) {
return mix(1.055 * pow(color, vec3(1. / 2.4)) - .055, color * 12.92, lessThanEqual(color, vec3(.0031308)));
}
// Entrypoints
#ifndef NO_DEFAULT_MAIN
#ifdef GL_VERTEX_SHADER