mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Direct3D11 common shader changes.
This commit is contained in:
parent
1ff6f221fb
commit
3a9b50f702
283 changed files with 3547 additions and 1834 deletions
|
|
@ -23,21 +23,22 @@
|
|||
#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
|
||||
TORQUE_UNIFORM_SAMPLER2D(shrunkSampler, 0); // Output of DofDownsample()
|
||||
TORQUE_UNIFORM_SAMPLER2D(blurredSampler, 1); // 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
|
||||
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
float3 color;
|
||||
float coc;
|
||||
half4 blurred;
|
||||
half4 shrunk;
|
||||
|
||||
shrunk = tex2D( shrunkSampler, IN.uv0 );
|
||||
blurred = tex2D( blurredSampler, IN.uv1 );
|
||||
shrunk = half4(TORQUE_TEX2D( shrunkSampler, IN.uv0 ));
|
||||
blurred = half4(TORQUE_TEX2D( blurredSampler, IN.uv1 ));
|
||||
color = shrunk.rgb;
|
||||
//coc = shrunk.a;
|
||||
//coc = blurred.a;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ PFXVertToPix main( PFXVert IN )
|
|||
*/
|
||||
|
||||
|
||||
OUT.hpos = IN.pos;
|
||||
OUT.hpos = float4(IN.pos,1.0);
|
||||
OUT.uv0 = viewportCoordToRenderTarget( IN.uv, rtParams0 );
|
||||
OUT.uv1 = viewportCoordToRenderTarget( IN.uv, rtParams1 );
|
||||
OUT.uv2 = viewportCoordToRenderTarget( IN.uv, rtParams2 );
|
||||
|
|
|
|||
|
|
@ -20,22 +20,23 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../shaderModel.hlsl"
|
||||
#include "../../shaderModelAutoGen.hlsl"
|
||||
|
||||
// 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;
|
||||
TORQUE_UNIFORM_SAMPLER2D(colorSampler, 0);
|
||||
TORQUE_UNIFORM_SAMPLER2D(depthSampler, 1);
|
||||
uniform float2 dofEqWorld;
|
||||
uniform float2 targetSize;
|
||||
uniform float depthOffset;
|
||||
uniform float maxWorldCoC;
|
||||
//uniform float2 dofEqWeapon;
|
||||
//uniform float2 dofRowDelta; // float2( 0, 0.25 / renderTargetHeight )
|
||||
|
||||
struct Pixel
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 position : TORQUE_POSITION;
|
||||
float2 tcColor0 : TEXCOORD0;
|
||||
float2 tcColor1 : TEXCOORD1;
|
||||
float2 tcDepth0 : TEXCOORD2;
|
||||
|
|
@ -44,7 +45,7 @@ struct Pixel
|
|||
float2 tcDepth3 : TEXCOORD5;
|
||||
};
|
||||
|
||||
half4 main( Pixel IN ) : COLOR
|
||||
half4 main( Pixel IN ) : TORQUE_TARGET0
|
||||
{
|
||||
//return float4( 1.0, 0.0, 1.0, 1.0 );
|
||||
|
||||
|
|
@ -69,57 +70,64 @@ half4 main( Pixel IN ) : COLOR
|
|||
|
||||
// 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 += half3(TORQUE_TEX2D( colorSampler, IN.tcColor0.xy + rowOfs[0] ).rgb);
|
||||
color += half3(TORQUE_TEX2D(colorSampler, IN.tcColor1.xy + rowOfs[0]).rgb);
|
||||
color += half3(TORQUE_TEX2D(colorSampler, IN.tcColor0.xy + rowOfs[2]).rgb);
|
||||
color += half3(TORQUE_TEX2D(colorSampler, IN.tcColor1.xy + rowOfs[2]).rgb);
|
||||
color /= 4;
|
||||
|
||||
//declare thse here to save doing it in each loop below
|
||||
half4 zero4 = half4(0, 0, 0, 0);
|
||||
coc = zero4;
|
||||
half4 dofEqWorld4X = half4(dofEqWorld.xxxx);
|
||||
half4 dofEqWorld4Y = half4(dofEqWorld.yyyy);
|
||||
half4 maxWorldCoC4 = half4(maxWorldCoC, maxWorldCoC, maxWorldCoC, maxWorldCoC);
|
||||
// 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++ )
|
||||
// between "sceneCoc" and "viewCoc".
|
||||
[unroll] // coc[i] causes this anyway
|
||||
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] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth0.xy + rowOfs[i])).w;
|
||||
depth[1] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth1.xy + rowOfs[i])).w;
|
||||
depth[2] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth2.xy + rowOfs[i])).w;
|
||||
depth[3] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth3.xy + rowOfs[i])).w;
|
||||
|
||||
coc = max(coc, clamp(dofEqWorld4X * half4(depth)+dofEqWorld4Y, zero4, maxWorldCoC4));
|
||||
}
|
||||
|
||||
/*
|
||||
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;
|
||||
depth[0] = TORQUE_TEX2D( depthSampler, pixel.tcDepth0.xy + rowOfs[0] ).r;
|
||||
depth[1] = TORQUE_TEX2D( depthSampler, pixel.tcDepth1.xy + rowOfs[0] ).r;
|
||||
depth[2] = TORQUE_TEX2D( depthSampler, pixel.tcDepth2.xy + rowOfs[0] ).r;
|
||||
depth[3] = TORQUE_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;
|
||||
depth[0] = TORQUE_TEX2D( depthSampler, pixel.tcDepth0.xy + rowOfs[1] ).r;
|
||||
depth[1] = TORQUE_TEX2D( depthSampler, pixel.tcDepth1.xy + rowOfs[1] ).r;
|
||||
depth[2] = TORQUE_TEX2D( depthSampler, pixel.tcDepth2.xy + rowOfs[1] ).r;
|
||||
depth[3] = TORQUE_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;
|
||||
depth[0] = TORQUE_TEX2D( depthSampler, pixel.tcDepth0.xy + rowOfs[2] ).r;
|
||||
depth[1] = TORQUE_TEX2D( depthSampler, pixel.tcDepth1.xy + rowOfs[2] ).r;
|
||||
depth[2] = TORQUE_TEX2D( depthSampler, pixel.tcDepth2.xy + rowOfs[2] ).r;
|
||||
depth[3] = TORQUE_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;
|
||||
depth[0] = TORQUE_TEX2D( depthSampler, pixel.tcDepth0.xy + rowOfs[3] ).r;
|
||||
depth[1] = TORQUE_TEX2D( depthSampler, pixel.tcDepth1.xy + rowOfs[3] ).r;
|
||||
depth[2] = TORQUE_TEX2D( depthSampler, pixel.tcDepth2.xy + rowOfs[3] ).r;
|
||||
depth[3] = TORQUE_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 );
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@
|
|||
|
||||
struct Vert
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float3 pos : POSITION;
|
||||
float2 tc : TEXCOORD0;
|
||||
float3 wsEyeRay : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct Pixel
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 position : TORQUE_POSITION;
|
||||
float2 tcColor0 : TEXCOORD0;
|
||||
float2 tcColor1 : TEXCOORD1;
|
||||
float2 tcDepth0 : TEXCOORD2;
|
||||
|
|
@ -47,7 +47,7 @@ uniform float2 oneOverTargetSize;
|
|||
Pixel main( Vert IN )
|
||||
{
|
||||
Pixel OUT;
|
||||
OUT.position = IN.pos;
|
||||
OUT.position = float4(IN.pos,1.0);
|
||||
|
||||
float2 uv = viewportCoordToRenderTarget( IN.tc, rtParams0 );
|
||||
//OUT.position = mul( IN.pos, modelView );
|
||||
|
|
|
|||
|
|
@ -20,13 +20,14 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../shaderModelAutoGen.hlsl"
|
||||
#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); //
|
||||
TORQUE_UNIFORM_SAMPLER2D(colorSampler,0); // Original source image
|
||||
TORQUE_UNIFORM_SAMPLER2D(smallBlurSampler,1); // Output of SmallBlurPS()
|
||||
TORQUE_UNIFORM_SAMPLER2D(largeBlurSampler,2); // Blurred output of DofDownsample()
|
||||
TORQUE_UNIFORM_SAMPLER2D(depthSampler,3);
|
||||
|
||||
uniform float2 oneOverTargetSize;
|
||||
uniform float4 dofLerpScale;
|
||||
uniform float4 dofLerpBias;
|
||||
|
|
@ -40,9 +41,9 @@ uniform float maxFarCoC;
|
|||
//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 )
|
||||
float4 tex2Doffset(TORQUE_SAMPLER2D(s), float2 tc, float2 offset)
|
||||
{
|
||||
return tex2D( s, tc + offset * oneOverTargetSize );
|
||||
return TORQUE_TEX2D( s, tc + offset * oneOverTargetSize );
|
||||
}
|
||||
|
||||
half3 GetSmallBlurSample( float2 tc )
|
||||
|
|
@ -51,10 +52,10 @@ half3 GetSmallBlurSample( float2 tc )
|
|||
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;
|
||||
sum += weight * half3(tex2Doffset(TORQUE_SAMPLER2D_MAKEARG(colorSampler), tc, float2(+0.5, -1.5)).rgb);
|
||||
sum += weight * half3(tex2Doffset(TORQUE_SAMPLER2D_MAKEARG(colorSampler), tc, float2(-1.5, -0.5)).rgb);
|
||||
sum += weight * half3(tex2Doffset(TORQUE_SAMPLER2D_MAKEARG(colorSampler), tc, float2(-0.5, +1.5)).rgb);
|
||||
sum += weight * half3(tex2Doffset(TORQUE_SAMPLER2D_MAKEARG(colorSampler), tc, float2(+1.5, +0.5)).rgb);
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +73,7 @@ half4 InterpolateDof( half3 small, half3 med, half3 large, half t )
|
|||
//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 = half4(saturate( t * dofLerpScale + dofLerpBias ));
|
||||
weights.yz = min( weights.yz, 1 - weights.xy );
|
||||
|
||||
// Unblurred sample with weight "weights.x" done by alpha blending
|
||||
|
|
@ -84,11 +85,11 @@ half4 InterpolateDof( half3 small, half3 med, half3 large, half t )
|
|||
return half4( color, alpha );
|
||||
}
|
||||
|
||||
half4 main( PFXVertToPix IN ) : COLOR
|
||||
half4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
//return half4( 1,0,1,1 );
|
||||
//return half4( tex2D( colorSampler, IN.uv0 ).rgb, 1.0 );
|
||||
//return half4( tex2D( colorSampler, texCoords ).rgb, 0 );
|
||||
//return half4( TORQUE_TEX2D( colorSampler, IN.uv0 ).rgb, 1.0 );
|
||||
//return half4( TORQUE_TEX2D( colorSampler, texCoords ).rgb, 0 );
|
||||
half3 small;
|
||||
half4 med;
|
||||
half3 large;
|
||||
|
|
@ -100,10 +101,10 @@ half4 main( PFXVertToPix IN ) : COLOR
|
|||
small = GetSmallBlurSample( IN.uv0 );
|
||||
//small = half3( 1,0,0 );
|
||||
//return half4( small, 1.0 );
|
||||
med = tex2D( smallBlurSampler, IN.uv1 );
|
||||
med = half4(TORQUE_TEX2D( smallBlurSampler, IN.uv1 ));
|
||||
//med.rgb = half3( 0,1,0 );
|
||||
//return half4(med.rgb, 0.0);
|
||||
large = tex2D( largeBlurSampler, IN.uv2 ).rgb;
|
||||
large = half3(TORQUE_TEX2D(largeBlurSampler, IN.uv2).rgb);
|
||||
//large = half3( 0,0,1 );
|
||||
//return large;
|
||||
//return half4(large.rgb,1.0);
|
||||
|
|
@ -114,7 +115,7 @@ half4 main( PFXVertToPix IN ) : COLOR
|
|||
//med.rgb = large;
|
||||
|
||||
//nearCoc = 0;
|
||||
depth = prepassUncondition( depthSampler, float4( IN.uv3, 0, 0 ) ).w;
|
||||
depth = half(TORQUE_PREPASS_UNCONDITION( depthSampler, IN.uv3 ).w);
|
||||
//return half4(depth.rrr,1);
|
||||
//return half4(nearCoc.rrr,1.0);
|
||||
|
||||
|
|
@ -128,8 +129,8 @@ half4 main( PFXVertToPix IN ) : COLOR
|
|||
// 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 );
|
||||
farCoc = half(clamp( dofEqFar.x * depth + dofEqFar.y, 0.0, maxFarCoC ));
|
||||
coc = half(max( nearCoc, farCoc * dofEqFar.z ));
|
||||
//coc = nearCoc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ PFXVertToPix main( PFXVert IN )
|
|||
*/
|
||||
|
||||
|
||||
OUT.hpos = IN.pos;
|
||||
OUT.hpos = float4(IN.pos,1.0);
|
||||
OUT.uv0 = viewportCoordToRenderTarget( IN.uv, rtParams0 );
|
||||
OUT.uv1 = viewportCoordToRenderTarget( IN.uv, rtParams1 ); // + float2( -5, 1 ) * oneOverTargetSize;
|
||||
OUT.uv2 = viewportCoordToRenderTarget( IN.uv, rtParams2 );
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@
|
|||
|
||||
#include "./../postFx.hlsl"
|
||||
|
||||
uniform sampler2D diffuseMap : register(S0);
|
||||
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
|
||||
|
||||
struct VertToPix
|
||||
{
|
||||
float4 hpos : POSITION;
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
|
|
@ -39,20 +39,20 @@ struct VertToPix
|
|||
float2 uv7 : TEXCOORD7;
|
||||
};
|
||||
|
||||
float4 main( VertToPix IN ) : COLOR
|
||||
float4 main( VertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
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 += TORQUE_TEX2D( diffuseMap, IN.uv0 ) * kernel.x;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv1 ) * kernel.y;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv2 ) * kernel.z;
|
||||
OUT += TORQUE_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;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv4 ) * kernel.x;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv5 ) * kernel.y;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv6 ) * kernel.z;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv7 ) * kernel.w;
|
||||
|
||||
// Calculate a lumenance value in the alpha so we
|
||||
// can use alpha test to save fillrate.
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@
|
|||
#include "./../../torque.hlsl"
|
||||
|
||||
|
||||
uniform float2 texSize0;
|
||||
uniform float4 rtParams0;
|
||||
uniform float2 texSize0;
|
||||
uniform float2 oneOverTargetSize;
|
||||
|
||||
struct VertToPix
|
||||
{
|
||||
float4 hpos : POSITION;
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
|
|
@ -47,7 +47,7 @@ VertToPix main( PFXVert IN )
|
|||
{
|
||||
VertToPix OUT;
|
||||
|
||||
OUT.hpos = IN.pos;
|
||||
OUT.hpos = float4(IN.pos,1.0);
|
||||
|
||||
IN.uv = viewportCoordToRenderTarget( IN.uv, rtParams0 );
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ PFXVertToPix main( PFXVert IN )
|
|||
*/
|
||||
|
||||
|
||||
OUT.hpos = IN.pos;
|
||||
OUT.hpos = float4(IN.pos,1.0);
|
||||
OUT.uv0 = viewportCoordToRenderTarget( IN.uv, rtParams0 );
|
||||
OUT.uv1 = viewportCoordToRenderTarget( IN.uv, rtParams1 );
|
||||
OUT.uv2 = viewportCoordToRenderTarget( IN.uv, rtParams2 );
|
||||
|
|
|
|||
|
|
@ -24,22 +24,23 @@
|
|||
// 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 "../../shaderModel.hlsl"
|
||||
|
||||
uniform sampler2D colorSampler; // Output of DofNearCoc()
|
||||
TORQUE_UNIFORM_SAMPLER2D(colorSampler, 0); // Output of DofNearCoc()
|
||||
|
||||
struct Pixel
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 position : TORQUE_POSITION;
|
||||
float4 texCoords : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 main( Pixel IN ) : COLOR
|
||||
float4 main( Pixel IN ) : TORQUE_TARGET0
|
||||
{
|
||||
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 );
|
||||
color += TORQUE_TEX2D( colorSampler, IN.texCoords.xz );
|
||||
color += TORQUE_TEX2D( colorSampler, IN.texCoords.yz );
|
||||
color += TORQUE_TEX2D( colorSampler, IN.texCoords.xw );
|
||||
color += TORQUE_TEX2D( colorSampler, IN.texCoords.yw );
|
||||
return color / 4.0;
|
||||
}
|
||||
|
|
@ -30,13 +30,13 @@
|
|||
|
||||
struct Vert
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float3 position : POSITION;
|
||||
float2 texCoords : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Pixel
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 position : TORQUE_POSITION;
|
||||
float4 texCoords : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ 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 );
|
||||
OUT.position = float4(IN.position,1.0); //Transform_ObjectToClip( IN.position );
|
||||
|
||||
//float2 uv = IN.texCoords + rtParams0.xy;
|
||||
float2 uv = viewportCoordToRenderTarget( IN.texCoords, rtParams0 );
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
// These are set by the game engine.
|
||||
uniform sampler2D shrunkSampler; // Output of DofDownsample()
|
||||
uniform sampler2D blurredSampler; // Blurred version of the shrunk sampler
|
||||
uniform sampler2D blurredSampler; // Blurred version of the shrunk sampler
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue