Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Filmic ToneMapping is DARK


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Alundra   Members   -  Reputation: 930

Like
0Likes
Like

Posted 30 July 2014 - 09:38 AM

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



Sponsor:

#2 TiagoCosta   Crossbones+   -  Reputation: 2462

Like
0Likes
Like

Posted 30 July 2014 - 10:12 AM

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, 30 July 2014 - 10:12 AM.


#3 haegarr   Crossbones+   -  Reputation: 4602

Like
0Likes
Like

Posted 30 July 2014 - 10:41 AM

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.



#4 Alundra   Members   -  Reputation: 930

Like
0Likes
Like

Posted 30 July 2014 - 01:57 PM

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, 30 July 2014 - 02:23 PM.


#5 haegarr   Crossbones+   -  Reputation: 4602

Like
0Likes
Like

Posted 31 July 2014 - 09:44 AM


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.



#6 Ashaman73   Crossbones+   -  Reputation: 8001

Like
1Likes
Like

Posted 01 August 2014 - 12:13 AM


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.



#7 Alundra   Members   -  Reputation: 930

Like
0Likes
Like

Posted 02 August 2014 - 07:48 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS