diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /KaplaDemo/externalIP/resources/AABox.cgfx | |
| download | physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip | |
Initial commit:
PhysX 3.4.0 Update @ 21294896
APEX 1.4.0 Update @ 21275617
[CL 21300167]
Diffstat (limited to 'KaplaDemo/externalIP/resources/AABox.cgfx')
| -rw-r--r-- | KaplaDemo/externalIP/resources/AABox.cgfx | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/KaplaDemo/externalIP/resources/AABox.cgfx b/KaplaDemo/externalIP/resources/AABox.cgfx new file mode 100644 index 00000000..abff4091 --- /dev/null +++ b/KaplaDemo/externalIP/resources/AABox.cgfx @@ -0,0 +1,141 @@ +//-------------------------------------------------------------------------------------- +// FroggyAA +// Author: Tristan Lorach +// Email: [email protected] +// +// Implementation of different downsampling methods for supersampled AA +// +// Copyright (c) NVIDIA Corporation. All rights reserved. +//-------------------------------------------------------------------------------------- +float2 SSTexelSize; +float blendFactor = 1.0; +sampler2D SSsampler = sampler_state +{ + minFilter = Linear; + magFilter = Linear; +}; +sampler2D DepthSSsampler = sampler_state +{ + minFilter = Linear; + magFilter = Linear; +}; + +struct v2fConnector { + float4 projCoord : POSITION; + float2 tex : TEXCOORD0; +}; +/////////////////////////////////////////////////////////////////////// +// Vertex programs +/////////////////////////////////////////////////////////////////////// +void vpPassThrough(float4 P : POSITION, float4 tc : TEXCOORD0, out v2fConnector v2f) +{ + v2f.tex = tc.xy; + v2f.projCoord = P; +} +struct PixelOut +{ +float4 color : COLOR; +float depth : DEPTH; +}; +/////////////////////////////////////////////////////////////////////// +// Fragment programs +/////////////////////////////////////////////////////////////////////// +// +// Simple down samling : just using the fact we are in between 4 texels. +// so the HW will do a bilinear filtering of these 4 samples +// +PixelOut DownSample1( float2 tc : TEXCOORD0 ) +{ + PixelOut pix; + pix.color = f4tex2D(SSsampler, tc); + pix.depth = f4tex2D(DepthSSsampler, tc).r; + return pix; +} +// +// add 4 fetches around the original filtered one +// each of the 4 additional fetches will also benefit from the HW bilinear filtering +// the offsets are chosen to benefit from various texels in a specific % amout +// +PixelOut DownSample2( float2 tc : TEXCOORD0 ) +{ + float4 tap0 = f4tex2D(SSsampler, tc); + float4 tap1 = f4tex2D(SSsampler, tc + SSTexelSize * float2( 0.4, 0.9 )); + float4 tap2 = f4tex2D(SSsampler, tc + SSTexelSize * float2( -0.4, -0.9 )); + float4 tap3 = f4tex2D(SSsampler, tc + SSTexelSize * float2( -0.9, 0.4 )); + float4 tap4 = f4tex2D(SSsampler, tc + SSTexelSize * float2( 0.9, -0.4 )); + float4 color = 0.2 * ( tap0 + tap1 + tap2 + tap3 + tap4 ); + + float tap0d = f4tex2D(DepthSSsampler, tc).r; + float tap1d = f4tex2D(DepthSSsampler, tc + SSTexelSize * float2( 0.4, 0.9 )).r; + float tap2d = f4tex2D(DepthSSsampler, tc + SSTexelSize * float2( -0.4, -0.9 )).r; + float tap3d = f4tex2D(DepthSSsampler, tc + SSTexelSize * float2( -0.9, 0.4 )).r; + float tap4d = f4tex2D(DepthSSsampler, tc + SSTexelSize * float2( 0.9, -0.4 )).r; + float depth = 0.2 * ( tap0d + tap1d + tap2d + tap3d + tap4d ); + + PixelOut pix; + pix.color = color; + pix.depth = depth; + return pix; +} +// +// same process are the previous one +// but we are using 2 kernels : one 'normal', one bigger (more blurry, then) +// we will lerp from one to the other depending on downsampled alpha from the bigger kernel +// this technique is good to blur 'high frequencies' marked by alpha =0, +// i.e thin primitives, like lines or sharp triangles +// +float4 DownSample3( float2 tc : TEXCOORD0 ) : COLOR +{ + float4 color; + + float4 tap0 = f4tex2D(SSsampler, tc); + float4 tap1 = f4tex2D(SSsampler, tc + SSTexelSize * float2( 0.4, 0.9 )); + float4 tap2 = f4tex2D(SSsampler, tc + SSTexelSize * float2( -0.4, -0.9 )); + float4 tap3 = f4tex2D(SSsampler, tc + SSTexelSize * float2( -0.9, 0.4 )); + float4 tap4 = f4tex2D(SSsampler, tc + SSTexelSize * float2( 0.9, -0.4 )); + color = 0.2 * ( tap0 + tap1 + tap2 + tap3 + tap4 ); + + float4 tap11 = f4tex2D(SSsampler, tc + SSTexelSize * float2( 0.9, 1.9 )); + float4 tap21 = f4tex2D(SSsampler, tc + SSTexelSize * float2( -0.9, -1.9 )); + float4 tap31 = f4tex2D(SSsampler, tc + SSTexelSize * float2( -1.9, 0.9 )); + float4 tap41 = f4tex2D(SSsampler, tc + SSTexelSize * float2( 1.9, -0.9 )); + float4 color2 = 0.2 * ( tap0 + tap11 + tap21 + tap31 + tap41 ); + + float mask = saturate(color2.w * 1); + + color = lerp(color2, color, mask); + color.w = mask; + + return color; +} +/////////////////////////////////////////////////////////////////////// +// Technique +/////////////////////////////////////////////////////////////////////// +technique DownSample_Filter1 +{ + pass drawFinal + { + DepthMask = true; + VertexProgram = compile arbvp1 vpPassThrough(); + FragmentProgram = compile arbfp1 DownSample1(); + } +} +technique DownSample_Filter2 +{ + pass drawFinal + { + DepthMask = true; + VertexProgram = compile arbvp1 vpPassThrough(); + FragmentProgram = compile arbfp1 DownSample2(); + } +} +technique DownSample_Filter3 +{ + pass drawFinal + { + DepthMask = true; + VertexProgram = compile arbvp1 vpPassThrough(); + FragmentProgram = compile arbfp1 DownSample3(); + } +} + |