Kaynağa Gözat

Merge pull request #854 from Azaezel/alpha401/pfxDefaultAlt

postfx defaults (and HDR aug)
Brian Roberts 3 yıl önce
ebeveyn
işleme
a24889d44d

+ 20 - 8
Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.tscript

@@ -31,6 +31,9 @@ $PostFX::HDRPostFX::enableToneMapping = 0.5;
 ///
 $PostFX::HDRPostFX::keyValue = 0.18;
 
+
+$PostFX::HDRPostFX::exposureValue = 1.0;
+
 /// The minimum luninace value to allow when tone mapping 
 /// the scene.  Is particularly useful if your scene very 
 /// dark or has a black ambient color in places.
@@ -59,13 +62,13 @@ $PostFX::HDRPostFX::enableBloom = 1.0;
 
 /// The threshold luminace value for pixels which are
 /// considered "bright" and need to be bloomed.
-$PostFX::HDRPostFX::brightPassThreshold = 1.0;
+$PostFX::HDRPostFX::brightPassThreshold = 0.2;
 
 /// These are used in the gaussian blur of the
 /// bright pass for the bloom effect.
-$PostFX::HDRPostFX::gaussMultiplier = 0.3;
-$PostFX::HDRPostFX::gaussMean = 0.0;
-$PostFX::HDRPostFX::gaussStdDev = 0.8;
+$PostFX::HDRPostFX::gaussMultiplier = 0.145;
+$PostFX::HDRPostFX::gaussMean = 0;
+$PostFX::HDRPostFX::gaussStdDev = 0.5;
 
 // The tonemapping algo to use
 $PostFX::HDRPostFX::tonemapMode = "Filmic";
@@ -222,7 +225,8 @@ singleton GFXStateBlockData( HDRStateBlock )
 function HDRPostFX::setShaderConsts( %this )
 {
    %this.setShaderConst( "$brightPassThreshold", $PostFX::HDRPostFX::brightPassThreshold );
-   %this.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue );   
+   %this.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue );  
+   %this.setShaderConst( "$ExposureValue", $PostFX::HDRPostFX::exposureValue );    
          
    %bloomH = %this-->bloomH;
    %bloomH.setShaderConst( "$gaussMultiplier", $PostFX::HDRPostFX::gaussMultiplier );
@@ -248,6 +252,7 @@ function HDRPostFX::setShaderConsts( %this )
    %combinePass = %this-->combinePass;   
    %combinePass.setShaderConst( "$g_fEnableToneMapping", $PostFX::HDRPostFX::enableToneMapping );
    %combinePass.setShaderConst( "$g_fMiddleGray", $PostFX::HDRPostFX::keyValue );
+   %combinePass.setShaderConst( "$ExposureValue", $PostFX::HDRPostFX::exposureValue );
    %combinePass.setShaderConst( "$g_fBloomScale", $PostFX::HDRPostFX::enableBloom );      
    %combinePass.setShaderConst( "$g_fEnableBlueShift", $PostFX::HDRPostFX::enableBlueShift );   
    %combinePass.setShaderConst( "$g_fBlueShiftColor", $PostFX::HDRPostFX::blueShiftColor );   
@@ -255,10 +260,15 @@ function HDRPostFX::setShaderConsts( %this )
    %combinePass.setShaderConst( "$g_fEnableAutoExposure", $PostFX::HDRPostFX::enableAutoExposure );
    
    %tonemapMode = 1;
-   if($PostFX::HDRPostFX::tonemapMode $= "Filmic")
+   if($PostFX::HDRPostFX::tonemapMode $= "ACES")
       %tonemapMode = 1;
-   else if($PostFX::HDRPostFX::tonemapMode $= "ACES")
+   else if($PostFX::HDRPostFX::tonemapMode $= "Uncharted 2")
       %tonemapMode = 2;
+   else if($PostFX::HDRPostFX::tonemapMode $= "Filmic")
+      %tonemapMode = 3;
+ else if($PostFX::HDRPostFX::tonemapMode $= "Reinhard")
+      %tonemapMode = 4;
+ 
       
    %combinePass.setShaderConst( "$g_fTonemapMode", %tonemapMode );
    
@@ -356,7 +366,8 @@ function HDRPostFX::populatePostFXSettings(%this)
    PostEffectEditorInspector.endGroup();
    
    PostEffectEditorInspector.startGroup("HDR - Tonemapping");
-   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::tonemapMode", "Tonemapping Mode", "list", "", $PostFX::HDRPostFX::tonemapMode, "Filmic,ACES");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::tonemapMode", "Tonemapping Mode", "list", "", $PostFX::HDRPostFX::tonemapMode, "ACES,Uncharted 2,Filmic,Reinhard");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::exposureValue", "Exposure", "float", "", $PostFX::HDRPostFX::exposureValue, " 1");
    PostEffectEditorInspector.endGroup();
    
    PostEffectEditorInspector.startGroup("HDR - Bloom");
