Understanding HPD Tonemapping?

More
4 years 9 months ago #1 by MajinCry
Understanding HPD Tonemapping? was created by MajinCry
Howdy lads.

With Boris having released an ENB that allows us to add shaders to Fallout 4, I went ahead and converted a couple basic effects to it as a learning experience; Vibrance, Levels and Nostalgia seem to be working fine, tho' Nostalgia might be borked? Ya can check me progress over here. enbseries.enbdev.com/forum/viewtopic.php...=4573&p=64923#p64923

Anyhow, I was taking a gander at the HPD tonemapping shader. It just makes my brain hurt.
float3 HaarmPeterDuikerFilmicToneMapping(in float3 x)
{
    	x = max( (float3)0.0f, x - 0.004f );
    	return pow( abs( ( x * ( 6.2f * x + 0.5f ) ) / ( x * ( 6.2f * x + 1.7f ) + 0.06 ) ), 2.2f );
}

Now, with the SweetFX shaders, it was sufficient to just remove the first line; ENB's equivalent of ColorInput is "color", and can be accessed anywhere in the pixel shader. This is the first time I've seen
(in float3 x)
, and I've no clue what that does, nor how to port it if it's necessary.

And the rest of the shader is just gibberish to me. Could a rather benevolent fellow try and explain to me what the math is doing?

Please Log in or Create an account to join the conversation.

More
4 years 9 months ago #2 by MajinCry
Replied by MajinCry on topic Understanding HPD Tonemapping?
Been getting a bit of help over on the ENB forums, so I'd like a bit of verification.

In the shader file, there is this bit of code:
#if USE_HPD
	color.xyz = HaarmPeterDuikerFilmicToneMapping(color.xyz);
#endif

Now, the actual shader code calls:
float3 HaarmPeterDuikerFilmicToneMapping(in float3 x)

Does this mean that x = color.xyz?


Even Boris Vorontsov was stumped by that x = max equation. His guess was that it was intended to clip low values. Is that the case or nah?

Please Log in or Create an account to join the conversation.

More
4 years 9 months ago #3 by crosire
Replied by crosire on topic Understanding HPD Tonemapping?

MajinCry wrote: Does this mean that x = color.xyz?

Pretty much.
The following user(s) said Thank You: MajinCry

Please Log in or Create an account to join the conversation.

More
4 years 9 months ago #4 by MajinCry
Replied by MajinCry on topic Understanding HPD Tonemapping?
Managed to get the shader to compile, but had to change a few things. Main issue was that the x = max() function threw an error. Here's the port:
if(bFiftyTiftyHPDTonemapping)
{   
   float3 xColor = color.xyz;
   xColor = max(xColor, HPDTonemappingClipping);
   float3 HPDcolor = pow(abs((xColor * (6.2f * xColor + 0.5f )) / (xColor * (6.2f * xColor + 1.7f) + 0.06 )), HPDTonemappingExposure);
   
   if(bFiftyTiftyHPDTonemappingMethod)
   {
      color.xyz = lerp(pow(HPDcolor.xyz, 1.0/2.2), color.xyz, HPDTonemappingLerp);
   }
   else
   {
      color.xyz = lerp(HPDcolor.xyz, color.xyz, HPDTonemappingLerp);
   }
}

To clarify, was the x = max() function for clipping?

Please Log in or Create an account to join the conversation.