From e9be30b9322021b0986948003d9cc89893f112f5 Mon Sep 17 00:00:00 2001 From: Samuel Skiff Date: Tue, 30 Aug 2022 05:37:58 -0500 Subject: [PATCH] Convert Tabs to Space & Enable Glow Effect --- .../postFX/scripts/Bloom/BloomPostFX.tscript | 60 +++++++++---------- .../postFX/scripts/Bloom/bloomStrengthP.hlsl | 26 ++++---- .../postFX/scripts/Bloom/bloomThresholdP.hlsl | 16 ++--- .../postFX/scripts/Bloom/downSampleP.hlsl | 48 +++++++-------- .../scripts/Bloom/gl/bloomStrengthP.glsl | 26 ++++---- .../scripts/Bloom/gl/bloomThresholdP.glsl | 16 ++--- .../postFX/scripts/Bloom/gl/downSampleP.glsl | 46 +++++++------- .../postFX/scripts/Bloom/gl/upSampleP.glsl | 48 +++++++-------- .../core/postFX/scripts/Bloom/upSampleP.hlsl | 52 ++++++++-------- .../postFX/scripts/Glow/GlowPostFX.tscript | 2 +- 10 files changed, 170 insertions(+), 170 deletions(-) diff --git a/Templates/BaseGame/game/core/postFX/scripts/Bloom/BloomPostFX.tscript b/Templates/BaseGame/game/core/postFX/scripts/Bloom/BloomPostFX.tscript index ccc2abada..7dbdaff31 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Bloom/BloomPostFX.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/Bloom/BloomPostFX.tscript @@ -39,8 +39,8 @@ singleton ShaderData( Bloom_ThresholdShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; DXPixelShaderFile = "./bloomThresholdP.hlsl"; - OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = "./gl/bloomThresholdP.glsl"; + OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "./gl/bloomThresholdP.glsl"; samplerNames[0] = "$inputTex"; @@ -51,8 +51,8 @@ singleton ShaderData( Bloom_DownSampleShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; DXPixelShaderFile = "./downSampleP.hlsl"; - OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = "./gl/downSampleP.glsl"; + OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "./gl/downSampleP.glsl"; samplerNames[0] = "$inputTex"; @@ -63,8 +63,8 @@ singleton ShaderData( Bloom_UpSampleShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; DXPixelShaderFile = "./upSampleP.hlsl"; - OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = "./gl/upSampleP.glsl"; + OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "./gl/upSampleP.glsl"; samplerNames[0] = "$nxtTex"; samplerNames[1] = "$mipTex"; @@ -76,8 +76,8 @@ singleton ShaderData( Bloom_StrengthShader ) { DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; DXPixelShaderFile = "./bloomStrengthP.hlsl"; - OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; - OGLPixelShaderFile = "./gl/bloomStrengthP.glsl"; + OGLVertexShaderFile= $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "./gl/bloomStrengthP.glsl"; samplerNames[0] = "$inputTex"; samplerNames[1] = "$dirtTex"; @@ -122,11 +122,11 @@ function BloomPostFX::setShaderConsts( %this ) %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); + + %edgeMin = $PostFX::BloomPostFX::dirtEdgeMinDist; + %edgeMax = $PostFX::BloomPostFX::dirtEdgeMaxDist; + %edgeVal = $PostFX::BloomPostFX::dirtEdgeMinVal; + %final.setShaderConst("$edgeParams", %edgeMin SPC %edgeMax SPC %edgeVal); } function BloomPostFX::preProcess( %this ) @@ -146,11 +146,11 @@ function BloomPostFX::preProcess( %this ) if(%this.dirtImage !$= $PostFX::BloomPostFX::dirtImage) { - if ($PostFX::BloomPostFX::dirtImage $= "") - $PostFX::BloomPostFX::dirtImage = "core/postFX/images/lensDirt.png"; - - %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); } @@ -168,7 +168,7 @@ function BloomPostFX::SetupBlurFX( %this ) stateBlock = Bloom_SampleStateBlock; texture[0] = "#threshold"; target = "#bloom_0"; - targetScale = "0.5 0.5"; + targetScale = "0.5 0.5"; targetFormat = %this.mipTexFormat; }; @@ -206,8 +206,8 @@ function BloomPostFX::SetupBlurFX( %this ) texture[0] = %nxt; texture[1] = %textureName; target = "#" @ %mipName; - targetScale = "1.0 1.0"; - targetFormat = %this.mipTexFormat; + targetScale = "1.0 1.0"; + targetFormat = %this.mipTexFormat; }; %blurFX.add(%mipFX); @@ -250,9 +250,9 @@ function BloomPostFX::populatePostFXSettings(%this) 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::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(); } @@ -289,18 +289,18 @@ function BloomPostFX::savePresetSettings(%this) 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"); + + 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"; - + mipTexFormat = "GFXFormatR16G16B16A16F"; + enabled = false; allowReflectPass = false; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Bloom/bloomStrengthP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Bloom/bloomStrengthP.hlsl index f0d9d56c6..76cb1f2e0 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Bloom/bloomStrengthP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Bloom/bloomStrengthP.hlsl @@ -36,17 +36,17 @@ uniform float2 oneOverTargetSize; float4 main(PFXVertToPix IN) : TORQUE_TARGET0 { - #ifdef USE_DIRT - float edge = distance(IN.uv0, float2(0.5f, 0.5f)); - edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z); - float3 dirt = TORQUE_TEX2D(dirtTex, IN.uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge; - #endif - - float4 upSample = TORQUE_TEX2D(inputTex, IN.uv0) * strength; - - #ifdef USE_DIRT - upSample.rgb += upSample.rgb * dirt; - #endif - - return upSample * M_1OVER_PI_F; + #ifdef USE_DIRT + float edge = distance(IN.uv0, float2(0.5f, 0.5f)); + edge = max(smoothstep(edgeParams.x, edgeParams.y, edge), edgeParams.z); + float3 dirt = TORQUE_TEX2D(dirtTex, IN.uv0 / (dirtParams.xy * oneOverTargetSize)).rgb * dirtParams.z * edge; + #endif + + float4 upSample = TORQUE_TEX2D(inputTex, IN.uv0) * strength; + + #ifdef USE_DIRT + upSample.rgb += upSample.rgb * dirt; + #endif + + return upSample * M_1OVER_PI_F; } diff --git a/Templates/BaseGame/game/core/postFX/scripts/Bloom/bloomThresholdP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Bloom/bloomThresholdP.hlsl index 4c016ea60..aa3a952b7 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Bloom/bloomThresholdP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Bloom/bloomThresholdP.hlsl @@ -28,12 +28,12 @@ uniform float threshold; float4 main(PFXVertToPix IN) : TORQUE_TARGET0 { - float4 screenColor = TORQUE_TEX2D(inputTex, IN.uv0); - float lum = hdrLuminance(screenColor.rgb); - - float brightness = max(screenColor.r, max(screenColor.g, screenColor.b)); - float contribution = saturate(brightness - threshold) / max(brightness, 0.0001f); - contribution = sqr(lum * contribution); - - return max(screenColor * sqr(contribution), 0.0001f); + float4 screenColor = TORQUE_TEX2D(inputTex, IN.uv0); + float lum = hdrLuminance(screenColor.rgb); + + float brightness = max(screenColor.r, max(screenColor.g, screenColor.b)); + float contribution = saturate(brightness - threshold) / max(brightness, 0.0001f); + contribution = sqr(lum * contribution); + + return max(screenColor * sqr(contribution), 0.0001f); } diff --git a/Templates/BaseGame/game/core/postFX/scripts/Bloom/downSampleP.hlsl b/Templates/BaseGame/game/core/postFX/scripts/Bloom/downSampleP.hlsl index 555c5fd2e..eb9f37cc5 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Bloom/downSampleP.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/Bloom/downSampleP.hlsl @@ -24,15 +24,15 @@ #define KERNEL_SAMPLES 9 static const float3 KERNEL[9] = { - float3( 0.0000f, 0.0000f, 0.2500f), - float3( 1.0000f, 0.0000f, 0.1250f), - float3( 0.0000f, 1.0000f, 0.1250f), - float3(-1.0000f, 0.0000f, 0.1250f), - float3( 0.0000f,-1.0000f, 0.1250f), - float3( 1.0000f, 1.0000f, 0.0625f), - float3( 1.0000f,-1.0000f, 0.0625f), - float3(-1.0000f,-1.0000f, 0.0625f), - float3(-1.0000f, 1.0000f, 0.0625f) + float3( 0.0000f, 0.0000f, 0.2500f), + float3( 1.0000f, 0.0000f, 0.1250f), + float3( 0.0000f, 1.0000f, 0.1250f), + float3(-1.0000f, 0.0000f, 0.1250f), + float3( 0.0000f,-1.0000f, 0.1250f), + float3( 1.0000f, 1.0000f, 0.0625f), + float3( 1.0000f,-1.0000f, 0.0625f), + float3(-1.0000f,-1.0000f, 0.0625f), + float3(-1.0000f, 1.0000f, 0.0625f) }; TORQUE_UNIFORM_SAMPLER2D(inputTex, 0); @@ -40,19 +40,19 @@ uniform float2 oneOverTargetSize; float4 main(PFXVertToPix IN) : TORQUE_TARGET0 { - float4 downSample = float4(0, 0, 0, 0); - - [unroll] - for (int i=0; i