29 lines
804 B
Text
29 lines
804 B
Text
|
/*
|
||
|
* ACES tone mapping
|
||
|
* From 'Baking Lab' by MJP and David Neubelt
|
||
|
* Original by Stephen Hill
|
||
|
* https://github.com/TheRealMJP/BakingLab/blob/master/BakingLab/ACES.hlsl
|
||
|
* Licensed under the MIT license
|
||
|
*/
|
||
|
|
||
|
#version 330 core
|
||
|
|
||
|
// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
|
||
|
const mat3 ACESInputMat = mat3(
|
||
|
0.59719, 0.07600, 0.02840,
|
||
|
0.35458, 0.90834, 0.13383,
|
||
|
0.04823, 0.01566, 0.83777);
|
||
|
// ODT_SAT => XYZ => D60_2_D65 => sRGB
|
||
|
const mat3 ACESOutputMat = mat3(
|
||
|
1.60475, -0.10208, -0.00327,
|
||
|
-0.53108, 1.10813, -0.07276,
|
||
|
-0.07367, -0.00605, 1.07602);
|
||
|
|
||
|
vec3 aces_fitted(vec3 color)
|
||
|
{
|
||
|
vec3 v = ACESInputMat * color;
|
||
|
vec3 a = v * (v + 0.0245786) - 0.000090537;
|
||
|
vec3 b = v * (0.983729 * v + 0.4329510) + 0.238081;
|
||
|
return clamp(ACESOutputMat * (a / b), 0.0, 1.0);
|
||
|
}
|