hdr format caching sidesteps reinitialization

we never actually turn hdr off. so drop a few assumptions about it starting in the disabled state
fix HDRPostFX::minLuminace
This commit is contained in:
AzaezelX 2025-12-17 18:22:26 -06:00
parent 9d4bfec4d1
commit d8618be499
5 changed files with 23 additions and 14 deletions

View file

@ -46,7 +46,7 @@ $PostFX::HDRPostFX::colorFilter = "1.0 1.0 1.0";
/// The minimum luninace value to allow when tone mapping /// The minimum luninace value to allow when tone mapping
/// the scene. Is particularly useful if your scene very /// the scene. Is particularly useful if your scene very
/// dark or has a black ambient color in places. /// dark or has a black ambient color in places.
$PostFX::HDRPostFX::minLuminace = 0.001; $PostFX::HDRPostFX::minLuminace = 0.5;
/// The rate of adaptation from the previous and new /// The rate of adaptation from the previous and new
/// average scene luminance. /// average scene luminance.
@ -241,7 +241,7 @@ singleton GFXStateBlockData( HDRStateBlock )
function HDRPostFX::setShaderConsts( %this ) function HDRPostFX::setShaderConsts( %this )
{ {
%this.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue ); %this.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue );
%minLuminace = $PostFX::HDRPostFX::minLuminace; %minLuminace = $PostFX::HDRPostFX::minLuminace;
if ( %minLuminace <= 0.0 ) if ( %minLuminace <= 0.0 )
@ -357,17 +357,25 @@ function HDRPostFX::onEnabled( %this )
// disable this postFx. // disable this postFx.
GammaPostFX.disable(); GammaPostFX.disable();
if (%format $= %this.previousFormat)
return true;
// Set the right global shader define for HDR. // Set the right global shader define for HDR.
if ( %format $= "GFXFormatR10G10B10A2" ) if ( %format $= "GFXFormatR10G10B10A2" )
{
addGlobalShaderMacro( "TORQUE_HDR_RGB10" ); addGlobalShaderMacro( "TORQUE_HDR_RGB10" );
removeGlobalShaderMacro( "TORQUE_HDR_RGB16" );
}
else if ( %format $= "GFXFormatR16G16B16A16F" ) else if ( %format $= "GFXFormatR16G16B16A16F" )
{
addGlobalShaderMacro( "TORQUE_HDR_RGB16" ); addGlobalShaderMacro( "TORQUE_HDR_RGB16" );
removeGlobalShaderMacro( "TORQUE_HDR_RGB10" );
}
echo( "HDR FORMAT: " @ %format ); echo( "HDR FORMAT: " @ %format );
// Change the format of the offscreen surface // Change the format of the offscreen surface
// to an HDR compatible format. // to an HDR compatible format.
%this.previousFormat = AL_FormatToken.format; %this.previousFormat = %format;
setReflectFormat( %format ); setReflectFormat( %format );
// Reset the light manager which will ensure the new // Reset the light manager which will ensure the new
@ -390,10 +398,7 @@ function HDRPostFX::onDisabled( %this )
// Restore the non-HDR offscreen surface format. // Restore the non-HDR offscreen surface format.
%format = %this.previousFormat; %format = %this.previousFormat;
AL_FormatToken.format = %format; AL_FormatToken.format = %format;
setReflectFormat( %format ); setReflectFormat( %format );
removeGlobalShaderMacro( "TORQUE_HDR_RGB10" );
removeGlobalShaderMacro( "TORQUE_HDR_RGB16" );
// Reset the light manager which will ensure the new // Reset the light manager which will ensure the new
// hdr encoding takes effect in all the shaders. // hdr encoding takes effect in all the shaders.
@ -565,9 +570,9 @@ function HDRPostFX::SetupBloomFX( %this )
singleton PostEffect( HDRPostFX ) singleton PostEffect( HDRPostFX )
{ {
enabled = false; enabled = true;
allowReflectPass = false; allowReflectPass = false;
previousFormat = AL_FormatToken.format;
// Resolve the HDR before we render any editor stuff // Resolve the HDR before we render any editor stuff
// and before we resolve the scene to the backbuffer. // and before we resolve the scene to the backbuffer.
renderTime = "PFXBeforeBin"; renderTime = "PFXBeforeBin";

View file

@ -6,7 +6,7 @@ $PostFX::HDRPostFX::saturationValue = 1;
$PostFX::HDRPostFX::colorFilter = "1.0 1.0 1.0"; $PostFX::HDRPostFX::colorFilter = "1.0 1.0 1.0";
$PostFX::HDRPostFX::minLuminace = "0.5"; $PostFX::HDRPostFX::minLuminace = "0.5";
$PostFX::HDRPostFX::whiteCutoff = 1; $PostFX::HDRPostFX::whiteCutoff = 1;
$PostFX::HDRPostFX::adaptRate = "0.134615391"; $PostFX::HDRPostFX::adaptRate = "0.85";
$PostFX::HDRPostFX::tonemapMode = "ACES"; $PostFX::HDRPostFX::tonemapMode = "ACES";
$PostFX::HDRPostFX::enableAutoExposure = "1"; $PostFX::HDRPostFX::enableAutoExposure = "1";
$PostFX::HDRPostFX::keyValue = 0.5; $PostFX::HDRPostFX::keyValue = 0.5;

View file

@ -71,4 +71,5 @@ function Core_Rendering::initClient(%this)
// we can hide any splash screen we have, and show the canvas. // we can hide any splash screen we have, and show the canvas.
// This keeps things looking nice, instead of having a blank window // This keeps things looking nice, instead of having a blank window
Canvas.showWindow(); Canvas.showWindow();
resetLightManager(); //make sure
} }

