• Advertisement
Sign in to follow this  

Filmic ToneMapping is DARK

This topic is 1267 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

I have a render target RGBA16F where I render the scene with lighting.

When the rendering of the scene is finished I send this texture in the Filmic ToneMapping pixel shader.

The problem is I got a very dark image, you can see the image "With" on the right and "Without" on the left:

http://uppix.com/f-Screenshot_2014_53d910de0017208f.png

Here the pixel shader code :

struct PS_INPUT
{
  float4 Position : SV_POSITION;
  float2 TexCoord : TEXCOORD0;
};

Texture2D< float4 > DiffuseMap : register( t0 );
SamplerState LinearSampler : register( s0 );

float3 FilmicTonemap( in float3 x )
{
  float A = 0.22f; // Shoulder Strength.
  float B = 0.30f; // Linear Strength.
  float C = 0.10f; // Linear Angle.
  float D = 0.20f; // Toe Strength.
  float E = 0.01f; // Toe Numerator.
  float F = 0.30f; // Toe Denominator.
  return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F)) - E/F;
}

float4 main( in PS_INPUT Input ) : SV_TARGET
{
  if(Input.TexCoord.x > 0.5f)
  {
    // Get the diffuse data.
    float3 DiffuseData = DiffuseMap.Sample( LinearSampler, Input.TexCoord ).rgb;
    
    // Compute the current color and the white scale.
    float3 CurrentColor = FilmicTonemap( DiffuseData );
    float3 WhiteScale = FilmicTonemap( float3( 11.2f, 11.2f, 11.2f ) );
    
    // Return the final color.
    return float4( CurrentColor / WhiteScale, 1.0f );
  }
  else
  {
    return DiffuseMap.Sample( LinearSampler, Input.TexCoord );
  }
}

Thanks for the help

Share this post


Link to post
Share on other sites
Advertisement

Have you played around the with the constants A, B, C, D, E, F and the 11.2 used to calculate WhiteScale? You probably have to tweak them to achieve the look you want... 

Edited by TiagoCosta

Share this post


Link to post
Share on other sites

11.2 is the level in the input image that should be mapped to 1.0 in the output image (i.e. the "white point"). If the input image's mean luminance lies noticeably below this 11.2, then the output image will look overall darker.

Share this post


Link to post
Share on other sites

Good catch, using this value :

float3 CurrentColor = FilmicTonemap( DiffuseData );
float3 WhiteScale = FilmicTonemap( float3( 1.0f, 1.0f, 1.0f ) );

I have this result (Left = orifinal HDR, Right = Filmic Tonemapping) :

http://uppix.com/f-Screenshot_2014_53d94e230017212f.png

Is it better to set one fixed value or have one value by scene ?

Edited by Alundra

Share this post


Link to post
Share on other sites


Is it better to set one fixed value or have one value by scene ?

I'm not familiar with HDR, but AFAIS the white point depends on the current snapshot of the scene. I mean, it would not make sense in general to have a constant white point, because it would result in typical LDR images since you would need to foresee a value for all circumstances. Someone with experience in HDR may confirm or contradict this...

 

However, the demo scene you are showing us with the screenshots does not look like a typical HDR scene. The brightness of highlights seems relative low, and the fact that 1.0 can be used as white point supports this. In such a scene a constant white point may perhaps be used.

Share this post


Link to post
Share on other sites


Is it better to set one fixed value or have one value by scene ?

When using the common reinhard tonemapping, you use the scene brightness as variation for the exposure level of the tonemapping operator. You can use something similar for the filimic tonemapping, eg by adding variation to the white scale (or modify other parameters).

 

To determine the brightness of your scene, render it first (HDR), then sample the image down (eg from 1024x1024=>256=>64=>16=>4=>1) while caluclating the average birghtness/light intensity of the HDR image. Then use the pixel value of the last rendered 1x1 pixel as input (modify by a scalar) for the white space. Utilising the GPU hardware filtering capacities and taking multiple samples per step will result in just a few rendering steps.

 

Advanced:

Instead of the using only the light intensity of the current scene, take the average of the last X frames.

Share this post


Link to post
Share on other sites

Unreal Engine has a param for camera component named "Dynamic Range" :

Dynamic Range -> This controls the amount of dynamic range before the tone-mapping curve starts to clip. A setting of 1 would be no dynamic range. Eye adaption happens before the input to Film post so dynamic range is the range after adaption.

So, we end to the answer that it's needed to allow the user to set it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement