diff --git a/.gitignore b/.gitignore
index 86c26bc28..c968f47c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -184,3 +184,5 @@ Project Manager.exe
projects.xml
Qt*.dll
.vs
+Engine/lib/assimp/include/assimp/config.h
+Engine/lib/assimp/revision.h
diff --git a/Templates/BaseGame/game/core/postFX/images/lensDirt.png b/Templates/BaseGame/game/core/postFX/images/lensDirt.png
new file mode 100644
index 000000000..51d66be71
Binary files /dev/null and b/Templates/BaseGame/game/core/postFX/images/lensDirt.png differ
diff --git a/Templates/BaseGame/game/core/postFX/images/lensDirt_image.asset.taml b/Templates/BaseGame/game/core/postFX/images/lensDirt_image.asset.taml
new file mode 100644
index 000000000..2c84ec01b
--- /dev/null
+++ b/Templates/BaseGame/game/core/postFX/images/lensDirt_image.asset.taml
@@ -0,0 +1,3 @@
+
diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.tscript b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.tscript
index 1d0b7485d..94374b398 100644
--- a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.tscript
+++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDRPostFX.tscript
@@ -56,31 +56,33 @@ $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;
+// Inspired by bloom described in paper listed here:
+// http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
-/// The threshold luminace value for pixels which are
-/// considered "bright" and need to be bloomed.
-$PostFX::HDRPostFX::brightPassThreshold = 0.08;
+$PostFX::HDRPostFX::enableBloom = true;
+$PostFX::HDRPostFX::threshold = 1.25;
+$PostFX::HDRPostFX::intensity = 0.25;
+$PostFX::HDRPostFX::radius = 4.0;
-/// 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;
+$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";
@@ -88,42 +90,56 @@ singleton ShaderData( HDR_BrightPassShader )
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";
-
- samplerNames[0] = "$inputTex";
-
- pixVersion = 2.0;
-};
-
-singleton ShaderData( HDR_BloomGaussBlurHShader )
-{
- 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/bloomThresholdP.hlsl";
+ OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+ OGLPixelShaderFile = "./HDR_Bloom/bloomThresholdP.glsl";
samplerNames[0] = "$inputTex";
pixVersion = 3.0;
};
-singleton ShaderData( HDR_BloomGaussBlurVShader )
+singleton ShaderData( HDR_BloomDownSampleShader )
{
- 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/downSampleP.hlsl";
+ OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl";
+ OGLPixelShaderFile = "./HDR_Bloom/downSampleP.glsl";
samplerNames[0] = "$inputTex";
pixVersion = 3.0;
};
+singleton ShaderData( HDR_BloomUpSampleShader )
+{
+ 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;
+};
+
singleton ShaderData( HDR_SampleLumShader )
{
DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
@@ -191,6 +207,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 +246,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 +269,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 +291,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 +327,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 +413,8 @@ function HDRPostFX::onDisabled( %this )
function HDRPostFX::onAdd( %this )
{
+ %this.SetupBloomFX();
+
PostFXManager.registerPostEffect(%this);
$PostFX::HDRPostFX::enableToneMapping = 1;
@@ -382,11 +442,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 2 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 +499,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(%bloomFX);
+ %this.add(%finalFX);
}
singleton PostEffect( HDRPostFX )
@@ -443,6 +598,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 +613,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 +700,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";
};
diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurHP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurHP.hlsl
deleted file mode 100644
index 48e490e7c..000000000
--- a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurHP.hlsl
+++ /dev/null
@@ -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 );
-}
\ No newline at end of file
diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurVP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurVP.hlsl
deleted file mode 100644
index bd8e16a16..000000000
--- a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurVP.hlsl
+++ /dev/null
@@ -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 );
-}
\ No newline at end of file
diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurHP.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomInitSample.glsl
similarity index 57%
rename from Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurHP.glsl
rename to Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomInitSample.glsl
index 48e654ddc..3c6ef6e6c 100644
--- a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomGaussBlurHP.glsl
+++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_Bloom/bloomInitSample.glsl
@@ -21,52 +21,39 @@
//-----------------------------------------------------------------------------
#include "core/rendering/shaders/gl/hlslCompat.glsl"
-#include "shadergen:/autogenConditioners.h"
#include "core/rendering/shaders/postFX/gl/postFx.glsl"
+#include "core/rendering/shaders/gl/torque.glsl"
+#include "shadergen:/autogenConditioners.h"
-uniform sampler2D inputTex ;
+#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;
-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 );
- }
+ const float weight = 1.0 / KERNEL_SAMPLES;
+ vec4 downSample = vec4(0, 0, 0, 0);
- OUT_col = vec4( color.rgb, 1.0f );
-}
\ No newline at end of file
+ for (int i=0; i>>>>>> development
$PostFX::HDRPostFX::brightPassThreshold = "0.02";
$PostFX::HDRPostFX::gaussMultiplier = "0.4";
$PostFX::HDRPostFX::enableAutoExposure = "1";
diff --git a/Templates/BaseGame/game/core/rendering/shaders/gl/torque.glsl b/Templates/BaseGame/game/core/rendering/shaders/gl/torque.glsl
index 4ec0303aa..14f5f9f24 100644
--- a/Templates/BaseGame/game/core/rendering/shaders/gl/torque.glsl
+++ b/Templates/BaseGame/game/core/rendering/shaders/gl/torque.glsl
@@ -27,7 +27,7 @@
float M_HALFPI_F = 1.57079632679489661923;
float M_PI_F = 3.14159265358979323846;
float M_2PI_F = 6.28318530717958647692;
-float M_1OVER_PI_F = 0.31830988618f;
+float M_1OVER_PI_F = 0.31830988618;
/// Calculate fog based on a start and end positions in worldSpace.
float computeSceneFog( vec3 startPos,
diff --git a/Templates/BaseGame/game/core/settings.xml b/Templates/BaseGame/game/core/settings.xml
index e42be0937..df6221c23 100644
--- a/Templates/BaseGame/game/core/settings.xml
+++ b/Templates/BaseGame/game/core/settings.xml
@@ -1,15 +1,38 @@
-
+
-
- MainMenuGUI
- PlayGUI
-
-
-
- core/
+
+
+ core/
-
- Deferred
+
+ Deferred
+
+
+ 0.560687482
+ 12
+ 0
+ 12
+ 12
+ 12
+
+
+ MainMenuGUI
+ PlayGUI