Prechádzať zdrojové kódy

Merge Bloom post effect with HDR post effect

Samuel Skiff 3 rokov pred
rodič
commit
c8e950ccbc
20 zmenil súbory, kde vykonal 288 pridanie a 1116 odobranie
  1. 0 326
      Templates/BaseGame/game/core/postFX/scripts/Bloom/BloomPostFX.tscript
  2. 233 106
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.tscript
  3. 0 72
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurHP.glsl
  4. 0 111
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurHP.hlsl
  5. 0 71
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurVP.glsl
  6. 0 108
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurVP.hlsl
  7. 25 16
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomInitSample.glsl
  8. 24 21
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomInitSample.hlsl
  9. 1 1
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomStrengthP.glsl
  10. 1 1
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomStrengthP.hlsl
  11. 0 0
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomThresholdP.glsl
  12. 0 0
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomThresholdP.hlsl
  13. 0 0
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/downSampleP.glsl
  14. 0 0
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/downSampleP.hlsl
  15. 0 141
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/downScale4x4V.glsl
  16. 0 138
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/downScale4x4V.hlsl
  17. 0 0
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/upSampleP.glsl
  18. 0 0
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/upSampleP.hlsl
  19. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_finalPass.glsl
  20. 2 2
      Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_finalPass.hlsl

+ 0 - 326
Templates/BaseGame/game/core/postFX/scripts/Bloom/BloomPostFX.tscript

@@ -1,326 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2012 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-// Inspired by bloom described in paper listed here:
-// http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
-
-$PostFX::BloomPostFX::threshold = 0.75;
-$PostFX::BloomPostFX::intensity = 1.0;
-$PostFX::BloomPostFX::radius = 4.0;
-
-$PostFX::BloomPostFX::dirtEnabled = true;
-$PostFX::BloomPostFX::dirtScale = 2048.0;
-$PostFX::BloomPostFX::dirtIntensity = 2.0;
-$PostFX::BloomPostFX::dirtEdgeMinDist = 0.125;
-$PostFX::BloomPostFX::dirtEdgeMaxDist = 0.75;
-$PostFX::BloomPostFX::dirtEdgeMinVal = 0.05;
-$PostFX::BloomPostFX::dirtImage = "core/postFX/images/lensDirt.png";
-
-singleton ShaderData( Bloom_ThresholdShader )
-{
-   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile  = "./bloomThresholdP.hlsl";
-   OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile = "./gl/bloomThresholdP.glsl";
-   
-   samplerNames[0] = "$inputTex";
-   
-   pixVersion = 3.0;
-};
-
-singleton ShaderData( Bloom_DownSampleShader )
-{
-   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile  = "./downSampleP.hlsl";
-   OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile = "./gl/downSampleP.glsl";
-   
-   samplerNames[0] = "$inputTex";
-   
-   pixVersion = 3.0;
-};
-
-singleton ShaderData( Bloom_UpSampleShader )
-{
-   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile  = "./upSampleP.hlsl";
-   OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile = "./gl/upSampleP.glsl";
-   
-   samplerNames[0] = "$nxtTex";
-   samplerNames[1] = "$mipTex";
-   
-   pixVersion = 3.0;
-};
-
-singleton ShaderData( Bloom_StrengthShader )
-{
-   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile  = "./bloomStrengthP.hlsl";
-   OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile = "./gl/bloomStrengthP.glsl";
-   
-   samplerNames[0] = "$inputTex";
-   samplerNames[1] = "$dirtTex";
-   
-   pixVersion = 3.0;
-};
-
-singleton GFXStateBlockData( Bloom_SampleStateBlock : PFX_DefaultStateBlock )
-{
-   samplersDefined = true;
-   samplerStates[0] = SamplerClampLinear;
-   samplerStates[1] = SamplerClampLinear;
-};
-
-singleton GFXStateBlockData( Bloom_Add_SampleStateBlock : PFX_DefaultStateBlock )
-{ 
-   // Do a one to one blend.
-   blendDefined = true;
-   blendEnable = true;
-   blendSrc = GFXBlendOne;
-   blendDest = GFXBlendOne;
-
-   samplersDefined = true;
-   samplerStates[0] = SamplerClampLinear;
-   samplerStates[1] = SamplerWrapLinear;
-};
-
-function BloomPostFX::setShaderConsts( %this )
-{
-   %this.setShaderConst("$threshold", $PostFX::BloomPostFX::threshold);
-   
-   %blur = %this->bloomBlur;
-   for (%idx = 0; %idx < %this.mipsCount; %idx++)
-   {
-     %mip = %blur.getObject(%this.mipsCount + %idx);
-     %mip.setShaderConst("$filterRadius", $PostFX::BloomPostFX::radius);
-   }
-   
-   %final = %this->bloomFinal;
-   %final.setShaderConst("$strength", $PostFX::BloomPostFX::intensity);
-   
-   %dirtScale = $PostFX::BloomPostFX::dirtScale;
-   %dirtIntensity = $PostFX::BloomPostFX::dirtIntensity;
-   %final.setShaderConst("$dirtParams", %dirtScale SPC %dirtScale SPC %dirtIntensity);
-   
-   %edgeMin = $PostFX::BloomPostFX::dirtEdgeMinDist;
-   %edgeMax = $PostFX::BloomPostFX::dirtEdgeMaxDist;
-   %edgeVal = $PostFX::BloomPostFX::dirtEdgeMinVal;
-   %final.setShaderConst("$edgeParams", %edgeMin SPC %edgeMax SPC %edgeVal);
-}
-
-function BloomPostFX::preProcess( %this )
-{
-  if (%this.dirtEnabled != $PostFX::BloomPostFX::dirtEnabled)
-  {
-     %this.dirtEnabled = $PostFX::BloomPostFX::dirtEnabled;
-     
-     %final = %this->bloomFinal;
-     if (%this.dirtEnabled)
-     {
-       %final.setShaderMacro("USE_DIRT");
-     } else {
-       %final.removeShaderMacro("USE_DIRT");
-     }
-  }
-  
-  if(%this.dirtImage !$= $PostFX::BloomPostFX::dirtImage)
-  {
-    if ($PostFX::BloomPostFX::dirtImage $= "")
-      $PostFX::BloomPostFX::dirtImage = "core/postFX/images/lensDirt.png";
-    
-    %this.dirtImage = $PostFX::BloomPostFX::dirtImage;
-    
-    %final = %this->bloomFinal;
-    %final.setTexture(1, %this.dirtImage);
-  }
-}
-
-// This function sets up s sort of "mip-chain" for the bloom effect
-// Not really "optimal" but it works well enough
-function BloomPostFX::SetupBlurFX( %this )
-{
-   %blurFX = new PostEffect()
-   {
-     internalName = "bloomBlur";
-     allowReflectPass = false;
-     shader = Bloom_DownSampleShader;
-     stateBlock = Bloom_SampleStateBlock;
-     texture[0] = "#threshold";
-     target = "#bloom_0";
-     targetScale = "0.5 0.5";
-     targetFormat = %this.mipTexFormat;
-   };
-  
-   %textureName = "#bloom_0";
-   for (%idx = 0; %idx < %this.mipsCount; %idx++)
-   {
-     %mipName = "bloom_" @ (%idx + 1);
-     %mipFX = new PostEffect()
-     { 
-       internalName = %mipName;
-       allowReflectPass = false;
-       shader = Bloom_DownSampleShader;
-       stateBlock = Bloom_SampleStateBlock;
-       texture[0] = %textureName;
-       target = "#" @ %mipName;
-       targetScale = "0.5 0.5";
-       targetFormat = %this.mipTexFormat;
-     };
-     
-     %blurFX.add(%mipFX);
-     %textureName = "#" @ %mipName;
-   }
-   
-   for (%idx = %this.mipsCount; %idx > 0; %idx--)
-   {
-     %nxt = "#bloom_" @ (%idx - 1);
-     %mipName = "upSample_" @ (%idx - 1);
-     
-     %mipFX = new PostEffect()
-     {
-       internalName = %mipName;
-       allowReflectPass = false;
-       shader = Bloom_UpSampleShader;
-       stateBlock = Bloom_SampleStateBlock;
-       texture[0] = %nxt;
-       texture[1] = %textureName;
-       target = "#" @ %mipName;
-       targetScale = "1.0 1.0";
-       targetFormat = %this.mipTexFormat;
-     };
-     
-     %blurFX.add(%mipFX);
-     %textureName = "#" @ %mipName;
-   }
-   
-   %this.add(%blurFX);
-}
-
-function BloomPostFX::onAdd(%this)
-{
-   %this.SetupBlurFX();
-   //Register the postFX with the manager
-   PostFXManager.registerPostEffect(%this);
-}
-
-function BloomPostFX::onEnabled( %this )
-{
-   return true;
-}
-
-function BloomPostFX::onDisabled( %this )
-{
-   return true;
-}
-
-//This is used to populate the PostFXEditor's settings so the post FX can be edited
-//This is automatically polled for any postFX that has been registered(in our onAdd) and the settings
-//are thus exposed for editing
-function BloomPostFX::populatePostFXSettings(%this)
-{
-   PostEffectEditorInspector.startGroup("BloomPostFX - General");
-   PostEffectEditorInspector.addCallbackField("$PostFX::BloomPostFX::Enabled", "Enabled", "bool", "", $PostFX::BloomPostFX::Enabled, "", "toggleBloomPostFX");
-   PostEffectEditorInspector.addField("$PostFX::BloomPostFX::threshold", "Threshold", "range", "", $PostFX::BloomPostFX::threshold, "0 1 10");
-   PostEffectEditorInspector.addField("$PostFX::BloomPostFX::intensity", "Intensity", "range", "", $PostFX::BloomPostFX::intensity, "0 10 10");
-   PostEffectEditorInspector.addField("$PostFX::BloomPostFX::radius", "Radius", "float", "", $PostFX::BloomPostFX::radius, "");
-   PostEffectEditorInspector.endGroup();
-   
-   PostEffectEditorInspector.startGroup("BloomPostFX - Lens Dirt");
-   PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEnabled", "Enable Dirt", "bool", "", $PostFX::BloomPostFX::dirtEnabled, "");
-   PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtScale", "Scale", "float", "", $PostFX::BloomPostFX::dirtScale, "");
-   PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtIntensity", "Intensity", "float", "", $PostFX::BloomPostFX::dirtIntensity, "");
-   PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEdgeMinDist", "Min Dist", "range", "", $PostFX::BloomPostFX::dirtEdgeMinDist, "0 1 10");
-   PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEdgeMaxDist", "Max Dist", "range", "", $PostFX::BloomPostFX::dirtEdgeMaxDist, "0 1 10");
-   PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtEdgeMinVal", "Min Value", "range", "", $PostFX::BloomPostFX::dirtEdgeMinVal, "0 1 10");
-   PostEffectEditorInspector.addField("$PostFX::BloomPostFX::dirtImage", "Dirt Image", "image", "", $PostFX::BloomPostFX::dirtImage, "");
-   PostEffectEditorInspector.endGroup();
-}
-
-//This is called back from our callbackField defined in populatePostFXSettings to
-//Allow us to easily toggle the postFX and have it respond immediately
-function PostEffectEditorInspector::toggleBloomPostFX(%this)
-{
-   if($PostFX::BloomPostFX::Enabled)
-      BloomPostFX.enable();
-   else
-      BloomPostFX.disable();
-}
-
-//This function pair(applyFromPreset and settingsApply) are done the way they are, with the separated variables
-//so that we can effectively store the 'settings' away from the live variables that the postFX's actually utilize
-//when rendering. This allows us to modify things but still leave room for reverting or temporarily applying them
-function BloomPostFX::applyFromPreset(%this)
-{
-   if($PostFX::BloomPostFX::Enabled)
-      %this.enable();
-   else
-      %this.disable();
-}
-
-function BloomPostFX::savePresetSettings(%this)
-{
-   PostFXManager::savePresetSetting("$PostFX::BloomPostFX::Enabled");
-   PostFXManager::savePresetSetting("$PostFX::BloomPostFX::threshold");
-   PostFXManager::savePresetSetting("$PostFX::BloomPostFX::intensity");
-   PostFXManager::savePresetSetting("$PostFX::BloomPostFX::radius");
-   
-   PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtEnabled");
-   PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtScale");
-   PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtIntensity");
-   PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtImage");
-   
-   PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtEdgeMinDist");
-   PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtEdgeMaxDist");
-   PostFXManager::savePresetSetting("$PostFX::BloomPostFX::dirtEdgeMinVal");
-}
-
-//Our actual postFX
-singleton PostEffect( BloomPostFX )
-{
-   mipsCount = 5;
-   mipTexFormat = "GFXFormatR16G16B16A16F";
-   
-   enabled = false;
-   allowReflectPass = false;
-   
-   renderTime = "PFXBeforeBin";
-   renderBin = "EditorBin";
-   renderPriority = 10000; 
-   
-   shader = Bloom_ThresholdShader;
-   stateBlock = Bloom_SampleStateBlock;
-   texture[0] = "$backBuffer";
-   target = "#threshold";
-   targetFormat = "GFXFormatR16G16B16A16F";
-   
-   new PostEffect()
-   {
-    internalName = "bloomFinal";
-    allowReflectPass = false;
-    shader = Bloom_StrengthShader;
-    stateBlock = Bloom_Add_SampleStateBlock;
-    texture[0] = "#upSample_0";
-    target = "$backBuffer";
-   };
-};

+ 233 - 106
Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.tscript

@@ -56,70 +56,85 @@ $PostFX::HDRPostFX::minLuminace = 0.001;
 /// average scene luminance. 
 $PostFX::HDRPostFX::adaptRate = 0.85;
 
-/// Blends between the scene and the bloomed scene.
-$PostFX::HDRPostFX::enableBloom = 1.0;
-
-/// The threshold luminace value for pixels which are
-/// considered "bright" and need to be bloomed.
-$PostFX::HDRPostFX::brightPassThreshold = 0.08;
-
-/// These are used in the gaussian blur of the
-/// bright pass for the bloom effect.
-$PostFX::HDRPostFX::gaussMultiplier = 0.4;
-$PostFX::HDRPostFX::gaussMean = 0;
-$PostFX::HDRPostFX::gaussStdDev = 0.5;
+// Inspired by bloom described in paper listed here:
+// http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
+
+$PostFX::HDRPostFX::enableBloom = true;
+$PostFX::HDRPostFX::threshold = 0.0;
+$PostFX::HDRPostFX::intensity = 1.0;
+$PostFX::HDRPostFX::radius = 4.0;
+
+$PostFX::HDRPostFX::enableDirt = true;
+$PostFX::HDRPostFX::dirtScale = 2048.0;
+$PostFX::HDRPostFX::dirtIntensity = 2.0;
+$PostFX::HDRPostFX::dirtEdgeMinDist = 0.125;
+$PostFX::HDRPostFX::dirtEdgeMaxDist = 0.75;
+$PostFX::HDRPostFX::dirtEdgeMinVal = 0.05;
+$PostFX::HDRPostFX::dirtImage = "core/postFX/images/lensDirt.png";
 
 // The tonemapping algo to use
 $PostFX::HDRPostFX::tonemapMode = "ACES";
 
 $PostFX::HDRPostFX::enableAutoExposure = true;
 
-
-singleton ShaderData( HDR_BrightPassShader )
+singleton ShaderData( HDR_BloomInitShader )
 {
-   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= "./HDR_utils/brightPassFilterP.hlsl";   
-   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = "./HDR_utils/brightPassFilterP.glsl";
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile  = "./HDR_Bloom/bloomInitSample.hlsl";
+   OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile = "./HDR_Bloom/bloomInitSample.glsl";
    
    samplerNames[0] = "$inputTex";
-   samplerNames[1] = "$luminanceTex";
    
    pixVersion = 3.0;
 };
 
