LYGIA Shader Library

aces (lygia/color/tonemap/aces)

ACES Filmic Tone Mapping Curve. https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/

Dependencies:

Use:

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

Check it on Github



#ifndef FNC_TONEMAPACES
#define FNC_TONEMAPACES
vec3 tonemapACES(vec3 v) {
    const float a = 2.51;
    const float b = 0.03;
    const float c = 2.43;
    const float d = 0.59;
    const float e = 0.14;
    return saturate((v*(a*v+b))/(v*(c*v+d)+e));
}

vec4 tonemapACES(in vec4 v) {
    return vec4(tonemapACES(v.rgb), v.a);
}
#endif

Use:

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

Check it on Github


#ifndef FNC_TONEMAPACES
#define FNC_TONEMAPACES
float3 tonemapACES(float3 x) {
    const float a = 2.51;
    const float b = 0.03;
    const float c = 2.43;
    const float d = 0.59;
    const float e = 0.14;
    return saturate((x*(a*x+b))/(x*(c*x+d)+e));
}

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

Use:

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

Check it on Github


const aces_a = 2.51;
const aces_b = 0.03;
const aces_c = 2.43;
const aces_d = 0.59;
const aces_e = 0.14;

fn tonemapACES3(v : vec3f) -> vec3f {
    return saturate((v * (aces_a * v + aces_b)) / (v * (aces_c * v + aces_d) + aces_e));
}

fn tonemapACES4(v : vec4f) -> vec4f {
    return vec4(tonemapACES3(v.rgb), v.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.

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