diff --git a/Templates/BaseGame/game/core/postFX/scripts/SMAA/BBtoGamma.hlsl b/Templates/BaseGame/game/core/postFX/scripts/SMAA/BBtoGamma.hlsl new file mode 100644 index 000000000..2b2c452bf --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/SMAA/BBtoGamma.hlsl @@ -0,0 +1,30 @@ +//----------------------------------------------------------------------------- +// 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/torque.hlsl" +#include "core/rendering/shaders/postFX/postFx.hlsl" + +TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0); + +float4 main(PFXVertToPix IN) : TORQUE_TARGET0 +{ + return toGamma(TORQUE_TEX2D(backBuffer, IN.uv0)); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/core/postFX/scripts/SMAA/SMAAPostFX.tscript b/Templates/BaseGame/game/core/postFX/scripts/SMAA/SMAAPostFX.tscript index 2e863dc3e..68d7069b8 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/SMAA/SMAAPostFX.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/SMAA/SMAAPostFX.tscript @@ -103,23 +103,59 @@ singleton ShaderData( SMAA_Neighbor_H_Shader ) pixVersion = 3.0; }; +singleton GFXStateBlockData( BBtoGamma_StateBlock ) +{ + zDefined = true; + zEnable = false; + zWriteEnable = false; + + samplersDefined = true; + samplerStates[0] = SamplerClampLinear; +}; + +singleton ShaderData( BBtoGammaShader ) +{ + DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl"; + DXPixelShaderFile = "./BBtoGamma.hlsl"; + OGLVertexShaderFile = $Core::CommonShaderPath @ "/postFX/gl/postFxV.glsl"; + OGLPixelShaderFile = "./gl/BBtoGamma.glsl"; + + samplerNames[0] = "$backBuffer"; + + pixVersion = 3.0; +}; + singleton PostEffect( SMAAPostFX ) { - enabled = false; - + enabled = false; allowReflectPass = false; - renderTime = "PFXAfterDiffuse"; - + renderTime = "PFXBeforeBin"; + renderBin = "EditorBin"; texture[0] = "$backBuffer"; - texture[1] = "#deferred"; - - target = "#edgesPass"; + target = "#BBtoGamma"; + renderPriority = 1; targetClear = PFXTargetClear_OnDraw; targetClearColor = "0 0 0 0"; + shader = BBtoGammaShader; + stateBlock = BBtoGamma_StateBlock; - shader = SMAA_Edge_D_Shader; - stateBlock = SMAA_Edge_D_StateBlock; + singleton PostEffect() + { + enabled = false; + allowReflectPass = false; + renderTime = "PFXAfterDiffuse"; + + texture[0] = "#BBtoGamma"; + texture[1] = "#deferred"; + + target = "#edgesPass"; + targetClear = PFXTargetClear_OnDraw; + targetClearColor = "0 0 0 0"; + + shader = SMAA_Edge_D_Shader; + stateBlock = SMAA_Edge_D_StateBlock; + }; singleton PostEffect() { internalName = "Edge Pass"; @@ -141,7 +177,7 @@ singleton PostEffect( SMAAPostFX ) { internalName = "BlendPass"; - texture[0] = "$backBuffer"; + texture[0] = "#BBtoGamma"; texture[1] = "#blendPass"; target = "$backBuffer"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/SMAA/SMAA_Neighbor_H_Blending_P.hlsl b/Templates/BaseGame/game/core/postFX/scripts/SMAA/SMAA_Neighbor_H_Blending_P.hlsl index 2511dc448..97a10168a 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/SMAA/SMAA_Neighbor_H_Blending_P.hlsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SMAA/SMAA_Neighbor_H_Blending_P.hlsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- #include "core/rendering/shaders/shaderModel.hlsl" - +#include "core/rendering/shaders/torque.hlsl" #include "SMAA_Params.hlsl" @@ -38,6 +38,6 @@ struct v_NHBlend float4 main( v_NHBlend IN ) : TORQUE_TARGET0 { //return float4(TORQUE_TEX2D(blendTex, IN.uv0)); - return SMAANeighborhoodBlendingPS(IN.uv0, IN.offset, texture_sceneTex, texture_blendTex); + return toLinear(SMAANeighborhoodBlendingPS(IN.uv0, IN.offset, texture_sceneTex, texture_blendTex)); } diff --git a/Templates/BaseGame/game/core/postFX/scripts/SMAA/gl/BBtoGamma.glsl b/Templates/BaseGame/game/core/postFX/scripts/SMAA/gl/BBtoGamma.glsl new file mode 100644 index 000000000..233773c9d --- /dev/null +++ b/Templates/BaseGame/game/core/postFX/scripts/SMAA/gl/BBtoGamma.glsl @@ -0,0 +1,31 @@ +//----------------------------------------------------------------------------- +// 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/torque.glsl" +#include "core/rendering/shaders/postFX/gl/postFx.glsl" + +uniform sampler2D backBuffer; +out vec4 OUT_col; + +void main() +{ + OUT_col= toGamma(texture(backBuffer, uv0)); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/core/postFX/scripts/SMAA/gl/SMAA_Neighbor_H_Blending_P.glsl b/Templates/BaseGame/game/core/postFX/scripts/SMAA/gl/SMAA_Neighbor_H_Blending_P.glsl index a615d1d19..9f04bdcf4 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/SMAA/gl/SMAA_Neighbor_H_Blending_P.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/SMAA/gl/SMAA_Neighbor_H_Blending_P.glsl @@ -20,7 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- #include "core/rendering/shaders/gl/hlslCompat.glsl" - +#include "core/rendering/shaders/gl/torque.glsl" #include "SMAA_Params.glsl" #define SMAA_INCLUDE_VS 0 @@ -41,6 +41,6 @@ out vec4 OUT_col; void main() { //OUT_col = vec4(texture(blendTex, uv0.xy)); - OUT_col= SMAANeighborhoodBlendingPS(uv0, offset, sceneTex, blendTex); + OUT_col= toLinear(SMAANeighborhoodBlendingPS(uv0, offset, sceneTex, blendTex)); }