-singleton ShaderData( HDR_DownScale4x4Shader )
+singleton ShaderData( HDR_BloomThresholdShader )
 {
-   DXVertexShaderFile 	= "./HDR_Bloom/downScale4x4V.hlsl";
-   DXPixelShaderFile 	= "./HDR_Bloom/downScale4x4P.hlsl";
-   OGLVertexShaderFile  = "./HDR_Bloom/downScale4x4V.glsl";
-   OGLPixelShaderFile   = "./HDR_Bloom/downScale4x4P.glsl";
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile  = "./HDR_Bloom/bloomThresholdP.hlsl";
+   OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile = "./HDR_Bloom/bloomThresholdP.glsl";
    
    samplerNames[0] = "$inputTex";
    
-   pixVersion = 2.0;
+   pixVersion = 3.0;
 };
 
-singleton ShaderData( HDR_BloomGaussBlurHShader )
+singleton ShaderData( HDR_BloomDownSampleShader )
 {
-   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= "./HDR_Bloom/bloomGaussBlurHP.hlsl";
-   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = "./HDR_Bloom/bloomGaussBlurHP.glsl";
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile  = "./HDR_Bloom/downSampleP.hlsl";
+   OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile = "./HDR_Bloom/downSampleP.glsl";
    
    samplerNames[0] = "$inputTex";
    
    pixVersion = 3.0;
 };
 
-singleton ShaderData( HDR_BloomGaussBlurVShader )
+singleton ShaderData( HDR_BloomUpSampleShader )
 {
-   DXVertexShaderFile 	= $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-   DXPixelShaderFile 	= "./HDR_Bloom/bloomGaussBlurVP.hlsl";
-   OGLVertexShaderFile  = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
-   OGLPixelShaderFile   = "./HDR_Bloom/bloomGaussBlurVP.glsl";
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile  = "./HDR_Bloom/upSampleP.hlsl";
+   OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile = "./HDR_Bloom/upSampleP.glsl";
+   
+   samplerNames[0] = "$nxtTex";
+   samplerNames[1] = "$mipTex";
+   
+   pixVersion = 3.0;
+};
+
+singleton ShaderData( HDR_BloomDirtShader )
+{
+   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+   DXPixelShaderFile  = "./HDR_Bloom/bloomStrengthP.hlsl";
+   OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+   OGLPixelShaderFile = "./HDR_Bloom/bloomStrengthP.glsl";
    
    samplerNames[0] = "$inputTex";
+   samplerNames[1] = "$dirtTex";
    
    pixVersion = 3.0;
 };
@@ -191,6 +206,13 @@ singleton GFXStateBlockData( HDR_DownSampleStateBlock : PFX_DefaultStateBlock )
    samplerStates[1] = SamplerClampLinear;
 };
 
+singleton GFXStateBlockData( HDR_LensDirtStateBlock : PFX_DefaultStateBlock )
+{ 
+   samplersDefined = true;
+   samplerStates[0] = SamplerClampLinear;
+   samplerStates[1] = SamplerWrapLinear;
+};
+
 singleton GFXStateBlockData( HDR_CombineStateBlock : PFX_DefaultStateBlock )
 {
    samplersDefined = true;
@@ -223,23 +245,7 @@ singleton GFXStateBlockData( HDRStateBlock )
 
 function HDRPostFX::setShaderConsts( %this )
 {
-   %this.setShaderConst( "$brightPassThreshold", $PostFX::HDRPostFX::brightPassThreshold );
-   %this.setShaderConst( "$g_fMiddleGray",   $PostFX::HDRPostFX::keyValue );  
-   %this.setShaderConst( "$exposureValue",   $PostFX::HDRPostFX::exposureValue );
-   %this.setShaderConst( "$whitePoint",      $PostFX::HDRPostFX::whitePoint ); 
-   %this.setShaderConst( "$logContrast",     $PostFX::HDRPostFX::logContrast );
-   %this.setShaderConst( "$saturationValue",     $PostFX::HDRPostFX::saturationValue );
-   
-         
-   %bloomH = %this-->bloomH;
-   %bloomH.setShaderConst( "$gaussMultiplier", $PostFX::HDRPostFX::gaussMultiplier );
-   %bloomH.setShaderConst( "$gaussMean", $PostFX::HDRPostFX::gaussMean );
-   %bloomH.setShaderConst( "$gaussStdDev", $PostFX::HDRPostFX::gaussStdDev );   
-
-   %bloomV = %this-->bloomV;
-   %bloomV.setShaderConst( "$gaussMultiplier", $PostFX::HDRPostFX::gaussMultiplier );
-   %bloomV.setShaderConst( "$gaussMean", $PostFX::HDRPostFX::gaussMean );
-   %bloomV.setShaderConst( "$gaussStdDev", $PostFX::HDRPostFX::gaussStdDev );   
+   %this.setShaderConst( "$g_fMiddleGray",   $PostFX::HDRPostFX::keyValue );
 
    %minLuminace = $PostFX::HDRPostFX::minLuminace;
    if ( %minLuminace <= 0.0 )
@@ -262,8 +268,7 @@ function HDRPostFX::setShaderConsts( %this )
    %combinePass.setShaderConst( "$colorFilter", $PostFX::HDRPostFX::colorFilter );  
    %combinePass.setShaderConst( "$saturationValue", $PostFX::HDRPostFX::saturationValue );
    %combinePass.setShaderConst( "$logContrast", $PostFX::HDRPostFX::logContrast );
- 
-   %combinePass.setShaderConst( "$g_fBloomScale", $PostFX::HDRPostFX::enableBloom );       
+       
    %combinePass.setShaderConst( "$g_fEnableAutoExposure", $PostFX::HDRPostFX::enableAutoExposure );
    
    %tonemapMode = 1;
@@ -285,7 +290,35 @@ function HDRPostFX::setShaderConsts( %this )
    %combinePass.setShaderConst( "$g_fOneOverGamma",  1 / %clampedGamma );       
    %combinePass.setShaderConst( "$Brightness", $pref::Video::Brightness );
    %combinePass.setShaderConst( "$Contrast", $pref::Video::Contrast );
- 
+   
+   // /----- BLOOM CONSTS -----/
+   %bloom = %this->hdrbloom;
+   %bloom.skip = !$PostFX::HDRPostFX::enableBloom;
+
+   %bloom.setShaderConst("$threshold", $PostFX::HDRPostFX::threshold);
+
+   for (%idx = 0; %idx < %this.mipsCount; %idx++)
+   {
+     %mip = %bloom.getObject(%this.mipsCount + %idx);
+     %mip.setShaderConst("$filterRadius", $PostFX::HDRPostFX::radius);
+   }
+
+   %strength = $PostFX::HDRPostFX::intensity;
+   if (!$PostFX::HDRPostFX::enableBloom)
+      %strength = 0.0;
+   
+   %bloomFinal = %this->hdrbloom_end;
+   %bloomFinal.setShaderConst("$strength", %strength);
+   
+   %dirtScale = $PostFX::HDRPostFX::dirtScale;
+   %dirtIntensity = $PostFX::HDRPostFX::dirtIntensity;
+   %bloomFinal.setShaderConst("$dirtParams", %dirtScale SPC %dirtScale SPC %dirtIntensity);
+   
+   %edgeMin = $PostFX::HDRPostFX::dirtEdgeMinDist;
+   %edgeMax = $PostFX::HDRPostFX::dirtEdgeMaxDist;
+   %edgeVal = $PostFX::HDRPostFX::dirtEdgeMinVal;
+   %bloomFinal.setShaderConst("$edgeParams", %edgeMin SPC %edgeMax SPC %edgeVal);
+   // \----- BLOOM CONSTS -----\
 }
 
 function HDRPostFX::preProcess( %this )
@@ -293,7 +326,31 @@ function HDRPostFX::preProcess( %this )
    %combinePass = %this-->combinePass;
    
    if ( %combinePass.texture[3] !$= $PostFX::HDRPostFX::colorCorrectionRamp )
-      %combinePass.setTexture( 3, $PostFX::HDRPostFX::colorCorrectionRamp );         
+      %combinePass.setTexture( 3, $PostFX::HDRPostFX::colorCorrectionRamp );    
+
+   // /----- BLOOM CONSTS -----/
+   %bloomFinal = %this->hdrbloom_end;
+
+   if (%this.enableDirt != $PostFX::HDRPostFX::enableDirt)
+   {
+      %this.enableDirt = $PostFX::HDRPostFX::enableDirt;
+      
+      if (%this.enableDirt)
+      {
+        %bloomFinal.setShaderMacro("USE_DIRT");
+      } else {
+        %bloomFinal.removeShaderMacro("USE_DIRT");
+      }
+   }
+   
+   if(%bloomFinal.texture[1] !$= $PostFX::HDRPostFX::dirtImage)
+   {
+      if ($PostFX::HDRPostFX::dirtImage $= "")
+        $PostFX::HDRPostFX::dirtImage = "core/postFX/images/lensDirt.png";
+      
+      %bloomFinal.setTexture(1, $PostFX::HDRPostFX::dirtImage);
+   }
+   // \----- BLOOM CONSTS -----\     
 }
 
 function HDRPostFX::onEnabled( %this )
@@ -355,6 +412,8 @@ function HDRPostFX::onDisabled( %this )
 
 function HDRPostFX::onAdd( %this )
 {
+   %this.SetupBloomFX();
+
    PostFXManager.registerPostEffect(%this);
    
    $PostFX::HDRPostFX::enableToneMapping = 1;
@@ -382,11 +441,24 @@ function HDRPostFX::populatePostFXSettings(%this)
    PostEffectEditorInspector.addField("$PostFX::HDRPostFX::colorFilter", "Color Tint", "colorF", "", $PostFX::HDRPostFX::colorFilter, "0 0 0");
    PostEffectEditorInspector.endGroup();
    
-   PostEffectEditorInspector.startGroup("HDR - HDR Bloom");
-   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableBloom", "Enable HDR Bloom", "bool", "", $PostFX::HDRPostFX::enableBloom, "");
-   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::gaussMultiplier", "Bloom Multiplier", "range", "", $PostFX::HDRPostFX::gaussMultiplier, "0.0 1.0 2.0");
-   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::brightPassThreshold", "Bright Pass Threshold", "float", "", $PostFX::HDRPostFX::brightPassThreshold, "");
-   PostEffectEditorInspector.endGroup(); 
+   // /----- BLOOM SETTINGS -----/
+   PostEffectEditorInspector.startGroup("HDR - Bloom");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableBloom", "Enable Bloom", "bool", "", $PostFX::HDRPostFX::enableBloom, "");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::threshold", "Threshold", "range", "", $PostFX::HDRPostFX::threshold, "0 1 10");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::intensity", "Intensity", "range", "", $PostFX::HDRPostFX::intensity, "0 10 10");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::radius", "Radius", "float", "", $PostFX::HDRPostFX::radius, "");
+   PostEffectEditorInspector.endGroup();
+   
+   PostEffectEditorInspector.startGroup("HDR - Lens Dirt");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableDirt", "Enable Dirt", "bool", "", $PostFX::HDRPostFX::enableDirt, "");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtScale", "Scale", "float", "", $PostFX::HDRPostFX::dirtScale, "");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtIntensity", "Intensity", "float", "", $PostFX::HDRPostFX::dirtIntensity, "");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtEdgeMinDist", "Min Dist", "range", "", $PostFX::HDRPostFX::dirtEdgeMinDist, "0 1 10");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtEdgeMaxDist", "Max Dist", "range", "", $PostFX::HDRPostFX::dirtEdgeMaxDist, "0 1 10");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtEdgeMinVal", "Min Value", "range", "", $PostFX::HDRPostFX::dirtEdgeMinVal, "0 1 10");
+   PostEffectEditorInspector.addField("$PostFX::HDRPostFX::dirtImage", "Dirt Image", "image", "", $PostFX::HDRPostFX::dirtImage, "");
+   PostEffectEditorInspector.endGroup();
+   // \----- BLOOM SETTINGS -----\
    
    PostEffectEditorInspector.startGroup("HDR - Adaptation");
    PostEffectEditorInspector.addField("$PostFX::HDRPostFX::enableAutoExposure", "Enable Auto Exposure", "bool", "", $PostFX::HDRPostFX::enableAutoExposure, "");
@@ -426,11 +498,93 @@ function HDRPostFX::savePresetSettings(%this)
    PostFXManager::savePresetSetting("$PostFX::HDRPostFX::whiteCutoff");
    PostFXManager::savePresetSetting("$PostFX::HDRPostFX::adaptRate");
    PostFXManager::savePresetSetting("$PostFX::HDRPostFX::tonemapMode");
-   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableBloom");
-   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::brightPassThreshold");
-   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::gaussMultiplier");
    PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableAutoExposure");
    PostFXManager::savePresetSetting("$PostFX::HDRPostFX::keyValue");
+
+   // /----- BLOOM SETTINGS -----/
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableBloom");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::threshold");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::intensity");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::radius");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::enableDirt");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtScale");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtIntensity");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtImage");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtEdgeMinDist");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtEdgeMaxDist");
+   PostFXManager::savePresetSetting("$PostFX::HDRPostFX::dirtEdgeMinVal");
+   // \----- BLOOM SETTINGS -----\
+}
+
+// This function sets up s sort of "mip-chain" for the bloom effect
+// Not really "optimal" but it works well enough
+function HDRPostFX::SetupBloomFX( %this )
+{
+   %bloomFX = new PostEffect()
+   {
+     internalName = "hdrbloom";
+     allowReflectPass = false;
+     shader = HDR_BloomThresholdShader;
+     stateBlock = HDR_DownSampleStateBlock;
+     texture[0] = "#hdrInitBloom";
+     target = "#hdrbloom_0";
+     targetFormat = %this.mipTexFormat;
+   };
+  
+   %textureName = "#hdrbloom_0";
+   for (%idx = 0; %idx < %this.mipsCount; %idx++)
+   {
+     %mipName = "hdrbloom_" @ (%idx + 1);
+     %mipFX = new PostEffect()
+     { 
+       internalName = %mipName;
+       allowReflectPass = false;
+       shader = HDR_BloomDownSampleShader;
+       stateBlock = HDR_DownSampleStateBlock;
+       texture[0] = %textureName;
+       target = "#" @ %mipName;
+       targetScale = "0.5 0.5";
+       targetFormat = %this.mipTexFormat;
+     };
+     
+     %bloomFX.add(%mipFX);
+     %textureName = "#" @ %mipName;
+   }
+   
+   for (%idx = %this.mipsCount; %idx > 0; %idx--)
+   {
+     %nxt = "#hdrbloom_" @ (%idx - 1);
+     %mipName = "hdrbloom_up_" @ (%idx - 1);
+     
+     %mipFX = new PostEffect()
+     {
+       internalName = %mipName;
+       allowReflectPass = false;
+       shader = HDR_BloomUpSampleShader;
+       stateBlock = HDR_DownSampleStateBlock;
+       texture[0] = %nxt;
+       texture[1] = %textureName;
+       target = "#" @ %mipName;
+       targetFormat = %this.mipTexFormat;
+     };
+     
+     %bloomFX.add(%mipFX);
+     %textureName = "#" @ %mipName;
+   }
+
+   %finalFX = new PostEffect()
+   {
+     internalName = "hdrbloom_end";
+     allowReflectPass = false;
+     shader = HDR_BloomDirtShader;
+     stateBlock = HDR_LensDirtStateBlock;
+     texture[0] = "#hdrbloom_up_0";
+     target = "#hdrbloom_end";
+     targetFormat = %this.mipTexFormat;
+   };
+   %this.add(%finalFX);
+
+   %this.add(%bloomFX);
 }
 
 singleton PostEffect( HDRPostFX )
@@ -443,6 +597,12 @@ singleton PostEffect( HDRPostFX )
    renderTime = "PFXBeforeBin";
    renderBin = "EditorBin";
    renderPriority = 9999;
+
+   // Hardcoded bloom settings.
+   // -- Amount of mip targets the bloom uses.
+   mipsCount = 5;
+   // -- Texture format for mip targets.
+   mipTexFormat = "GFXFormatR16G16B16A16F";
       
    // The bright pass generates a bloomed version of 
    // the scene for pixels which are brighter than a 
@@ -452,48 +612,15 @@ singleton PostEffect( HDRPostFX )
    // at the end of this post effect chain.
    //
                                 
-      shader = HDR_BrightPassShader;
-      stateBlock = HDR_DownSampleStateBlock;
-      texture[0] = "$backBuffer";
-      texture[1] = "#adaptedLum";
-      target = "$outTex";
-      targetFormat = "GFXFormatR16G16B16A16F"; 
-      targetScale = "0.5 0.5";
-      
-      new PostEffect()
-      {
-         allowReflectPass = false;
-         shader = HDR_DownScale4x4Shader;
-         stateBlock = HDR_DownSampleStateBlock;
-         texture[0] = "$inTex";
-         target = "$outTex";
-         targetFormat = "GFXFormatR16G16B16A16F";
-         targetScale = "0.25 0.25";
-      };
-      
-      new PostEffect()
-      {
-         allowReflectPass = false;
-         internalName = "bloomH";
-         
-         shader = HDR_BloomGaussBlurHShader;
-         stateBlock = HDR_DownSampleStateBlock;
-         texture[0] = "$inTex";
-         target = "$outTex";
-         targetFormat = "GFXFormatR16G16B16A16F";   
-      };
+   shader = HDR_BloomInitShader;
+   stateBlock = HDR_DownSampleStateBlock;
+   texture[0] = "$backBuffer";
+   texture[1] = "#adaptedLum";
+   target = "#hdrInitBloom";
+   targetFormat = "GFXFormatR16G16B16A16F"; 
+   targetScale = "0.5 0.5";
 
-      new PostEffect()
-      {
-         allowReflectPass = false;
-         internalName = "bloomV";
-                  
-         shader = HDR_BloomGaussBlurVShader;
-         stateBlock = HDR_DownSampleStateBlock;
-         texture[0] = "$inTex";
-         target = "#bloomFinal";
-         targetFormat = "GFXFormatR16G16B16A16F";    
-      };
+   // Bloom should get inserted about here.
 
    // BrightPass End
    
@@ -572,7 +699,7 @@ singleton PostEffect( HDRPostFX )
       stateBlock = HDR_CombineStateBlock;
       texture[0] = "$backBuffer";
       texture[1] = "#adaptedLum";            
-      texture[2] = "#bloomFinal";
+      texture[2] = "#hdrbloom_end";
       texture[3] = $PostFX::HDRPostFX::colorCorrectionRamp;
       target = "$backBuffer";
    };

+ 0 - 72
Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurHP.glsl

@@ -1,72 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2012 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-#include "core/rendering/shaders/gl/hlslCompat.glsl"
-#include "shadergen:/autogenConditioners.h"
-#include "core/rendering/shaders/postFX/gl/postFx.glsl"
-
-uniform sampler2D inputTex ;
-uniform vec2 oneOverTargetSize;
-uniform float gaussMultiplier;
-uniform float gaussMean;
-uniform float gaussStdDev;
-
-out vec4 OUT_col;
-
-#define PI 3.141592654
-
-float computeGaussianValue( float x, float mean, float std_deviation )
-{
-    // The gaussian equation is defined as such:
-    /*    
-      -(x - mean)^2
-      -------------
-      1.0               2*std_dev^2
-      f(x,mean,std_dev) = -------------------- * e^
-      sqrt(2*pi*std_dev^2)
-      
-     */
-
-    float tmp = ( 1.0f / sqrt( 2.0f * PI * std_deviation * std_deviation ) );
-    float tmp2 = exp( ( -( ( x - mean ) * ( x - mean ) ) ) / ( 2.0f * std_deviation * std_deviation ) );
-    return tmp * tmp2;
-}
-
-void main()
-{
-   vec4 color = vec4( 0.0f, 0.0f, 0.0f, 0.0f );
-   float offset = 0;
-   float weight = 0;
-   float x = 0;
-   float fI = 0;
-
-   for( int i = 0; i < 9; i++ )
-   {
-      fI = float(i);
-      offset = (i - 4.0) * oneOverTargetSize.x;
-      x = (i - 4.0) / 4.0;
-      weight = gaussMultiplier * computeGaussianValue( x, gaussMean, gaussStdDev );
-      color += (texture( inputTex, IN_uv0 + vec2( offset, 0.0f ) ) * weight );
-   }
-   
-   OUT_col = vec4( color.rgb, 1.0f );
-}

+ 0 - 111
Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurHP.hlsl

@@ -1,111 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2012 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-#include "core/rendering/shaders/postFX/postFx.hlsl"
-
-TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
-uniform float2 oneOverTargetSize;
-uniform float gaussMultiplier;
-uniform float gaussMean;
-uniform float gaussStdDev;
-
-#define PI 3.141592654
-
-float computeGaussianValue( float x, float mean, float std_deviation )
-{
-    // The gaussian equation is defined as such:
-    /*    
-      -(x - mean)^2
-      -------------
-      1.0               2*std_dev^2
-      f(x,mean,std_dev) = -------------------- * e^
-      sqrt(2*pi*std_dev^2)
-      
-     */
-
-    float tmp = ( 1.0f / sqrt( 2.0f * PI * std_deviation * std_deviation ) );
-    float tmp2 = exp( ( -( ( x - mean ) * ( x - mean ) ) ) / ( 2.0f * std_deviation * std_deviation ) );
-    return tmp * tmp2;
-}
-
-float SCurve (float x) 
-{
-		x = x * 2.0 - 1.0;
-		return -x * abs(x) * 0.5 + x + 0.5;
-}
-
-float4 BlurH (TORQUE_SAMPLER2D(source), float2 size, float2 uv, float radius) 
-{
-	if (radius >= 1.0)
-	{
-		float4 A = float4(0.0,0.0,0.0,0.0); 
-		float4 C = float4(0.0,0.0,0.0,0.0); 
-
-		float width = 1.0 / size.x;
-
-      float divisor = 0.0; 
-      float weight = 0.0;
-
-      float radiusMultiplier = 1.0 / radius;
-
-      // Hardcoded for radius 20 (normally we input the radius
-      // in there), needs to be literal here
-
-      for (float x = -20.0; x <= 20.0; x++)
-      {
-         A = TORQUE_TEX2D(source, uv + float2(x * width, 0.0));
-
-         weight = SCurve(1.0 - (abs(x) * radiusMultiplier)); 
-
-         C += A * weight; 
-
-         divisor += weight; 
-      }
-
-		return float4(C.r / divisor, C.g / divisor, C.b / divisor, 1.0);
-	}
-
-	return TORQUE_TEX2D(source, uv);
-}
-
-float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
-{
-   float4 color = { 0.0f, 0.0f, 0.0f, 0.0f };
-   float offset = 0;
-   float weight = 0;
-   float x = 0;
-   float fI = 0;
-
-   for( int i = 0; i < 9; i++ )
-   {
-      fI = (float)i;
-      offset = (i - 4.0) * oneOverTargetSize.x;
-      x = (i - 4.0) / 4.0;
-      weight = gaussMultiplier * computeGaussianValue( x, gaussMean, gaussStdDev );
-      color += (TORQUE_TEX2D( inputTex, IN.uv0 + float2( offset, 0.0f ) ) * weight );
-   }
-
-   //float2 targetSize = 1/oneOverTargetSize;
-   //float4 color = BlurH(TORQUE_SAMPLER2D_MAKEARG(inputTex), targetSize, IN.uv0, 20.0);
-   
-   return float4( color.rgb, 1.0f );
-}

+ 0 - 71
Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurVP.glsl

@@ -1,71 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2012 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-#include "core/rendering/shaders/gl/hlslCompat.glsl"
-#include "shadergen:/autogenConditioners.h"
-#include "core/rendering/shaders/postFX/gl/postFx.glsl"
-
-uniform sampler2D inputTex ;
-uniform vec2 oneOverTargetSize;
-uniform float gaussMultiplier;
-uniform float gaussMean;
-uniform float gaussStdDev;
-
-out vec4 OUT_col;
-
-#define D3DX_PI 3.141592654
-
-float computeGaussianValue( float x, float mean, float std_deviation )
-{
-    // The gaussian equation is defined as such:
-    /*    
-      -(x - mean)^2
-      -------------
-      1.0               2*std_dev^2
-      f(x,mean,std_dev) = -------------------- * e^
-      sqrt(2*pi*std_dev^2)
-      
-     */
-    float tmp = ( 1.0f / sqrt( 2.0f * D3DX_PI * std_deviation * std_deviation ) );
-    float tmp2 = exp( ( -( ( x - mean ) * ( x - mean ) ) ) / ( 2.0f * std_deviation * std_deviation ) );
-    return tmp * tmp2;
-}
-
-void main()
-{
-   vec4 color = vec4( 0.0f, 0.0f, 0.0f, 0.0f );
-   float offset = 0;
-   float weight = 0;
-   float x = 0;
-   float fI = 0;
-
-   for( int i = 0; i < 9; i++ )
-   {
-      fI = float(i);
-      offset = (fI - 4.0) * oneOverTargetSize.y;
-      x = (fI - 4.0) / 4.0;
-      weight = gaussMultiplier * computeGaussianValue( x, gaussMean, gaussStdDev );
-      color += (texture( inputTex, IN_uv0 + vec2( 0.0f, offset ) ) * weight );
-   }
-
-   OUT_col = vec4( color.rgb, 1.0f );
-}

+ 0 - 108
Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurVP.hlsl

@@ -1,108 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2012 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-#include "core/rendering/shaders/postFX/postFx.hlsl"
-
-TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
-uniform float2 oneOverTargetSize;
-uniform float gaussMultiplier;
-uniform float gaussMean;
-uniform float gaussStdDev;
-
-#define D3DX_PI 3.141592654
-
-float computeGaussianValue( float x, float mean, float std_deviation )
-{
-    // The gaussian equation is defined as such:
-    /*    
-      -(x - mean)^2
-      -------------
-      1.0               2*std_dev^2
-      f(x,mean,std_dev) = -------------------- * e^
-      sqrt(2*pi*std_dev^2)
-      
-     */
-    float tmp = ( 1.0f / sqrt( 2.0f * D3DX_PI * std_deviation * std_deviation ) );
-    float tmp2 = exp( ( -( ( x - mean ) * ( x - mean ) ) ) / ( 2.0f * std_deviation * std_deviation ) );
-    return tmp * tmp2;
-}
-
-float SCurve (float x) 
-{
-		x = x * 2.0 - 1.0;
-		return -x * abs(x) * 0.5 + x + 0.5;
-}
-
-float4 BlurV (TORQUE_SAMPLER2D(source), float2 size, float2 uv, float radius) 
-{
-	if (radius >= 1.0)
-	{
-		float4 A = float4(0.0,0.0,0.0,0.0); 
-		float4 C = float4(0.0,0.0,0.0,0.0); 
-
-		float height = 1.0 / size.y;
-
-		float divisor = 0.0; 
-      float weight = 0.0;
-
-      float radiusMultiplier = 1.0 / radius;
-
-      for (float y = -20.0; y <= 20.0; y++)
-      {
-         A = TORQUE_TEX2D(source, uv + float2(0.0, y * height));
-
-         weight = SCurve(1.0 - (abs(y) * radiusMultiplier)); 
-
-         C += A * weight; 
-
-         divisor += weight; 
-      }
-
-		return float4(C.r / divisor, C.g / divisor, C.b / divisor, 1.0);
-	}
-
-	return TORQUE_TEX2D(source, uv);
-}
-
-
-float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
-{
-   float4 color = { 0.0f, 0.0f, 0.0f, 0.0f };
-   float offset = 0;
-   float weight = 0;
-   float x = 0;
-   float fI = 0;
-
-   for( int i = 0; i < 9; i++ )
-   {
-      fI = (float)i;
-      offset = (fI - 4.0) * oneOverTargetSize.y;
-      x = (fI - 4.0) / 4.0;
-      weight = gaussMultiplier * computeGaussianValue( x, gaussMean, gaussStdDev );
-      color += (TORQUE_TEX2D( inputTex, IN.uv0 + float2( 0.0f, offset ) ) * weight );
-   }
-
-   //float2 targetSize = 1/oneOverTargetSize;
-   //float4 color = BlurV(TORQUE_SAMPLER2D_MAKEARG(inputTex), targetSize, IN.uv0, 20.0);
-
-   return float4( color.rgb, 1.0f );
-}

+ 25 - 16
Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/downScale4x4P.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomInitSample.glsl

@@ -20,31 +20,40 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#define IN_GLSL
-#include "core/rendering/shaders/shdrConsts.h"
 #include "core/rendering/shaders/gl/hlslCompat.glsl"
+#include "core/rendering/shaders/postFX/gl/postFx.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
 #include "shadergen:/autogenConditioners.h"
 
-in vec4 texCoords[8];
-#define IN_texCoords texCoords
+#define KERNEL_SAMPLES 4
+const vec2 KERNEL[9] = vec2[](
+  vec2( 0.5, 0.5),
+  vec2( 0.5,-0.5),
+  vec2(-0.5,-0.5),
+  vec2(-0.5, 0.5)
+);
 
 uniform sampler2D inputTex;
+uniform sampler2D luminanceTex;
+uniform float g_fMiddleGray;
+uniform vec2 oneOverTargetSize;
 
 out vec4 OUT_col;
-
-//-----------------------------------------------------------------------------
-// Main
-//-----------------------------------------------------------------------------
+ 
 void main()
 {
-   // We calculate the texture coords
-   // in the vertex shader as an optimization.
-   vec4 _sample = vec4(0.0f);
-   for ( int i = 0; i < 8; i++ )
+   const float weight = 1.0 / KERNEL_SAMPLES;
+   vec4 downSample = vec4(0, 0, 0, 0);
+   
+   for (int i=0; i<KERNEL_SAMPLES; i++)
    {
-      _sample += texture( inputTex, IN_texCoords[i].xy );
-      _sample += texture( inputTex, IN_texCoords[i].zw );
+     vec2 offset = KERNEL[i] * oneOverTargetSize;
+     vec4 sampleCol = hdrDecode( texture(inputTex, IN_uv0 + offset) );
+     downSample += sampleCol;
    }
+
+   float adaptedLum = texture( luminanceTex, vec2( 0.5, 0.5 ) ).r;
+   float lum = (g_fMiddleGray / (adaptedLum + 0.0001));
    
-	OUT_col = _sample / 16;
-}
+   return downSample * weight * lum;
+}

+ 24 - 21
Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/downScale4x4P.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomInitSample.hlsl

@@ -20,34 +20,37 @@
 // IN THE SOFTWARE.
 //-----------------------------------------------------------------------------
 
-#define IN_HLSL
-#include "core/rendering/shaders/shdrConsts.h"
 #include "core/rendering/shaders/postFX/postFx.hlsl"
+#include "core/rendering/shaders/torque.hlsl"
 
-//-----------------------------------------------------------------------------
-// Data 
-//-----------------------------------------------------------------------------
-struct VertIn
-{
-	float4 hpos : TORQUE_POSITION;
-	float4 texCoords[8] : TEXCOORD0;
+#define KERNEL_SAMPLES 4
+static const float2 KERNEL[4] = {
+  float2( 0.5f, 0.5f),
+  float2( 0.5f,-0.5f),
+  float2(-0.5f,-0.5f),
+  float2(-0.5f, 0.5f)
 };
 
 TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
+TORQUE_UNIFORM_SAMPLER2D(luminanceTex, 1);
+uniform float g_fMiddleGray;
+uniform float2 oneOverTargetSize;
  
-//-----------------------------------------------------------------------------
-// Main
-//-----------------------------------------------------------------------------
-float4 main(  VertIn IN) : TORQUE_TARGET0
+float4 main(PFXVertToPix IN) : TORQUE_TARGET0
 {
-   // We calculate the texture coords
-   // in the vertex shader as an optimization.
-   float4 sample = 0.0f;
-   for ( int i = 0; i < 8; i++ )
+   const float weight = 1.0f / KERNEL_SAMPLES;
+   float4 downSample = float4(0, 0, 0, 0);
+   
+   [unroll]
+   for (int i=0; i<KERNEL_SAMPLES; i++)
    {
-      sample += TORQUE_TEX2D( inputTex, IN.texCoords[i].xy );
-      sample += TORQUE_TEX2D( inputTex, IN.texCoords[i].zw );
+     float2 offset = KERNEL[i] * oneOverTargetSize;
+     float4 sampleCol = hdrDecode( TORQUE_TEX2D(inputTex, IN.uv0 + offset) );
+     downSample += sampleCol;
    }
+
+   float adaptedLum = TORQUE_TEX2D( luminanceTex, float2( 0.5f, 0.5f ) ).r;
+   float lum = (g_fMiddleGray / (adaptedLum + 0.0001f));
    
-	return sample / 16;
-}
+   return downSample * weight * lum;
+}

+ 1 - 1
Templates/BaseGame/game/core/postFX/scripts/Bloom/gl/bloomStrengthP.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomStrengthP.glsl

@@ -54,5 +54,5 @@ void main()
     upSample.rgb += upSample.rgb * dirt;
   #endif
   
-  OUT_col = upSample * M_1OVER_PI_F;
+  OUT_col = max(upSample * M_1OVER_PI_F, 0.0);
 }

+ 1 - 1
Templates/BaseGame/game/core/postFX/scripts/Bloom/bloomStrengthP.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomStrengthP.hlsl

@@ -48,5 +48,5 @@ float4 main(PFXVertToPix IN) : TORQUE_TARGET0
     upSample.rgb += upSample.rgb * dirt;
   #endif
   
-  return upSample * M_1OVER_PI_F;
+  return max(upSample * M_1OVER_PI_F, 0.0f);
 }

+ 0 - 0
Templates/BaseGame/game/core/postFX/scripts/Bloom/gl/bloomThresholdP.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomThresholdP.glsl


+ 0 - 0
Templates/BaseGame/game/core/postFX/scripts/Bloom/bloomThresholdP.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomThresholdP.hlsl


+ 0 - 0
Templates/BaseGame/game/core/postFX/scripts/Bloom/gl/downSampleP.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/downSampleP.glsl


+ 0 - 0
Templates/BaseGame/game/core/postFX/scripts/Bloom/downSampleP.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/downSampleP.hlsl


+ 0 - 141
Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/downScale4x4V.glsl

@@ -1,141 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2012 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-#define IN_GLSL
-#include "core/rendering/shaders/shdrConsts.h"
-#include "core/rendering/shaders/gl/hlslCompat.glsl"
-
-in vec4 vPosition;
-in vec2 vTexCoord0;
-
-#define In_pos vPosition
-#define In_uv vTexCoord0
-
-//-----------------------------------------------------------------------------
-// Constants
-//-----------------------------------------------------------------------------
-out vec4 texCoords[8];
-#define Out_texCoords texCoords
-
-#define Out_hpos gl_Position
-
-uniform vec2 targetSize;
-
-//-----------------------------------------------------------------------------
-// Main
-//-----------------------------------------------------------------------------
-void main()
-{
-	Out_hpos = In_pos;
-   
-   // Sample from the 16 surrounding points. Since the center point will be in
-   // the exact center of 16 texels, a 0.5f offset is needed to specify a texel
-   // center.
-   vec2 texSize = vec2( 1.0 / (targetSize.x - 1.0), 1.0 / (targetSize.y - 1.0) );
-   
-   vec4 uv;
-	uv.xy = In_uv.xy;
-	uv.zw = In_uv.xy;
-   
-   Out_texCoords[0] = uv;
-   Out_texCoords[0].x += texSize.x;
-   Out_texCoords[0].y += texSize.y;
-   Out_texCoords[0].z += texSize.x;
-   Out_texCoords[0].w += texSize.y;
-   Out_texCoords[0].x += ( 0 - 1.5 ) * texSize.x;
-   Out_texCoords[0].y += ( 0 - 1.5 ) * texSize.y;
-   Out_texCoords[0].z += ( 1 - 1.5 ) * texSize.x;
-   Out_texCoords[0].w += ( 0 - 1.5 ) * texSize.y;
-   
-   Out_texCoords[1] = uv;
-   Out_texCoords[1].x += texSize.x;
-   Out_texCoords[1].y += texSize.y;
-   Out_texCoords[1].z += texSize.x;
-   Out_texCoords[1].w += texSize.y;
-   Out_texCoords[1].x += ( 2 - 1.5 ) * texSize.x;
-   Out_texCoords[1].y += ( 0 - 1.5 ) * texSize.y;
-   Out_texCoords[1].z += ( 3 - 1.5 ) * texSize.x;
-   Out_texCoords[1].w += ( 0 - 1.5 ) * texSize.y;
-   
-   Out_texCoords[2] = uv;
-   Out_texCoords[2].x += texSize.x;
-   Out_texCoords[2].y += texSize.y;
-   Out_texCoords[2].z += texSize.x;
-   Out_texCoords[2].w += texSize.y;
-   Out_texCoords[2].x += ( 0 - 1.5 ) * texSize.x;
-   Out_texCoords[2].y += ( 1 - 1.5 ) * texSize.y;
-   Out_texCoords[2].z += ( 1 - 1.5 ) * texSize.x;
-   Out_texCoords[2].w += ( 1 - 1.5 ) * texSize.y;
-   
-   Out_texCoords[3] = uv;
-   Out_texCoords[3].x += texSize.x;
-   Out_texCoords[3].y += texSize.y;
-   Out_texCoords[3].z += texSize.x;
-   Out_texCoords[3].w += texSize.y;
-   Out_texCoords[3].x += ( 2 - 1.5 ) * texSize.x;
-   Out_texCoords[3].y += ( 1 - 1.5 ) * texSize.y;
-   Out_texCoords[3].z += ( 3 - 1.5 ) * texSize.x;
-   Out_texCoords[3].w += ( 1 - 1.5 ) * texSize.y;
-   
-   Out_texCoords[4] = uv;
-   Out_texCoords[4].x += texSize.x;
-   Out_texCoords[4].y += texSize.y;
-   Out_texCoords[4].z += texSize.x;
-   Out_texCoords[4].w += texSize.y;
-   Out_texCoords[4].x += ( 0 - 1.5 ) * texSize.x;
-   Out_texCoords[4].y += ( 2 - 1.5 ) * texSize.y;
-   Out_texCoords[4].z += ( 1 - 1.5 ) * texSize.x;
-   Out_texCoords[4].w += ( 2 - 1.5 ) * texSize.y;
-   
-   Out_texCoords[5] = uv;
-   Out_texCoords[5].x += texSize.x;
-   Out_texCoords[5].y += texSize.y;
-   Out_texCoords[5].z += texSize.x;
-   Out_texCoords[5].w += texSize.y;
-   Out_texCoords[5].x += ( 2 - 1.5 ) * texSize.x;
-   Out_texCoords[5].y += ( 2 - 1.5 ) * texSize.y;
-   Out_texCoords[5].z += ( 3 - 1.5 ) * texSize.x;
-   Out_texCoords[5].w += ( 2 - 1.5 ) * texSize.y;
-   
-   Out_texCoords[6] = uv;
-   Out_texCoords[6].x += texSize.x;
-   Out_texCoords[6].y += texSize.y;
-   Out_texCoords[6].z += texSize.x;
-   Out_texCoords[6].w += texSize.y;
-   Out_texCoords[6].x += ( 0 - 1.5 ) * texSize.x;
-   Out_texCoords[6].y += ( 3 - 1.5 ) * texSize.y;
-   Out_texCoords[6].z += ( 1 - 1.5 ) * texSize.x;
-   Out_texCoords[6].w += ( 3 - 1.5 ) * texSize.y;
-   
-   Out_texCoords[7] = uv;
-   Out_texCoords[7].x += texSize.x;
-   Out_texCoords[7].y += texSize.y;
-   Out_texCoords[7].z += texSize.x;
-   Out_texCoords[7].w += texSize.y;
-   Out_texCoords[7].x += ( 2 - 1.5 ) * texSize.x;
-   Out_texCoords[7].y += ( 3 - 1.5 ) * texSize.y;
-   Out_texCoords[7].z += ( 3 - 1.5 ) * texSize.x;
-   Out_texCoords[7].w += ( 3 - 1.5 ) * texSize.y;
-   
-	correctSSP(gl_Position);
-}
-

