Full Template for ticket #1

This commit is contained in:
DavidWyand-GG 2012-09-19 11:54:25 -04:00
parent 74f265b3b3
commit f439dc8dcd
2150 changed files with 286240 additions and 0 deletions

View file

@ -0,0 +1,52 @@
//-----------------------------------------------------------------------------
// 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"
// These are set by the game engine.
uniform sampler2D shrunkSampler : register(S0); // Output of DofDownsample()
uniform sampler2D blurredSampler : register(S1); // Blurred version of the shrunk sampler
// This is the pixel shader function that calculates the actual
// value used for the near circle of confusion.
// "texCoords" are 0 at the bottom left pixel and 1 at the top right.
float4 main( PFXVertToPix IN ) : COLOR
{
float3 color;
float coc;
half4 blurred;
half4 shrunk;
shrunk = tex2D( shrunkSampler, IN.uv0 );
blurred = tex2D( blurredSampler, IN.uv1 );
color = shrunk.rgb;
//coc = shrunk.a;
//coc = blurred.a;
//coc = max( blurred.a, shrunk.a );
coc = 2 * max( blurred.a, shrunk.a ) - shrunk.a;
//return float4( coc.rrr, 1.0 );
//return float4( color, 1.0 );
return float4( color, coc );
//return float4( 1.0, 0.0, 1.0, 1.0 );
}

View file

@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
// 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 = IN.uv;
OUT.uv1 = IN.uv;
OUT.uv2 = IN.uv;
OUT.uv3 = IN.uv;
*/
/*
OUT.hpos = IN.pos;
OUT.uv0 = IN.uv + rtParams0.xy;
OUT.uv1 = IN.uv + rtParams1.xy;
OUT.uv2 = IN.uv + rtParams2.xy;
OUT.uv3 = IN.uv + rtParams3.xy;
*/
/*
OUT.hpos = IN.pos;
OUT.uv0 = IN.uv * rtParams0.zw;
OUT.uv1 = IN.uv * rtParams1.zw;
OUT.uv2 = IN.uv * rtParams2.zw;
OUT.uv3 = IN.uv * rtParams3.zw;
*/
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;
}

View file

@ -0,0 +1,135 @@
//-----------------------------------------------------------------------------
// 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 "shadergen:/autogenConditioners.h"
// These are set by the game engine.
// The render target size is one-quarter the scene rendering size.
uniform sampler2D colorSampler : register(S0);
uniform sampler2D depthSampler : register(S1);
uniform float2 dofEqWorld;
uniform float depthOffset;
uniform float2 targetSize;
uniform float maxWorldCoC;
//uniform float2 dofEqWeapon;
//uniform float2 dofRowDelta; // float2( 0, 0.25 / renderTargetHeight )
struct Pixel
{
float4 position : POSITION;
float2 tcColor0 : TEXCOORD0;
float2 tcColor1 : TEXCOORD1;
float2 tcDepth0 : TEXCOORD2;
float2 tcDepth1 : TEXCOORD3;
float2 tcDepth2 : TEXCOORD4;
float2 tcDepth3 : TEXCOORD5;
};
half4 main( Pixel IN ) : COLOR
{
//return float4( 1.0, 0.0, 1.0, 1.0 );
float2 dofRowDelta = float2( 0, 0.25 / targetSize.y );
//float2 dofEqWorld = float2( -60, 1.0 );
half3 color;
half maxCoc;
float4 depth;
half4 viewCoc;
half4 sceneCoc;
half4 curCoc;
half4 coc;
float2 rowOfs[4];
// "rowOfs" reduces how many moves PS2.0 uses to emulate swizzling.
rowOfs[0] = 0;
rowOfs[1] = dofRowDelta.xy;
rowOfs[2] = dofRowDelta.xy * 2;
rowOfs[3] = dofRowDelta.xy * 3;
// Use bilinear filtering to average 4 color samples for free.
color = 0;
color += tex2D( colorSampler, IN.tcColor0.xy + rowOfs[0] ).rgb;
color += tex2D( colorSampler, IN.tcColor1.xy + rowOfs[0] ).rgb;
color += tex2D( colorSampler, IN.tcColor0.xy + rowOfs[2] ).rgb;
color += tex2D( colorSampler, IN.tcColor1.xy + rowOfs[2] ).rgb;
color /= 4;
// Process 4 samples at a time to use vector hardware efficiently.
// The CoC will be 1 if the depth is negative, so use "min" to pick
// between "sceneCoc" and "viewCoc".
for ( int i = 0; i < 4; i++ )
{
depth[0] = prepassUncondition( depthSampler, float4( IN.tcDepth0.xy + rowOfs[i], 0, 0 ) ).w;
depth[1] = prepassUncondition( depthSampler, float4( IN.tcDepth1.xy + rowOfs[i], 0, 0 ) ).w;
depth[2] = prepassUncondition( depthSampler, float4( IN.tcDepth2.xy + rowOfs[i], 0, 0 ) ).w;
depth[3] = prepassUncondition( depthSampler, float4( IN.tcDepth3.xy + rowOfs[i], 0, 0 ) ).w;
coc[i] = clamp( dofEqWorld.x * depth + dofEqWorld.y, 0.0, maxWorldCoC );
}
/*
depth[0] = tex2D( depthSampler, pixel.tcDepth0.xy + rowOfs[0] ).r;
depth[1] = tex2D( depthSampler, pixel.tcDepth1.xy + rowOfs[0] ).r;
depth[2] = tex2D( depthSampler, pixel.tcDepth2.xy + rowOfs[0] ).r;
depth[3] = tex2D( depthSampler, pixel.tcDepth3.xy + rowOfs[0] ).r;
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
curCoc = min( viewCoc, sceneCoc );
coc = curCoc;
depth[0] = tex2D( depthSampler, pixel.tcDepth0.xy + rowOfs[1] ).r;
depth[1] = tex2D( depthSampler, pixel.tcDepth1.xy + rowOfs[1] ).r;
depth[2] = tex2D( depthSampler, pixel.tcDepth2.xy + rowOfs[1] ).r;
depth[3] = tex2D( depthSampler, pixel.tcDepth3.xy + rowOfs[1] ).r;
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
curCoc = min( viewCoc, sceneCoc );
coc = max( coc, curCoc );
depth[0] = tex2D( depthSampler, pixel.tcDepth0.xy + rowOfs[2] ).r;
depth[1] = tex2D( depthSampler, pixel.tcDepth1.xy + rowOfs[2] ).r;
depth[2] = tex2D( depthSampler, pixel.tcDepth2.xy + rowOfs[2] ).r;
depth[3] = tex2D( depthSampler, pixel.tcDepth3.xy + rowOfs[2] ).r;
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
curCoc = min( viewCoc, sceneCoc );
coc = max( coc, curCoc );
depth[0] = tex2D( depthSampler, pixel.tcDepth0.xy + rowOfs[3] ).r;
depth[1] = tex2D( depthSampler, pixel.tcDepth1.xy + rowOfs[3] ).r;
depth[2] = tex2D( depthSampler, pixel.tcDepth2.xy + rowOfs[3] ).r;
depth[3] = tex2D( depthSampler, pixel.tcDepth3.xy + rowOfs[3] ).r;
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
curCoc = min( viewCoc, sceneCoc );
coc = max( coc, curCoc );
*/
maxCoc = max( max( coc[0], coc[1] ), max( coc[2], coc[3] ) );
//return half4( 1.0, 0.0, 1.0, 1.0 );
return half4( color, maxCoc );
//return half4( color, 1.0f );
//return half4( maxCoc.rrr, 1.0 );
}

View file

@ -0,0 +1,61 @@
//-----------------------------------------------------------------------------
// 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"
struct Vert
{
float4 pos : POSITION;
float2 tc : TEXCOORD0;
float3 wsEyeRay : TEXCOORD1;
};
struct Pixel
{
float4 position : POSITION;
float2 tcColor0 : TEXCOORD0;
float2 tcColor1 : TEXCOORD1;
float2 tcDepth0 : TEXCOORD2;
float2 tcDepth1 : TEXCOORD3;
float2 tcDepth2 : TEXCOORD4;
float2 tcDepth3 : TEXCOORD5;
};
uniform float4 rtParams0;
uniform float2 oneOverTargetSize;
Pixel main( Vert IN )
{
Pixel OUT;
OUT.position = IN.pos;
float2 uv = viewportCoordToRenderTarget( IN.tc, rtParams0 );
//OUT.position = mul( IN.pos, modelView );
OUT.tcColor1 = uv + float2( +1.0, -0.0 ) * oneOverTargetSize;
OUT.tcColor0 = uv + float2( -1.0, -0.0 ) * oneOverTargetSize;
OUT.tcDepth0 = uv + float2( -0.5, -0.0 ) * oneOverTargetSize;
OUT.tcDepth1 = uv + float2( -1.5, -0.0 ) * oneOverTargetSize;
OUT.tcDepth2 = uv + float2( +1.5, -0.0 ) * oneOverTargetSize;
OUT.tcDepth3 = uv + float2( +2.5, -0.0 ) * oneOverTargetSize;
return OUT;
}

View file

@ -0,0 +1,144 @@
//-----------------------------------------------------------------------------
// 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 "shadergen:/autogenConditioners.h"
#include "./../postFx.hlsl"
uniform sampler2D colorSampler : register(S0); // Original source image
uniform sampler2D smallBlurSampler : register(S1); // Output of SmallBlurPS()
uniform sampler2D largeBlurSampler : register(S2); // Blurred output of DofDownsample()
uniform sampler2D depthSampler : register(S3); //
uniform float2 oneOverTargetSize;
uniform float4 dofLerpScale;
uniform float4 dofLerpBias;
uniform float3 dofEqFar;
uniform float maxFarCoC;
//static float d0 = 0.1;
//static float d1 = 0.1;
//static float d2 = 0.8;
//static float4 dofLerpScale = float4( -1.0 / d0, -1.0 / d1, -1.0 / d2, 1.0 / d2 );
//static float4 dofLerpBias = float4( 1.0, (1.0 - d2) / d1, 1.0 / d2, (d2 - 1.0) / d2 );
//static float3 dofEqFar = float3( 2.0, 0.0, 1.0 );
float4 tex2Doffset( sampler2D s, float2 tc, float2 offset )
{
return tex2D( s, tc + offset * oneOverTargetSize );
}
half3 GetSmallBlurSample( float2 tc )
{
half3 sum;
const half weight = 4.0 / 17;
sum = 0; // Unblurred sample done by alpha blending
//sum += weight * tex2Doffset( colorSampler, tc, float2( 0, 0 ) ).rgb;
sum += weight * tex2Doffset( colorSampler, tc, float2( +0.5, -1.5 ) ).rgb;
sum += weight * tex2Doffset( colorSampler, tc, float2( -1.5, -0.5 ) ).rgb;
sum += weight * tex2Doffset( colorSampler, tc, float2( -0.5, +1.5 ) ).rgb;
sum += weight * tex2Doffset( colorSampler, tc, float2( +1.5, +0.5 ) ).rgb;
return sum;
}
half4 InterpolateDof( half3 small, half3 med, half3 large, half t )
{
//t = 2;
half4 weights;
half3 color;
half alpha;
// Efficiently calculate the cross-blend weights for each sample.
// Let the unblurred sample to small blur fade happen over distance
// d0, the small to medium blur over distance d1, and the medium to
// large blur over distance d2, where d0 + d1 + d2 = 1.
//float4 dofLerpScale = float4( -1 / d0, -1 / d1, -1 / d2, 1 / d2 );
//float4 dofLerpBias = float4( 1, (1 d2) / d1, 1 / d2, (d2 1) / d2 );
weights = saturate( t * dofLerpScale + dofLerpBias );
weights.yz = min( weights.yz, 1 - weights.xy );
// Unblurred sample with weight "weights.x" done by alpha blending
color = weights.y * small + weights.z * med + weights.w * large;
//color = med;
alpha = dot( weights.yzw, half3( 16.0 / 17, 1.0, 1.0 ) );
//alpha = 0.0;
return half4( color, alpha );
}
half4 main( PFXVertToPix IN ) : COLOR
{
//return half4( 1,0,1,1 );
//return half4( tex2D( colorSampler, IN.uv0 ).rgb, 1.0 );
//return half4( tex2D( colorSampler, texCoords ).rgb, 0 );
half3 small;
half4 med;
half3 large;
half depth;
half nearCoc;
half farCoc;
half coc;
small = GetSmallBlurSample( IN.uv0 );
//small = half3( 1,0,0 );
//return half4( small, 1.0 );
med = tex2D( smallBlurSampler, IN.uv1 );
//med.rgb = half3( 0,1,0 );
//return half4(med.rgb, 0.0);
large = tex2D( largeBlurSampler, IN.uv2 ).rgb;
//large = half3( 0,0,1 );
//return large;
//return half4(large.rgb,1.0);
nearCoc = med.a;
// Since the med blur texture is screwed up currently
// replace it with the large, but this needs to be fixed.
//med.rgb = large;
//nearCoc = 0;
depth = prepassUncondition( depthSampler, float4( IN.uv3, 0, 0 ) ).w;
//return half4(depth.rrr,1);
//return half4(nearCoc.rrr,1.0);
if (depth > 0.999 )
{
coc = nearCoc; // We don't want to blur the sky.
//coc = 0;
}
else
{
// dofEqFar.x and dofEqFar.y specify the linear ramp to convert
// to depth for the distant out-of-focus region.
// dofEqFar.z is the ratio of the far to the near blur radius.
farCoc = clamp( dofEqFar.x * depth + dofEqFar.y, 0.0, maxFarCoC );
coc = max( nearCoc, farCoc * dofEqFar.z );
//coc = nearCoc;
}
//coc = nearCoc;
//coc = farCoc;
//return half4(coc.rrr,0.5);
//return half4(farCoc.rrr,1);
//return half4(nearCoc.rrr,1);
//return half4( 1,0,1,0 );
return InterpolateDof( small, med.rgb, large, coc );
}

View file

@ -0,0 +1,72 @@
//-----------------------------------------------------------------------------
// 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;
uniform float2 oneOverTargetSize;
PFXVertToPix main( PFXVert IN )
{
PFXVertToPix OUT;
/*
OUT.hpos = IN.pos;
OUT.uv0 = IN.uv;
OUT.uv1 = IN.uv;
OUT.uv2 = IN.uv;
OUT.uv3 = IN.uv;
*/
/*
OUT.hpos = IN.pos;
OUT.uv0 = IN.uv + rtParams0.xy;
OUT.uv1 = IN.uv + rtParams1.xy;
OUT.uv2 = IN.uv + rtParams2.xy;
OUT.uv3 = IN.uv + rtParams3.xy;
*/
/*
OUT.hpos = IN.pos;
OUT.uv0 = IN.uv * rtParams0.zw;
OUT.uv1 = IN.uv * rtParams1.zw;
OUT.uv2 = IN.uv * rtParams2.zw;
OUT.uv3 = IN.uv * rtParams3.zw;
*/
OUT.hpos = IN.pos;
OUT.uv0 = viewportCoordToRenderTarget( IN.uv, rtParams0 );
OUT.uv1 = viewportCoordToRenderTarget( IN.uv, rtParams1 ); // + float2( -5, 1 ) * oneOverTargetSize;
OUT.uv2 = viewportCoordToRenderTarget( IN.uv, rtParams2 );
OUT.uv3 = viewportCoordToRenderTarget( IN.uv, rtParams3 );
OUT.wsEyeRay = IN.wsEyeRay;
return OUT;
}

View file

@ -0,0 +1,63 @@
//-----------------------------------------------------------------------------
// 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"
uniform sampler2D diffuseMap : register(S0);
struct VertToPix
{
float4 hpos : POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
float2 uv2 : TEXCOORD2;
float2 uv3 : TEXCOORD3;
float2 uv4 : TEXCOORD4;
float2 uv5 : TEXCOORD5;
float2 uv6 : TEXCOORD6;
float2 uv7 : TEXCOORD7;
};
float4 main( VertToPix IN ) : COLOR
{
float4 kernel = float4( 0.175, 0.275, 0.375, 0.475 ) * 0.5 / 1.3; //25f;
float4 OUT = 0;
OUT += tex2D( diffuseMap, IN.uv0 ) * kernel.x;
OUT += tex2D( diffuseMap, IN.uv1 ) * kernel.y;
OUT += tex2D( diffuseMap, IN.uv2 ) * kernel.z;
OUT += tex2D( diffuseMap, IN.uv3 ) * kernel.w;
OUT += tex2D( diffuseMap, IN.uv4 ) * kernel.x;
OUT += tex2D( diffuseMap, IN.uv5 ) * kernel.y;
OUT += tex2D( diffuseMap, IN.uv6 ) * kernel.z;
OUT += tex2D( diffuseMap, IN.uv7 ) * kernel.w;
// Calculate a lumenance value in the alpha so we
// can use alpha test to save fillrate.
//float3 rgb2lum = float3( 0.30, 0.59, 0.11 );
//OUT.a = dot( OUT.rgb, rgb2lum );
return OUT;
}

View file

@ -0,0 +1,80 @@
//-----------------------------------------------------------------------------
// 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 float2 texSize0;
uniform float4 rtParams0;
uniform float2 oneOverTargetSize;
struct VertToPix
{
float4 hpos : POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
float2 uv2 : TEXCOORD2;
float2 uv3 : TEXCOORD3;
float2 uv4 : TEXCOORD4;
float2 uv5 : TEXCOORD5;
float2 uv6 : TEXCOORD6;
float2 uv7 : TEXCOORD7;
};
VertToPix main( PFXVert IN )
{
VertToPix OUT;
OUT.hpos = IN.pos;
IN.uv = viewportCoordToRenderTarget( IN.uv, rtParams0 );
// I don't know why this offset is necessary, but it is.
//IN.uv = IN.uv * oneOverTargetSize;
OUT.uv0 = IN.uv + ( ( BLUR_DIR * 3.5f ) / texSize0 );
OUT.uv1 = IN.uv + ( ( BLUR_DIR * 2.5f ) / texSize0 );
OUT.uv2 = IN.uv + ( ( BLUR_DIR * 1.5f ) / texSize0 );
OUT.uv3 = IN.uv + ( ( BLUR_DIR * 0.5f ) / texSize0 );
OUT.uv4 = IN.uv - ( ( BLUR_DIR * 3.5f ) / texSize0 );
OUT.uv5 = IN.uv - ( ( BLUR_DIR * 2.5f ) / texSize0 );
OUT.uv6 = IN.uv - ( ( BLUR_DIR * 1.5f ) / texSize0 );
OUT.uv7 = IN.uv - ( ( BLUR_DIR * 0.5f ) / texSize0 );
/*
OUT.uv0 = viewportCoordToRenderTarget( OUT.uv0, rtParams0 );
OUT.uv1 = viewportCoordToRenderTarget( OUT.uv1, rtParams0 );
OUT.uv2 = viewportCoordToRenderTarget( OUT.uv2, rtParams0 );
OUT.uv3 = viewportCoordToRenderTarget( OUT.uv3, rtParams0 );
OUT.uv4 = viewportCoordToRenderTarget( OUT.uv4, rtParams0 );
OUT.uv5 = viewportCoordToRenderTarget( OUT.uv5, rtParams0 );
OUT.uv6 = viewportCoordToRenderTarget( OUT.uv6, rtParams0 );
OUT.uv7 = viewportCoordToRenderTarget( OUT.uv7, rtParams0 );
*/
return OUT;
}

View file

@ -0,0 +1,70 @@
//-----------------------------------------------------------------------------
// 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 = IN.uv;
OUT.uv1 = IN.uv;
OUT.uv2 = IN.uv;
OUT.uv3 = IN.uv;
*/
/*
OUT.hpos = IN.pos;
OUT.uv0 = IN.uv + rtParams0.xy;
OUT.uv1 = IN.uv + rtParams1.xy;
OUT.uv2 = IN.uv + rtParams2.xy;
OUT.uv3 = IN.uv + rtParams3.xy;
*/
/*
OUT.hpos = IN.pos;
OUT.uv0 = IN.uv * rtParams0.zw;
OUT.uv1 = IN.uv * rtParams1.zw;
OUT.uv2 = IN.uv * rtParams2.zw;
OUT.uv3 = IN.uv * rtParams3.zw;
*/
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;
}

View file

@ -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.
//-----------------------------------------------------------------------------
// This vertex and pixel shader applies a 3 x 3 blur to the image in
// colorMapSampler, which is the same size as the render target.
// The sample weights are 1/16 in the corners, 2/16 on the edges,
// and 4/16 in the center.
uniform sampler2D colorSampler; // Output of DofNearCoc()
struct Pixel
{
float4 position : POSITION;
float4 texCoords : TEXCOORD0;
};
float4 main( Pixel IN ) : COLOR
{
float4 color;
color = 0.0;
color += tex2D( colorSampler, IN.texCoords.xz );
color += tex2D( colorSampler, IN.texCoords.yz );
color += tex2D( colorSampler, IN.texCoords.xw );
color += tex2D( colorSampler, IN.texCoords.yw );
return color / 4.0;
}

View file

@ -0,0 +1,56 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
// This vertex and pixel shader applies a 3 x 3 blur to the image in
// colorMapSampler, which is the same size as the render target.
// The sample weights are 1/16 in the corners, 2/16 on the edges,
// and 4/16 in the center.
#include "./../postFx.hlsl"
#include "./../../torque.hlsl"
struct Vert
{
float4 position : POSITION;
float2 texCoords : TEXCOORD0;
};
struct Pixel
{
float4 position : POSITION;
float4 texCoords : TEXCOORD0;
};
uniform float2 oneOverTargetSize;
uniform float4 rtParams0;
Pixel main( Vert IN )
{
Pixel OUT;
const float4 halfPixel = { -0.5, 0.5, -0.5, 0.5 };
OUT.position = IN.position; //Transform_ObjectToClip( IN.position );
//float2 uv = IN.texCoords + rtParams0.xy;
float2 uv = viewportCoordToRenderTarget( IN.texCoords, rtParams0 );
OUT.texCoords = uv.xxyy + halfPixel * oneOverTargetSize.xxyy;
return OUT;
}