From 752f94b11edd090d09b0a54ee0a79187cf0b0dc9 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 20 Sep 2022 17:01:42 -0500 Subject: [PATCH 1/4] ligh shader final review 1) prunes extraneous garbage variables from GFXStateBlockData 2) re-orgs texture slots for lights as follows to better support stateblock slots: 0-norm|depth buffer 1- shadowmap 2-taprotationtex 3-colorbuffer 4-maitinfobuffer 5-cookiemap (AL_ConvexLightState only) --- .../scripts/advancedLighting_Shaders.tscript | 40 ++++++++----------- .../lighting/advanced/gl/pointLightP.glsl | 16 +++----- .../lighting/advanced/gl/spotLightP.glsl | 14 +++---- .../lighting/advanced/gl/vectorLightP.glsl | 3 +- .../lighting/advanced/pointLightP.hlsl | 22 ++++------ .../shaders/lighting/advanced/softShadow.hlsl | 2 +- .../shaders/lighting/advanced/spotLightP.hlsl | 12 +++--- .../lighting/advanced/vectorLightP.hlsl | 7 ++-- 8 files changed, 49 insertions(+), 67 deletions(-) diff --git a/Templates/BaseGame/game/core/lighting/scripts/advancedLighting_Shaders.tscript b/Templates/BaseGame/game/core/lighting/scripts/advancedLighting_Shaders.tscript index 55100d729..4f17d4a68 100644 --- a/Templates/BaseGame/game/core/lighting/scripts/advancedLighting_Shaders.tscript +++ b/Templates/BaseGame/game/core/lighting/scripts/advancedLighting_Shaders.tscript @@ -43,10 +43,10 @@ singleton GFXStateBlockData( AL_VectorLightState ) samplersDefined = true; samplerStates[0] = SamplerClampPoint; // G-buffer - mSamplerNames[0] = "deferredBuffer"; samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not change this to linear, as all cards can not filter equally.) - mSamplerNames[1] = "shadowMap"; - samplerStates[2] = SamplerWrapPoint; // Random Direction Map + samplerStates[3] = SamplerWrapPoint; // gTapRotationTex Random Direction Map + samplerStates[4] = SamplerClampPoint; // colorBuffer + samplerStates[5] = SamplerClampPoint; // matInfoBuffer cullDefined = true; cullMode = GFXCullNone; @@ -68,9 +68,8 @@ singleton shaderData( AL_VectorLightShader ) samplerNames[0] = "$deferredBuffer"; samplerNames[1] = "$shadowMap"; samplerNames[2] = "$gTapRotationTex"; - samplerNames[3] = "$lightBuffer"; - samplerNames[4] = "$colorBuffer"; - samplerNames[5] = "$matInfoBuffer"; + samplerNames[3] = "$colorBuffer"; + samplerNames[4] = "$matInfoBuffer"; pixVersion = 3.0; }; @@ -82,7 +81,6 @@ singleton CustomMaterial( AL_VectorLightMaterial ) sampler["deferredBuffer"] = "#deferred"; sampler["shadowMap"] = "$dynamiclight"; - sampler["lightBuffer"] = "#specularLighting"; sampler["colorBuffer"] = "#color"; sampler["matInfoBuffer"] = "#matinfo"; @@ -115,11 +113,11 @@ singleton GFXStateBlockData( AL_ConvexLightState ) samplersDefined = true; samplerStates[0] = SamplerClampPoint; // G-buffer - mSamplerNames[0] = "deferredBuffer"; samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not use linear, these are perspective projections) - mSamplerNames[1] = "shadowMap"; - samplerStates[3] = SamplerClampLinear; // Cookie Map - samplerStates[4] = SamplerWrapPoint; // Random Direction Map + samplerStates[2] = SamplerWrapPoint; // gTapRotationTex Random Direction Map + samplerStates[3] = SamplerClampPoint; // colorBuffer + samplerStates[4] = SamplerClampPoint; // matInfoBuffer + samplerStates[5] = SamplerClampLinear; // Cookie Map cullDefined = true; cullMode = GFXCullCW; @@ -140,11 +138,10 @@ singleton shaderData( AL_PointLightShader ) samplerNames[0] = "$deferredBuffer"; samplerNames[1] = "$shadowMap"; - samplerNames[2] = "$cookieMap"; - samplerNames[3] = "$gTapRotationTex"; - samplerNames[4] = "$lightBuffer"; - samplerNames[5] = "$colorBuffer"; - samplerNames[6] = "$matInfoBuffer"; + samplerNames[2] = "$gTapRotationTex"; + samplerNames[3] = "$colorBuffer"; + samplerNames[4] = "$matInfoBuffer"; + samplerNames[5] = "$cookieMap"; pixVersion = 3.0; }; @@ -157,7 +154,6 @@ singleton CustomMaterial( AL_PointLightMaterial ) sampler["deferredBuffer"] = "#deferred"; sampler["shadowMap"] = "$dynamiclight"; sampler["cookieMap"] = "$dynamiclightmask"; - sampler["lightBuffer"] = "#specularLighting"; sampler["colorBuffer"] = "#color"; sampler["matInfoBuffer"] = "#matinfo"; @@ -177,11 +173,10 @@ singleton shaderData( AL_SpotLightShader ) samplerNames[0] = "$deferredBuffer"; samplerNames[1] = "$shadowMap"; - samplerNames[2] = "$cookieMap"; - samplerNames[3] = "$gTapRotationTex"; - samplerNames[4] = "$lightBuffer"; - samplerNames[5] = "$colorBuffer"; - samplerNames[6] = "$matInfoBuffer"; + samplerNames[2] = "$gTapRotationTex"; + samplerNames[3] = "$colorBuffer"; + samplerNames[4] = "$matInfoBuffer"; + samplerNames[5] = "$cookieMap"; pixVersion = 3.0; }; @@ -194,7 +189,6 @@ singleton CustomMaterial( AL_SpotLightMaterial ) sampler["deferredBuffer"] = "#deferred"; sampler["shadowMap"] = "$dynamiclight"; sampler["cookieMap"] = "$dynamiclightmask"; - sampler["lightBuffer"] = "#specularLighting"; sampler["colorBuffer"] = "#color"; sampler["matInfoBuffer"] = "#matinfo"; diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/pointLightP.glsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/pointLightP.glsl index 310a84a0a..e40ca8b29 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/pointLightP.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/pointLightP.glsl @@ -26,7 +26,6 @@ #include "farFrustumQuad.glsl" #include "../../../gl/lighting.glsl" #include "../../shadowMap/shadowMapIO_GLSL.h" -#include "softShadow.glsl" #include "../../../gl/torque.glsl" #line 31 @@ -35,12 +34,6 @@ in vec4 ssPos; in vec4 vsEyeDir; in vec4 color; -#ifdef USE_COOKIE_TEX - -/// The texture for cookie rendering. -uniform samplerCube cookieMap; - -#endif #ifdef SHADOW_CUBE @@ -106,16 +99,19 @@ uniform samplerCube cookieMap; #endif uniform sampler2D deferredBuffer; - #ifdef SHADOW_CUBE uniform samplerCube shadowMap; #else uniform sampler2D shadowMap; #endif - -uniform sampler2D lightBuffer; +//contains gTapRotationTex sampler +#include "softShadow.glsl" uniform sampler2D colorBuffer; uniform sampler2D matInfoBuffer; +#ifdef USE_COOKIE_TEX +/// The texture for cookie rendering. +uniform samplerCube cookieMap; +#endif uniform vec4 rtParams0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/spotLightP.glsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/spotLightP.glsl index 5d0079afa..b6a29b72e 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/spotLightP.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/spotLightP.glsl @@ -24,7 +24,6 @@ #include "farFrustumQuad.glsl" #include "../../shadowMap/shadowMapIO_GLSL.h" #include "shadergen:/autogenConditioners.h" -#include "softShadow.glsl" #include "../../../gl/lighting.glsl" #include "../../../gl/torque.glsl" @@ -33,17 +32,16 @@ in vec4 ssPos; in vec4 vsEyeDir; in vec4 color; -#ifdef USE_COOKIE_TEX - -/// The texture for cookie rendering. -uniform sampler2D cookieMap; - -#endif - uniform sampler2D deferredBuffer; uniform sampler2D shadowMap; +//contains gTapRotationTex sampler +#include "softShadow.glsl" uniform sampler2D colorBuffer; uniform sampler2D matInfoBuffer; +#ifdef USE_COOKIE_TEX +/// The texture for cookie rendering. +uniform sampler2D cookieMap; +#endif uniform vec4 rtParams0; diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/vectorLightP.glsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/vectorLightP.glsl index 558599423..a2657fb23 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/vectorLightP.glsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/vectorLightP.glsl @@ -26,7 +26,6 @@ #include "../../../gl/torque.glsl" #include "../../../gl/lighting.glsl" #include "../../shadowMap/shadowMapIO_GLSL.h" -#include "softShadow.glsl" #line 30 in vec4 hpos; in vec2 uv0; @@ -35,6 +34,8 @@ in vec3 vsEyeRay; uniform sampler2D deferredBuffer; uniform sampler2D shadowMap; +//contains gTapRotationTex sampler +#include "softShadow.glsl" uniform sampler2D colorBuffer; uniform sampler2D matInfoBuffer; diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/pointLightP.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/pointLightP.hlsl index 05a29d66d..60d2f2d00 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/pointLightP.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/pointLightP.hlsl @@ -25,7 +25,6 @@ #include "farFrustumQuad.hlsl" #include "../../lighting.hlsl" #include "../shadowMap/shadowMapIO_HLSL.h" -#include "softShadow.hlsl" #include "../../torque.hlsl" struct ConvexConnectP @@ -36,14 +35,6 @@ struct ConvexConnectP float4 vsEyeDir : TEXCOORD2; }; -#ifdef USE_COOKIE_TEX - -/// The texture for cookie rendering. -TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 3); - -#endif - - #ifdef SHADOW_CUBE float3 decodeShadowCoord( float3 shadowCoord ) @@ -107,16 +98,19 @@ TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 3); #endif TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0); - #ifdef SHADOW_CUBE TORQUE_UNIFORM_SAMPLERCUBE(shadowMap, 1); #else TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1); #endif - -TORQUE_UNIFORM_SAMPLER2D(lightBuffer, 5); -TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 6); -TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 7); +//contains gTapRotationTex sampler +#include "softShadow.hlsl" +TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3); +TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4); +#ifdef USE_COOKIE_TEX +/// The texture for cookie rendering. +TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 5); +#endif uniform float4 rtParams0; uniform float4 lightColor; diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/softShadow.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/softShadow.hlsl index d98fe4d65..ccc90f009 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/softShadow.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/softShadow.hlsl @@ -70,7 +70,7 @@ static float2 sNonUniformTaps[NUM_PRE_TAPS] = /// The texture used to do per-pixel pseudorandom /// rotations of the filter taps. -TORQUE_UNIFORM_SAMPLER2D(gTapRotationTex, 3); +TORQUE_UNIFORM_SAMPLER2D(gTapRotationTex, 2); float softShadow_sampleTaps( TORQUE_SAMPLER2D(shadowMap1), float2 sinCos, diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/spotLightP.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/spotLightP.hlsl index 15b4b4e37..a0459bfb2 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/spotLightP.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/spotLightP.hlsl @@ -26,7 +26,6 @@ #include "farFrustumQuad.hlsl" #include "../../lighting.hlsl" #include "../shadowMap/shadowMapIO_HLSL.h" -#include "softShadow.hlsl" #include "../../torque.hlsl" struct ConvexConnectP @@ -39,16 +38,15 @@ struct ConvexConnectP TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0); TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1); - +//contains gTapRotationTex sampler +#include "softShadow.hlsl" +TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3); +TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4); #ifdef USE_COOKIE_TEX - /// The texture for cookie rendering. -TORQUE_UNIFORM_SAMPLER2D(cookieMap, 2); +TORQUE_UNIFORM_SAMPLER2D(cookieMap, 5); #endif -TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 5); -TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 6); - uniform float4 rtParams0; uniform float lightBrightness; diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/vectorLightP.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/vectorLightP.hlsl index d99544dca..6046d6f00 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/vectorLightP.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/vectorLightP.hlsl @@ -27,13 +27,14 @@ #include "../../torque.hlsl" #include "../../lighting.hlsl" #include "../shadowMap/shadowMapIO_HLSL.h" -#include "softShadow.hlsl" TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0); TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1); -TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 5); -TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 6); +//contains gTapRotationTex sampler +#include "softShadow.hlsl" +TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 3); +TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 4); uniform float lightBrightness; uniform float3 lightDirection; From b54a03d38899d162dfbdcbde51570df6a744759a Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 20 Sep 2022 19:12:21 -0500 Subject: [PATCH 2/4] fix smaa backbuffer colorspace as we do not at time of writing have a specifier for what colorspace to load a backbuffer in, we leverage the old toGamma and toLinear macros to upshift the backbuffer for lumina edge detection via a clone --- .../core/postFX/scripts/SMAA/BBtoGamma.hlsl | 30 ++++++++++ .../postFX/scripts/SMAA/SMAAPostFX.tscript | 56 +++++++++++++++---- .../SMAA/SMAA_Neighbor_H_Blending_P.hlsl | 4 +- .../postFX/scripts/SMAA/gl/BBtoGamma.glsl | 31 ++++++++++ .../SMAA/gl/SMAA_Neighbor_H_Blending_P.glsl | 4 +- 5 files changed, 111 insertions(+), 14 deletions(-) create mode 100644 Templates/BaseGame/game/core/postFX/scripts/SMAA/BBtoGamma.hlsl create mode 100644 Templates/BaseGame/game/core/postFX/scripts/SMAA/gl/BBtoGamma.glsl 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)); } From be0f3097d695f0c153cfd292a02c81eb4976c456 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 20 Sep 2022 19:58:02 -0500 Subject: [PATCH 3/4] $platform $= "macos" is used throughout the codebase --- Engine/source/platformMac/macMain.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/platformMac/macMain.mm b/Engine/source/platformMac/macMain.mm index 19fc2b0e2..e906ec3ff 100644 --- a/Engine/source/platformMac/macMain.mm +++ b/Engine/source/platformMac/macMain.mm @@ -37,7 +37,7 @@ void Platform::init() Con::printf("Initializing platform..."); // Set the platform variable for the scripts - Con::setVariable( "$platform", "MacOSX" ); + Con::setVariable( "$platform", "macos" ); Input::init(); From f419227d30b40baedc49193b72c4cb890e52fa34 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 22 Sep 2022 13:04:42 -0500 Subject: [PATCH 4/4] conform gl to dx --- .../BaseGame/game/core/postFX/scripts/HDR/HDR_finalPass.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_finalPass.glsl b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_finalPass.glsl index 43e8a2f2e..9e8b66597 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_finalPass.glsl +++ b/Templates/BaseGame/game/core/postFX/scripts/HDR/HDR_finalPass.glsl @@ -87,7 +87,7 @@ vec3 Tonemap(vec3 x) //Linear Tonemap else if (g_fTonemapMode == 5.0) { - x = TO_Linear(x); + x = toLinear(TO_Linear(toGamma(x))); } return x;