Uncharted 2 Tonemapping


Tweet glsl shaders code-archives
(Posted 2 years ago) RonTek

Uncharted 2 Tonemap Filter for OpenB3D

Copy and save the file as tonemap.frag.glsl and load as post process camera effect in OpenB3D, use with default.vert.glsl. See other post process effects like blur and toon for reference.

tonemap filter on left side
OpenB3D Uncharted Tonemap

// Uncharted 2 Tonemap
// OpenB3D version by RonTek
// www.blitzcoder.org

uniform sampler2D texture0;

uniform float TonemapExposureBias = 1.0;
uniform float TonemapMaxWhite = 1.0;

const float A = 0.22;
const float B = 0.30;
const float C = 0.10;
const float D = 0.20;
const float E = 0.01;
const float F = 0.30;

vec3 Uncharted2Tonemap(vec3 x)
{
   return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
}

void main()
{
    vec3 color = Uncharted2Tonemap(max(texture2D(texture0, gl_TexCoord[0].st).rgb * TonemapExposureBias, 0.0)) / Uncharted2Tonemap(vec3(TonemapMaxWhite, TonemapMaxWhite, TonemapMaxWhite));
    gl_FragColor = vec4(color, 1.0);   
}
(Posted 2 years ago) markcwm commented:

Hi RonTek,

thanks for sharing this, I've added it to the Openb3d shaders examples on Git.

I'm wondering, does this increase contrast between light and dark colors, or is it a kind of bloom?

(Posted 2 years ago) RonTek commented:

sure thing Mark and that's awesome. Actually, this preserves somes details while having the darker colors saturated as you can see another example of this effect below. Notice how this effect lightens up darker places or spots.

Uncharted 2 Tonemapping

cheers.

Reply To Topic (minimum 10 characters)

Please log in to reply