@@ -395,6 +406,7 @@ function HDRPostFX::applyFromPreset(%this)
 function HDRPostFX::savePresetSettings(%this)
 {
    PostFXManager::savePresetSetting("$PostFX::HDRPostFX::Enabled");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::exposureValue");
    PostFXManager::savePresetSetting("$PostFX::HDRPostFX::minLuminace");
    PostFXManager::savePresetSetting("$PostFX::HDRPostFX::whiteCutoff");
    PostFXManager::savePresetSetting("$PostFX::HDRPostFX::adaptRate");

+ 39 - 8
Templates/BaseGame/game/core/postFX/scripts/HDR/finalPassCombineP.hlsl

@@ -44,8 +44,24 @@ uniform float g_fBloomScale;
 uniform float g_fOneOverGamma;
 uniform float Brightness;
 uniform float Contrast;
+uniform float ExposureValue;
+   
 
-// uncharted 2 tonemapper see: http://filmicgames.com/archives/75
+float3 Reinhard(float3 x) 
+{
+    x *= 2.0;    
+    return x / (1.0 + x);
+} 
+ 
+ 
+float3 Filmic(float3 x)
+{   
+    x *= 0.4;   
+    x = max(0,x-0.004);
+    return (x*(6.2*x+.5))/(x*(6.2*x+1.7)+0.06);
+}   
+   
+// Uncharted 2 tonemapper see: http://filmicgames.com/archives/75
 float3 Uncharted2Tonemap(const float3 x)
 {
    const float A = 0.15;
@@ -71,18 +87,31 @@ float3 tonemap(float3 color)
 {
    if(g_fTonemapMode == 1.0)
    {
+      color = ACESFilm(color);
+   }
+    
+   if(g_fTonemapMode == 2.0)
+   { 
+        
+      color *= 2.5; // compensate exposure to final image  
       const float W = 11.2;
       float ExposureBias = 2.0f;
-      //float ExposureAdjust = 1.5f;
-      //c *= ExposureAdjust;
+      
       color = Uncharted2Tonemap(ExposureBias*color);
       color = color * (1.0f / Uncharted2Tonemap(W));
+   } 
+    
+   if (g_fTonemapMode == 3.0)
+   {  
+       
+      color = Filmic(color);
+   } 
+       
+   else if (g_fTonemapMode == 4.0)
+   {   
+      color = Reinhard(color);
    }
-   else if(g_fTonemapMode == 2.0)
-   {
-      color = ACESFilm(color);
-   }
-
+    
    return color;
 }
 
@@ -112,6 +141,8 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
       bloom.rgb = lerp( bloom.rgb, rodColor, coef );
    }
 
+   sample.rgb *= ExposureValue;
+   
    // Add the bloom effect.
    sample += saturate(g_fBloomScale * bloom);
 

+ 17 - 10
Templates/BaseGame/game/core/postFX/scripts/default.postfxpreset.tscript

@@ -1,14 +1,21 @@
 $PostFX::HDRPostFX::Enabled = 1;
-$PostFX::HDRPostFX::minLuminace = 0.001;
-$PostFX::HDRPostFX::whiteCutoff = 1;
-$PostFX::HDRPostFX::adaptRate = 2;
+$PostFX::HDRPostFX::ExposureValue = "1";
+$PostFX::HDRPostFX::minLuminace = "0.001";
+$PostFX::HDRPostFX::whiteCutoff = "1.0";
+$PostFX::HDRPostFX::adaptRate = "1";
 $PostFX::HDRPostFX::tonemapMode = "ACES";
-$PostFX::HDRPostFX::enableBloom = 1;
-$PostFX::HDRPostFX::brightPassThreshold = 1;
-$PostFX::HDRPostFX::gaussMultiplier = 0.3;
-$PostFX::HDRPostFX::gaussMean = 0;
-$PostFX::HDRPostFX::gaussStdDev = 0.8;
+$PostFX::HDRPostFX::enableBloom = "1";
+$PostFX::HDRPostFX::brightPassThreshold = "0.2";
+$PostFX::HDRPostFX::gaussMultiplier = "0.145";
+$PostFX::HDRPostFX::gaussMean = "0";
+$PostFX::HDRPostFX::gaussStdDev = "0.5";
 $PostFX::HDRPostFX::enableAutoExposure = "0";
-$PostFX::HDRPostFX::keyValue = 0.18;
-$PostFX::HDRPostFX::enableBlueShift = 0;
+$PostFX::HDRPostFX::keyValue = "0.18";
+$PostFX::HDRPostFX::enableBlueShift = "0";
 $PostFX::HDRPostFX::blueShiftColor = "1.05 0.97 1.27";
+$PostFX::SharpenPostFX::Enabled = "1";
+$PostFX::SharpenPostFX::sharpness = "0.15";
+$PostFX::VignettePostFX::Enabled = "1";
+$PostFX::VignettePostFX::VMin = "0.25";
+$PostFX::VignettePostFX::VMax = "0.9";
+$PostFX::VignettePostFX::Color = "0 0 0 1";