+ 0 - 138
Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/downScale4x4V.hlsl

@@ -1,138 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright (c) 2012 GarageGames, LLC
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-//-----------------------------------------------------------------------------
-
-#define IN_HLSL
-#include "core/rendering/shaders/shdrConsts.h"
-#include "core/rendering/shaders/postFX/postFx.hlsl"
-//-----------------------------------------------------------------------------
-// Constants
-//-----------------------------------------------------------------------------
- 
-struct Conn
-{
-	float4 hpos : TORQUE_POSITION;
-   float4 texCoords[8] : TEXCOORD0;
-};
-
-uniform float2 targetSize;
-
-//-----------------------------------------------------------------------------
-// Main
-//-----------------------------------------------------------------------------
-Conn main(  PFXVert In )
-{
-	Conn Out;
-
-	Out.hpos = float4(In.pos,1.0);
-   
-   // Sample from the 16 surrounding points. Since the center point will be in
-   // the exact center of 16 texels, a 0.5f offset is needed to specify a texel
-   // center.
-   float2 texSize = float2( 1.0 / (targetSize.x - 1.0), 1.0 / (targetSize.y - 1.0) );
-   
-   float4 uv;
-	uv.xy = In.uv.xy;
-	uv.zw = In.uv.xy;
-   
-   Out.texCoords[0] = uv;
-   Out.texCoords[0].x += texSize.x;
-   Out.texCoords[0].y += texSize.y;
-   Out.texCoords[0].z += texSize.x;
-   Out.texCoords[0].w += texSize.y;
-   Out.texCoords[0].x += ( 0 - 1.5 ) * texSize.x;
-   Out.texCoords[0].y += ( 0 - 1.5 ) * texSize.y;
-   Out.texCoords[0].z += ( 1 - 1.5 ) * texSize.x;
-   Out.texCoords[0].w += ( 0 - 1.5 ) * texSize.y;
-   
-   Out.texCoords[1] = uv;
-   Out.texCoords[1].x += texSize.x;
-   Out.texCoords[1].y += texSize.y;
-   Out.texCoords[1].z += texSize.x;
-   Out.texCoords[1].w += texSize.y;
-   Out.texCoords[1].x += ( 2 - 1.5 ) * texSize.x;
-   Out.texCoords[1].y += ( 0 - 1.5 ) * texSize.y;
-   Out.texCoords[1].z += ( 3 - 1.5 ) * texSize.x;
-   Out.texCoords[1].w += ( 0 - 1.5 ) * texSize.y;
-   
-   Out.texCoords[2] = uv;
-   Out.texCoords[2].x += texSize.x;
-   Out.texCoords[2].y += texSize.y;
-   Out.texCoords[2].z += texSize.x;
-   Out.texCoords[2].w += texSize.y;
-   Out.texCoords[2].x += ( 0 - 1.5 ) * texSize.x;
-   Out.texCoords[2].y += ( 1 - 1.5 ) * texSize.y;
-   Out.texCoords[2].z += ( 1 - 1.5 ) * texSize.x;
-   Out.texCoords[2].w += ( 1 - 1.5 ) * texSize.y;
-   
-   Out.texCoords[3] = uv;
-   Out.texCoords[3].x += texSize.x;
-   Out.texCoords[3].y += texSize.y;
-   Out.texCoords[3].z += texSize.x;
-   Out.texCoords[3].w += texSize.y;
-   Out.texCoords[3].x += ( 2 - 1.5 ) * texSize.x;
-   Out.texCoords[3].y += ( 1 - 1.5 ) * texSize.y;
-   Out.texCoords[3].z += ( 3 - 1.5 ) * texSize.x;
-   Out.texCoords[3].w += ( 1 - 1.5 ) * texSize.y;
-   
-   Out.texCoords[4] = uv;
-   Out.texCoords[4].x += texSize.x;
-   Out.texCoords[4].y += texSize.y;
-   Out.texCoords[4].z += texSize.x;
-   Out.texCoords[4].w += texSize.y;
-   Out.texCoords[4].x += ( 0 - 1.5 ) * texSize.x;
-   Out.texCoords[4].y += ( 2 - 1.5 ) * texSize.y;
-   Out.texCoords[4].z += ( 1 - 1.5 ) * texSize.x;
-   Out.texCoords[4].w += ( 2 - 1.5 ) * texSize.y;
-   
-   Out.texCoords[5] = uv;
-   Out.texCoords[5].x += texSize.x;
-   Out.texCoords[5].y += texSize.y;
-   Out.texCoords[5].z += texSize.x;
-   Out.texCoords[5].w += texSize.y;
-   Out.texCoords[5].x += ( 2 - 1.5 ) * texSize.x;
-   Out.texCoords[5].y += ( 2 - 1.5 ) * texSize.y;
-   Out.texCoords[5].z += ( 3 - 1.5 ) * texSize.x;
-   Out.texCoords[5].w += ( 2 - 1.5 ) * texSize.y;
-   
-   Out.texCoords[6] = uv;
-   Out.texCoords[6].x += texSize.x;
-   Out.texCoords[6].y += texSize.y;
-   Out.texCoords[6].z += texSize.x;
-   Out.texCoords[6].w += texSize.y;
-   Out.texCoords[6].x += ( 0 - 1.5 ) * texSize.x;
-   Out.texCoords[6].y += ( 3 - 1.5 ) * texSize.y;
-   Out.texCoords[6].z += ( 1 - 1.5 ) * texSize.x;
-   Out.texCoords[6].w += ( 3 - 1.5 ) * texSize.y;
-   
-   Out.texCoords[7] = uv;
-   Out.texCoords[7].x += texSize.x;
-   Out.texCoords[7].y += texSize.y;
-   Out.texCoords[7].z += texSize.x;
-   Out.texCoords[7].w += texSize.y;
-   Out.texCoords[7].x += ( 2 - 1.5 ) * texSize.x;
-   Out.texCoords[7].y += ( 3 - 1.5 ) * texSize.y;
-   Out.texCoords[7].z += ( 3 - 1.5 ) * texSize.x;
-   Out.texCoords[7].w += ( 3 - 1.5 ) * texSize.y;
-   
-	return Out;
-}
-

+ 0 - 0
Templates/BaseGame/game/core/postFX/scripts/Bloom/gl/upSampleP.glsl → Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/upSampleP.glsl


+ 0 - 0
Templates/BaseGame/game/core/postFX/scripts/Bloom/upSampleP.hlsl → Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/upSampleP.hlsl


+ 2 - 2
Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_finalPass.glsl

@@ -41,7 +41,7 @@ uniform float g_fWhiteCutoff;
 uniform float g_fEnableAutoExposure;
 uniform float g_fTonemapMode;
 
-uniform float g_fBloomScale;
+//uniform float g_fBloomScale;
 
 uniform float g_fOneOverGamma;
 uniform float Brightness;
@@ -102,7 +102,7 @@ void main()
    
         	    
    // Add the bloom effect.     
-   _sample += (g_fBloomScale * bloom) / 10; 
+   _sample += bloom; 
    
    //Apply Exposure     
    _sample.rgb *= TO_Exposure(_sample.rgb, exposureValue, colorFilter);

+ 2 - 2
Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_finalPass.hlsl

@@ -39,7 +39,7 @@ uniform float g_fMiddleGray;
 uniform float g_fEnableAutoExposure;
 uniform float g_fTonemapMode;
 
-uniform float g_fBloomScale;
+//uniform float g_fBloomScale;
 uniform float g_fOneOverGamma;
 uniform float Brightness;
 uniform float Contrast;
@@ -94,7 +94,7 @@ float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
    float4 bloom = TORQUE_TEX2D( bloomTex, IN.uv0 ); 
         	    
    // Add the bloom effect.     
-   sample += (g_fBloomScale * bloom) / 10;         
+   sample += bloom;         
    			
 	//Apply Exposure     
    sample.rgb *= TO_Exposure(sample.rgb, exposureValue, colorFilter);