lygia
/color
/tonemap
/uncharted2
)Tonemapping function from presentation, uncharted 2 HDR Lighting, Page 142 to 143
Use:
<vec3|vec4> tonemapUncharted2(<vec3|vec4> x)
#ifndef FNC_TONEMAPUNCHARTED2
#define FNC_TONEMAPUNCHARTED2
vec3 tonemapUncharted2(vec3 v) {
float A = 0.15; // 0.22
float B = 0.50; // 0.30
float C = 0.10;
float D = 0.20;
float E = 0.02; // 0.01
float F = 0.30;
float W = 11.2;
vec4 x = vec4(v, W);
x = ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
return x.xyz / x.w;
}
vec4 tonemapUncharted2(const vec4 x) { return vec4( tonemapUncharted2(x.rgb), x.a); }
#endif
Use:
<float3|float4> tonemapUncharted2(<float3|float4> x)
#ifndef FNC_TONEMAPUNCHARTED2
#define FNC_TONEMAPUNCHARTED2
float3 tonemapUncharted2(float3 color) {
float A = 0.15; // 0.22
float B = 0.50; // 0.30
float C = 0.10;
float D = 0.20;
float E = 0.02; // 0.01
float F = 0.30;
float W = 11.2;
float4 x = float4(color, W);
x = ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
return x.xyz / x.w;
}
float4 tonemapUncharted2(const float4 x) { return float4( tonemapUncharted2(x.rgb), x.a); }
#endif
Use:
<vec3|vec4> tonemapUncharted2(<vec3|vec4> x)
fn tonemapUncharted23(v : vec3f) -> vec3f {
let A = 0.15; // 0.22
let B = 0.50; // 0.30
let C = 0.10;
let D = 0.20;
let E = 0.02; // 0.01
let F = 0.30;
let W = 11.2;
var x = vec4(v, W);
x = ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;
return x.xyz / x.w;
}
fn tonemapUncharted24(x : vec4f) -> vec4f { return vec4(tonemapUncharted23(x.rgb), x.a); }
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository