mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Improve precision of the gammaToLinearPrecise shader function.
This commit is contained in:
@@ -138,13 +138,13 @@ GLSL.FUNCTIONS = [[
|
||||
#endif
|
||||
|
||||
float gammaToLinearPrecise(float c) {
|
||||
return c <= 0.04045 ? c * 0.077399380804954 : pow((c + 0.055) * 0.9478672985782, 2.4);
|
||||
return c <= 0.04045 ? c / 12.92 : pow((c + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
vec3 gammaToLinearPrecise(vec3 c) {
|
||||
bvec3 leq = lessThanEqual(c, vec3(0.04045));
|
||||
c.r = leq.r ? c.r * 0.077399380804954 : pow((c.r + 0.055) * 0.9478672985782, 2.4);
|
||||
c.g = leq.g ? c.g * 0.077399380804954 : pow((c.g + 0.055) * 0.9478672985782, 2.4);
|
||||
c.b = leq.b ? c.b * 0.077399380804954 : pow((c.b + 0.055) * 0.9478672985782, 2.4);
|
||||
c.r = leq.r ? c.r / 12.92 : pow((c.r + 0.055) / 1.055, 2.4);
|
||||
c.g = leq.g ? c.g / 12.92 : pow((c.g + 0.055) / 1.055, 2.4);
|
||||
c.b = leq.b ? c.b / 12.92 : pow((c.b + 0.055) / 1.055, 2.4);
|
||||
return c;
|
||||
}
|
||||
vec4 gammaToLinearPrecise(vec4 c) { return vec4(gammaToLinearPrecise(c.rgb), c.a); }
|
||||
|
||||
Reference in New Issue
Block a user