View file

@ -31,7 +31,7 @@ function initRenderManager()
// PostEffect copies the result to the backbuffer. // PostEffect copies the result to the backbuffer.
new RenderFormatToken(AL_FormatToken) new RenderFormatToken(AL_FormatToken)
{ {
enabled = "false"; enabled = true;
//When hdr is enabled this will be changed to the appropriate format //When hdr is enabled this will be changed to the appropriate format
format = "GFXFormatR16G16B16A16F"; format = "GFXFormatR16G16B16A16F";
@ -46,6 +46,9 @@ function initRenderManager()
// provided in $inTex // provided in $inTex
resolveEffect = "AL_FormatCopy"; resolveEffect = "AL_FormatCopy";
}; };
addGlobalShaderMacro( "TORQUE_HDR_RGB16" );
setReflectFormat( AL_FormatToken.format );
DiffuseRenderPassManager.addManager( new RenderPassStateBin() { renderOrder = 0.001; stateToken = AL_FormatToken; } ); DiffuseRenderPassManager.addManager( new RenderPassStateBin() { renderOrder = 0.001; stateToken = AL_FormatToken; } );
DiffuseRenderPassManager.addManager( new RenderProbeMgr(ProbeBin) { bintype = "Probes"; renderOrder = 0.019; processAddOrder = 0.019; } ); DiffuseRenderPassManager.addManager( new RenderProbeMgr(ProbeBin) { bintype = "Probes"; renderOrder = 0.019; processAddOrder = 0.019; } );
@ -119,7 +122,7 @@ singleton PostEffect( AL_FormatCopy )
{ {
// This PostEffect is used by 'AL_FormatToken' directly. It is never added to // This PostEffect is used by 'AL_FormatToken' directly. It is never added to
// the PostEffectManager. Do not call enable() on it. // the PostEffectManager. Do not call enable() on it.
enabled = false; enabled = true;
allowReflectPass = true; allowReflectPass = true;
shader = PFX_PassthruShader; shader = PFX_PassthruShader;

View file

@ -4,7 +4,7 @@ $PostFX::HDRPostFX::whitePoint = 1;
$PostFX::HDRPostFX::logContrast = 1; $PostFX::HDRPostFX::logContrast = 1;
$PostFX::HDRPostFX::saturationValue = 1; $PostFX::HDRPostFX::saturationValue = 1;
$PostFX::HDRPostFX::colorFilter = "1.0 1.0 1.0"; $PostFX::HDRPostFX::colorFilter = "1.0 1.0 1.0";
$PostFX::HDRPostFX::minLuminace = 0.001; $PostFX::HDRPostFX::minLuminace = 0.5;
$PostFX::HDRPostFX::whiteCutoff = 1; $PostFX::HDRPostFX::whiteCutoff = 1;
$PostFX::HDRPostFX::adaptRate = "0.85"; $PostFX::HDRPostFX::adaptRate = "0.85";
$PostFX::HDRPostFX::tonemapMode = "ACES"; $PostFX::HDRPostFX::tonemapMode = "ACES";