LYGIA Shader Library

filmic (lygia/color/tonemap/filmic)

Haarm-Peter Duikers curve from John Hables presentation "Uncharted 2 HDR Lighting", Page 140, http://www.gdcvault.com/play/1012459/Uncharted_2__HDR_Lighting

Dependencies:

Use:

<vec3|vec4> tonemapFilmic(<vec3|vec4> x)

Check it on Github





#ifndef FNC_TONEMAPFILMIC
#define FNC_TONEMAPFILMIC
vec3 tonemapFilmic(vec3 v) {
    v = max(vec3(0.0), v - 0.004);
    v = (v * (6.2 * v + 0.5)) / (v * (6.2 * v + 1.7) + 0.06);
    return v;
}

vec4 tonemapFilmic(const vec4 x) { return vec4( tonemapFilmic(x.rgb), x.a ); }
#endif

Dependencies:

Use:

<float3|float4> tonemapFilmic(<float3|float4> x)

Check it on Github





#ifndef FNC_TONEMAPFILMIC
#define FNC_TONEMAPFILMIC
float3 tonemapFilmic(float3 color) {
    color = max(float3(0.0, 0.0, 0.0), color - 0.004);
    color = (color * (6.2 * color + 0.5)) / (color * (6.2 * color + 1.7) + 0.06);
    return color;
}

float4 tonemapFilmic(const float4 x) { return float4( tonemapFilmic(x.rgb), x.a ); }
#endif

License

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.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository