Advertisement Jump to content
Sign in to follow this  
Alundra

Tonemapping Correct ?

This topic is 1804 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,

using a tonemapping is good to have a good range from all paper I read.

So, I make a try on it and used the paper of hable using this shader code :

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

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

float3 HableTonemap( 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
{
  // Get the diffuse data.
  float3 DiffuseData = DiffuseMap.Sample( LinearSampler, Input.TexCoord ).rgb;
  
  // Compute the current color.
  float ExposureBias = 2.0f;
  float3 CurrentColor = HableTonemap( ExposureBias * DiffuseData );
  
  // Compute the white scale.
  float3 WhitePoint = float3( 11.2f, 11.2f, 11.2f );
  float3 WhiteScale = 1.0f / HableTonemap( WhitePoint );
  
  // Return the final color.
  return float4( CurrentColor * WhiteScale, 1.0f );
}

I got this result :

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

On the left you have tonemapped, on the right the original render target RGBA32F.

It looks a lot more dark than the value stored in render target.

Is the result correct ?

Thanks

Edited by Alundra

Share this post


Link to post
Share on other sites
Advertisement

Are you doing gamma correction at some point? Otherwise, your shader code looks correct, but it might be a good idea to make these values (exposure, white point, A/B/C/D/E/F) tweakable so you can adjust them at runtime and see the results. All of those values could potentially change, depending on the scene. In a darker scene, you might want a higher exposure and a lower white point, for example. If you feel like the dark colors are looking desaturated, then you might want to increase the toe strength (D), and so on. 

Edited by CDProp

Share this post


Link to post
Share on other sites

I only render the scene in a render target RGBA32F (I will change to RGBA16F for bandwidth) and then send the target to a fullscreen quad using the shader I showed in the first post.

I read on the paper of Hable that a pow is needed on texture sampling and final output when render the scene, is it really needed ?

I read on the paper that a hardware sRGB can be used to avoid to do pow in the shader, is it better to use it ?

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!