mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Full Template for ticket #1
This commit is contained in:
parent
74f265b3b3
commit
f439dc8dcd
2150 changed files with 286240 additions and 0 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 "../postFx.hlsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
float4 main( PFXVertToPix IN,
|
||||
uniform sampler2D edgeBuffer :register(S0) ) : COLOR0
|
||||
{
|
||||
return float4( tex2D( edgeBuffer, IN.uv0 ).rrr, 1.0 );
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../postFx.hlsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
float4 main( PFXVertToPix IN,
|
||||
uniform sampler2D edgeBuffer : register(S0),
|
||||
uniform sampler2D backBuffer : register(S1),
|
||||
uniform float2 targetSize : register(C0) ) : COLOR0
|
||||
{
|
||||
float2 pixelSize = 1.0 / targetSize;
|
||||
|
||||
// Sample edge buffer, bail if not on an edge
|
||||
float edgeSample = tex2D(edgeBuffer, IN.uv0).r;
|
||||
clip(edgeSample - 1e-6);
|
||||
|
||||
// Ok we're on an edge, so multi-tap sample, average, and return
|
||||
float2 offsets[9] = {
|
||||
float2( 0.0, 0.0),
|
||||
float2(-1.0, -1.0),
|
||||
float2( 0.0, -1.0),
|
||||
float2( 1.0, -1.0),
|
||||
float2( 1.0, 0.0),
|
||||
float2( 1.0, 1.0),
|
||||
float2( 0.0, 1.0),
|
||||
float2(-1.0, 1.0),
|
||||
float2(-1.0, 0.0),
|
||||
};
|
||||
|
||||
float4 accumColor = 0;
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
// Multiply the intensity of the edge, by the UV, so that things which maybe
|
||||
// aren't quite full edges get sub-pixel sampling to reduce artifacts
|
||||
|
||||
// Scaling offsets by 0.5 to reduce the range bluriness from extending to
|
||||
// far outward from the edge.
|
||||
|
||||
float2 offsetUV = IN.uv1 + edgeSample * ( offsets[i] * 0.5 ) * pixelSize;//rtWidthHeightInvWidthNegHeight.zw;
|
||||
//offsetUV *= 0.999;
|
||||
accumColor+= tex2D(backBuffer, offsetUV);
|
||||
}
|
||||
accumColor /= 9.0;
|
||||
|
||||
return accumColor;
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "./../postFx.hlsl"
|
||||
#include "./../../torque.hlsl"
|
||||
|
||||
|
||||
uniform float4 rtParams0;
|
||||
uniform float4 rtParams1;
|
||||
uniform float4 rtParams2;
|
||||
uniform float4 rtParams3;
|
||||
|
||||
PFXVertToPix main( PFXVert IN )
|
||||
{
|
||||
PFXVertToPix OUT;
|
||||
|
||||
OUT.hpos = IN.pos;
|
||||
OUT.uv0 = viewportCoordToRenderTarget( IN.uv, rtParams0 );
|
||||
OUT.uv1 = viewportCoordToRenderTarget( IN.uv, rtParams1 );
|
||||
OUT.uv2 = viewportCoordToRenderTarget( IN.uv, rtParams2 );
|
||||
OUT.uv3 = viewportCoordToRenderTarget( IN.uv, rtParams3 );
|
||||
|
||||
OUT.wsEyeRay = IN.wsEyeRay;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../postFx.hlsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
// GPU Gems 3, pg 443-444
|
||||
float GetEdgeWeight(float2 uv0, in sampler2D prepassBuffer, in float2 targetSize)
|
||||
{
|
||||
float2 offsets[9] = {
|
||||
float2( 0.0, 0.0),
|
||||
float2(-1.0, -1.0),
|
||||
float2( 0.0, -1.0),
|
||||
float2( 1.0, -1.0),
|
||||
float2( 1.0, 0.0),
|
||||
float2( 1.0, 1.0),
|
||||
float2( 0.0, 1.0),
|
||||
float2(-1.0, 1.0),
|
||||
float2(-1.0, 0.0),
|
||||
};
|
||||
|
||||
|
||||
float2 PixelSize = 1.0 / targetSize;
|
||||
|
||||
float Depth[9];
|
||||
float3 Normal[9];
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
float2 uv = uv0 + offsets[i] * PixelSize;
|
||||
float4 gbSample = prepassUncondition( prepassBuffer, uv );
|
||||
Depth[i] = gbSample.a;
|
||||
Normal[i] = gbSample.rgb;
|
||||
}
|
||||
|
||||
float4 Deltas1 = float4(Depth[1], Depth[2], Depth[3], Depth[4]);
|
||||
float4 Deltas2 = float4(Depth[5], Depth[6], Depth[7], Depth[8]);
|
||||
|
||||
Deltas1 = abs(Deltas1 - Depth[0]);
|
||||
Deltas2 = abs(Depth[0] - Deltas2);
|
||||
|
||||
float4 maxDeltas = max(Deltas1, Deltas2);
|
||||
float4 minDeltas = max(min(Deltas1, Deltas2), 0.00001);
|
||||
|
||||
float4 depthResults = step(minDeltas * 25.0, maxDeltas);
|
||||
|
||||
Deltas1.x = dot(Normal[1], Normal[0]);
|
||||
Deltas1.y = dot(Normal[2], Normal[0]);
|
||||
Deltas1.z = dot(Normal[3], Normal[0]);
|
||||
Deltas1.w = dot(Normal[4], Normal[0]);
|
||||
|
||||
Deltas2.x = dot(Normal[5], Normal[0]);
|
||||
Deltas2.y = dot(Normal[6], Normal[0]);
|
||||
Deltas2.z = dot(Normal[7], Normal[0]);
|
||||
Deltas2.w = dot(Normal[8], Normal[0]);
|
||||
|
||||
Deltas1 = abs(Deltas1 - Deltas2);
|
||||
|
||||
float4 normalResults = step(0.4, Deltas1);
|
||||
|
||||
normalResults = max(normalResults, depthResults);
|
||||
|
||||
return dot(normalResults, float4(1.0, 1.0, 1.0, 1.0)) * 0.25;
|
||||
}
|
||||
|
||||
float4 main( PFXVertToPix IN,
|
||||
uniform sampler2D prepassBuffer :register(S0),
|
||||
uniform float2 targetSize : register(C0) ) : COLOR0
|
||||
{
|
||||
return GetEdgeWeight(IN.uv0, prepassBuffer, targetSize );//rtWidthHeightInvWidthNegHeight.zw);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue