Welcome, Guest.
Username: Password: Remember me

TOPIC: Understanding HPD Tonemapping?

Understanding HPD Tonemapping? 11 months 4 weeks ago #1

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?
The administrator has disabled public write access.

Understanding HPD Tonemapping? 11 months 4 weeks ago #2

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?
The administrator has disabled public write access.

Understanding HPD Tonemapping? 11 months 4 weeks ago #3

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2437
  • Thank you received: 1384
MajinCry wrote:
Does this mean that x = color.xyz?
Pretty much.
Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: MajinCry

Understanding HPD Tonemapping? 11 months 4 weeks ago #4

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?
The administrator has disabled public write access.