mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-31 10:05:13 +00:00
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
This commit is contained in:
parent
72230e2124
commit
b54a03d388
5 changed files with 111 additions and 14 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue