Direct3D11 common shader changes.

This commit is contained in:
rextimmy 2016-03-20 21:50:21 +10:00
parent 1ff6f221fb
commit 3a9b50f702
283 changed files with 3547 additions and 1834 deletions

View file

@ -32,12 +32,12 @@
#include "./postFx.hlsl"
uniform sampler2D diffuseMap : register(S0);
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
uniform float strength;
struct VertToPix
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
@ -50,20 +50,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 ) * strength;
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.

View file

@ -21,25 +21,26 @@
//-----------------------------------------------------------------------------
#include "../postFx.hlsl"
#include "shadergen:/autogenConditioners.h"
#include "../../shaderModelAutoGen.hlsl"
uniform float accumTime;
uniform float3 eyePosWorld;
uniform float4 rtParams0;
uniform float4 waterFogPlane;
uniform float accumTime;
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 0);
TORQUE_UNIFORM_SAMPLER2D(causticsTex0, 1);
TORQUE_UNIFORM_SAMPLER2D(causticsTex1, 2);
float distanceToPlane(float4 plane, float3 pos)
{
return (plane.x * pos.x + plane.y * pos.y + plane.z * pos.z) + plane.w;
}
float4 main( PFXVertToPix IN,
uniform sampler2D prepassTex :register(S0),
uniform sampler2D causticsTex0 :register(S1),
uniform sampler2D causticsTex1 :register(S2) ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
//Sample the pre-pass
float4 prePass = prepassUncondition( prepassTex, IN.uv0 );
float4 prePass = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 );
//Get depth
float depth = prePass.w;
@ -65,12 +66,12 @@ float4 main( PFXVertToPix IN,
causticsUV1.xy -= float2(accumTime*0.15, timeSin*0.15);
//Sample caustics texture
float4 caustics = tex2D(causticsTex0, causticsUV0);
caustics *= tex2D(causticsTex1, causticsUV1);
float4 caustics = TORQUE_TEX2D(causticsTex0, causticsUV0);
caustics *= TORQUE_TEX2D(causticsTex1, causticsUV1);
//Use normal Z to modulate caustics
//float waterDepth = 1 - saturate(pos.z + waterFogPlane.w + 1);
caustics *= saturate(prePass.z) * pow(1-depth, 64) * waterDepth;
caustics *= saturate(prePass.z) * pow(abs(1-depth), 64) * waterDepth;
return caustics;
}

View file

@ -26,14 +26,13 @@
#include "./postFx.hlsl"
#include "./../torque.hlsl"
uniform sampler2D backBuffer : register( s0 );
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
uniform float distCoeff;
uniform float cubeDistort;
uniform float3 colorDistort;
float4 main( PFXVertToPix IN ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float2 tex = IN.uv0;
@ -54,7 +53,7 @@ float4 main( PFXVertToPix IN ) : COLOR0
{
float x = distort[i] * ( tex.x - 0.5 ) + 0.5;
float y = distort[i] * ( tex.y - 0.5 ) + 0.5;
outColor[i] = tex2Dlod( backBuffer, float4(x,y,0,0) )[i];
outColor[i] = TORQUE_TEX2DLOD( backBuffer, float4(x,y,0,0) )[i];
}
return float4( outColor.rgb, 1 );

View file

@ -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;

View file

@ -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 );

View file

@ -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 );

View file

@ -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 );

View file

@ -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;
}

View file

@ -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 );

View file

@ -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.

View file

@ -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 );

View file

@ -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 );

View file

@ -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;
}

View file

@ -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 );

View file

@ -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;

View file

@ -21,10 +21,10 @@
//-----------------------------------------------------------------------------
#include "../postFx.hlsl"
#include "shadergen:/autogenConditioners.h"
float4 main( PFXVertToPix IN,
uniform sampler2D edgeBuffer :register(S0) ) : COLOR0
TORQUE_UNIFORM_SAMPLER2D(edgeBuffer);
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
return float4( tex2D( edgeBuffer, IN.uv0 ).rrr, 1.0 );
return float4( TORQUE_TEX2D( edgeBuffer, IN.uv0 ).rrr, 1.0 );
}

View file

@ -21,17 +21,17 @@
//-----------------------------------------------------------------------------
#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
TORQUE_UNIFORM_SAMPLER2D(edgeBuffer,0);
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 1);
uniform float2 targetSize;
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float2 pixelSize = 1.0 / targetSize;
// Sample edge buffer, bail if not on an edge
float edgeSample = tex2D(edgeBuffer, IN.uv0).r;
float edgeSample = TORQUE_TEX2D(edgeBuffer, IN.uv0).r;
clip(edgeSample - 1e-6);
// Ok we're on an edge, so multi-tap sample, average, and return
@ -58,7 +58,7 @@ float4 main( PFXVertToPix IN,
float2 offsetUV = IN.uv1 + edgeSample * ( offsets[i] * 0.5 ) * pixelSize;//rtWidthHeightInvWidthNegHeight.zw;
//offsetUV *= 0.999;
accumColor+= tex2D(backBuffer, offsetUV);
accumColor += TORQUE_TEX2D(backBuffer, offsetUV);
}
accumColor /= 9.0;

View file

@ -21,10 +21,12 @@
//-----------------------------------------------------------------------------
#include "../postFx.hlsl"
#include "shadergen:/autogenConditioners.h"
#include "../../shaderModelAutoGen.hlsl"
TORQUE_UNIFORM_SAMPLER2D(prepassBuffer,0);
// GPU Gems 3, pg 443-444
float GetEdgeWeight(float2 uv0, in sampler2D prepassBuffer, in float2 targetSize)
float GetEdgeWeight(float2 uv0, in float2 targetSize)
{
float2 offsets[9] = {
float2( 0.0, 0.0),
@ -44,10 +46,11 @@ float GetEdgeWeight(float2 uv0, in sampler2D prepassBuffer, in float2 targetSize
float Depth[9];
float3 Normal[9];
[unroll] //no getting around this, may as well save the annoying warning message
for(int i = 0; i < 9; i++)
{
float2 uv = uv0 + offsets[i] * PixelSize;
float4 gbSample = prepassUncondition( prepassBuffer, uv );
float4 gbSample = TORQUE_PREPASS_UNCONDITION( prepassBuffer, uv );
Depth[i] = gbSample.a;
Normal[i] = gbSample.rgb;
}
@ -82,9 +85,9 @@ float GetEdgeWeight(float2 uv0, in sampler2D prepassBuffer, in float2 targetSize
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
uniform float2 targetSize;
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
return GetEdgeWeight(IN.uv0, prepassBuffer, targetSize );//rtWidthHeightInvWidthNegHeight.zw);
return GetEdgeWeight(IN.uv0, targetSize);//rtWidthHeightInvWidthNegHeight.zw);
}

View file

@ -25,11 +25,11 @@
uniform float damageFlash;
uniform float whiteOut;
uniform sampler2D backBuffer : register(S0);
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
float4 main(PFXVertToPix IN) : COLOR0
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
{
float4 color1 = tex2D(backBuffer, IN.uv0);
float4 color1 = TORQUE_TEX2D(backBuffer, IN.uv0);
float4 color2 = color1 * MUL_COLOR;
float4 damage = lerp(color1,color2,damageFlash);
return lerp(damage,WHITE_COLOR,whiteOut);

View file

@ -20,20 +20,21 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "./postFx.hlsl"
#include "./../torque.hlsl"
#include "./../shaderModelAutoGen.hlsl"
uniform sampler2D prepassTex : register(S0);
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 0);
uniform float3 eyePosWorld;
uniform float4 fogColor;
uniform float3 fogData;
uniform float4 rtParams0;
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
//float2 prepassCoord = ( IN.uv0.xy * rtParams0.zw ) + rtParams0.xy;
float depth = prepassUncondition( prepassTex, IN.uv0 ).w;
float depth = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
//return float4( depth, 0, 0, 0.7 );
float factor = computeSceneFog( eyePosWorld,

View file

@ -20,38 +20,53 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../shaderModel.hlsl"
#define FXAA_PC 1
#if (TORQUE_SM <= 30)
#define FXAA_HLSL_3 1
#elif TORQUE_SM < 49
#define FXAA_HLSL_4 1
#elif TORQUE_SM >=50
#define FXAA_HLSL_5 1
#endif
#define FXAA_QUALITY__PRESET 12
#define FXAA_GREEN_AS_LUMA 1
#include "Fxaa3_11.h"
#include "../postFx.hlsl"
struct VertToPix
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 uv0 : TEXCOORD0;
};
uniform sampler2D colorTex : register(S0);
TORQUE_UNIFORM_SAMPLER2D(colorTex, 0);
uniform float2 oneOverTargetSize;
float4 main( VertToPix IN ) : COLOR
float4 main( VertToPix IN ) : TORQUE_TARGET0
{
#if (TORQUE_SM >= 10 && TORQUE_SM <=30)
FxaaTex tex = colorTex;
#elif TORQUE_SM >=40
FxaaTex tex;
tex.smpl = colorTex;
tex.tex = texture_colorTex;
#endif
return FxaaPixelShader(
IN.uv0, // vertex position
0, // Unused... console stuff
colorTex, // The color back buffer
tex, // The color back buffer
colorTex, // Used for 360 optimization
tex, // Used for 360 optimization
colorTex, // Used for 360 optimization
tex, // Used for 360 optimization
oneOverTargetSize,

View file

@ -25,7 +25,7 @@
struct VertToPix
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 uv0 : TEXCOORD0;
};
@ -35,7 +35,7 @@ VertToPix main( PFXVert IN )
{
VertToPix OUT;
OUT.hpos = IN.pos;
OUT.hpos = float4(IN.pos,1);
OUT.uv0 = viewportCoordToRenderTarget( IN.uv, rtParams0 );
return OUT;

View file

@ -24,23 +24,30 @@
#include "./postFx.hlsl"
#include "../torque.hlsl"
uniform sampler2D backBuffer : register(S0);
uniform sampler1D colorCorrectionTex : register( s1 );
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 1);
uniform float OneOverGamma;
uniform float Brightness;
uniform float Contrast;
float4 main( PFXVertToPix IN ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float4 color = tex2D(backBuffer, IN.uv0.xy);
float4 color = TORQUE_TEX2D(backBuffer, IN.uv0.xy);
// Apply the color correction.
color.r = tex1D( colorCorrectionTex, color.r ).r;
color.g = tex1D( colorCorrectionTex, color.g ).g;
color.b = tex1D( colorCorrectionTex, color.b ).b;
color.r = TORQUE_TEX1D( colorCorrectionTex, color.r ).r;
color.g = TORQUE_TEX1D( colorCorrectionTex, color.g ).g;
color.b = TORQUE_TEX1D( colorCorrectionTex, color.b ).b;
// Apply gamma correction
color.rgb = pow( abs(color.rgb), OneOverGamma );
// Apply contrast
color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;
// Apply brightness
color.rgb += Brightness;
return color;
}

View file

@ -28,6 +28,8 @@ uniform sampler2D backBuffer;
uniform sampler1D colorCorrectionTex;
uniform float OneOverGamma;
uniform float Brightness;
uniform float Contrast;
in vec2 uv0;
@ -45,5 +47,11 @@ void main()
// Apply gamma correction
color.rgb = pow( abs(color.rgb), vec3(OneOverGamma) );
// Apply contrast
color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;
// Apply brightness
color.rgb += Brightness;
OUT_col = color;
}

View file

@ -39,7 +39,7 @@ out vec4 OUT_col;
void main()
{
vec4 kernel = vec4( 0.175, 0.275, 0.375, 0.475 ) * 0.5f;
OUT_col = vec4(0);
OUT_col += texture( diffuseMap, uv0 ) * kernel.x;
OUT_col += texture( diffuseMap, uv1 ) * kernel.y;
@ -55,5 +55,5 @@ void main()
// can use alpha test to save fillrate.
vec3 rgb2lum = vec3( 0.30, 0.59, 0.11 );
OUT_col.a = dot( OUT_col.rgb, rgb2lum );
}

View file

@ -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.5f;
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.

View file

@ -28,7 +28,7 @@ uniform float2 texSize0;
struct VertToPix
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
@ -45,7 +45,7 @@ VertToPix main( PFXVert IN )
{
VertToPix OUT;
OUT.hpos = IN.pos;
OUT.hpos = float4(IN.pos,1.0);
float2 uv = IN.uv + (0.5f / texSize0);

View file

@ -21,9 +21,8 @@
//-----------------------------------------------------------------------------
#include "../postFx.hlsl"
#include "shadergen:/autogenConditioners.h"
uniform sampler2D inputTex : register(S0);
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
uniform float2 oneOverTargetSize;
uniform float gaussMultiplier;
uniform float gaussMean;
@ -48,7 +47,7 @@ float computeGaussianValue( float x, float mean, float std_deviation )
return tmp * tmp2;
}
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float4 color = { 0.0f, 0.0f, 0.0f, 0.0f };
float offset = 0;
@ -62,7 +61,7 @@ float4 main( PFXVertToPix IN ) : COLOR
offset = (i - 4.0) * oneOverTargetSize.x;
x = (i - 4.0) / 4.0;
weight = gaussMultiplier * computeGaussianValue( x, gaussMean, gaussStdDev );
color += (tex2D( inputTex, IN.uv0 + float2( offset, 0.0f ) ) * weight );
color += (TORQUE_TEX2D( inputTex, IN.uv0 + float2( offset, 0.0f ) ) * weight );
}
return float4( color.rgb, 1.0f );

View file

@ -21,9 +21,8 @@
//-----------------------------------------------------------------------------
#include "../postFx.hlsl"
#include "shadergen:/autogenConditioners.h"
uniform sampler2D inputTex : register(S0);
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
uniform float2 oneOverTargetSize;
uniform float gaussMultiplier;
uniform float gaussMean;
@ -47,7 +46,7 @@ float computeGaussianValue( float x, float mean, float std_deviation )
return tmp * tmp2;
}
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float4 color = { 0.0f, 0.0f, 0.0f, 0.0f };
float offset = 0;
@ -61,7 +60,7 @@ float4 main( PFXVertToPix IN ) : COLOR
offset = (fI - 4.0) * oneOverTargetSize.y;
x = (fI - 4.0) / 4.0;
weight = gaussMultiplier * computeGaussianValue( x, gaussMean, gaussStdDev );
color += (tex2D( inputTex, IN.uv0 + float2( 0.0f, offset ) ) * weight );
color += (TORQUE_TEX2D( inputTex, IN.uv0 + float2( 0.0f, offset ) ) * weight );
}
return float4( color.rgb, 1.0f );

View file

@ -21,12 +21,11 @@
//-----------------------------------------------------------------------------
#include "../postFx.hlsl"
#include "shadergen:/autogenConditioners.h"
#include "../../torque.hlsl"
uniform sampler2D inputTex : register(S0);
uniform sampler2D luminanceTex : register(S1);
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
TORQUE_UNIFORM_SAMPLER2D(luminanceTex, 1);
uniform float2 oneOverTargetSize;
uniform float brightPassThreshold;
uniform float g_fMiddleGray;
@ -40,17 +39,17 @@ static float2 gTapOffsets[4] =
{ -0.5, -0.5 }, { 0.5, 0.5 }
};
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float4 average = { 0.0f, 0.0f, 0.0f, 0.0f };
// Combine and average 4 samples from the source HDR texture.
for( int i = 0; i < 4; i++ )
average += hdrDecode( tex2D( inputTex, IN.uv0 + ( gTapOffsets[i] * oneOverTargetSize ) ) );
average += hdrDecode( TORQUE_TEX2D( inputTex, IN.uv0 + ( gTapOffsets[i] * oneOverTargetSize ) ) );
average *= 0.25f;
// Determine the brightness of this particular pixel.
float adaptedLum = tex2D( luminanceTex, float2( 0.5f, 0.5f ) ).r;
float adaptedLum = TORQUE_TEX2D( luminanceTex, float2( 0.5f, 0.5f ) ).r;
float lum = (g_fMiddleGray / (adaptedLum + 0.0001)) * hdrLuminance( average.rgb );
//float lum = hdrLuminance( average.rgb );

View file

@ -21,18 +21,17 @@
//-----------------------------------------------------------------------------
#include "../postFx.hlsl"
#include "shadergen:/autogenConditioners.h"
uniform sampler2D currLum : register( S0 );
uniform sampler2D lastAdaptedLum : register( S1 );
TORQUE_UNIFORM_SAMPLER2D(currLum, 0);
TORQUE_UNIFORM_SAMPLER2D(lastAdaptedLum, 1);
uniform float adaptRate;
uniform float deltaTime;
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float fAdaptedLum = tex2D( lastAdaptedLum, float2(0.5f, 0.5f) ).r;
float fCurrentLum = tex2D( currLum, float2(0.5f, 0.5f) ).r;
float fAdaptedLum = TORQUE_TEX2D( lastAdaptedLum, float2(0.5f, 0.5f) ).r;
float fCurrentLum = TORQUE_TEX2D( currLum, float2(0.5f, 0.5f) ).r;
// The user's adapted luminance level is simulated by closing the gap between
// adapted luminance and current luminance by 2% every frame, based on a

View file

@ -29,23 +29,24 @@
//-----------------------------------------------------------------------------
struct VertIn
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 texCoords[8] : TEXCOORD0;
};
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
float4 main( VertIn IN,
uniform sampler2D inputTex : register(S0) ) : COLOR
float4 main( VertIn IN) : TORQUE_TARGET0
{
// We calculate the texture coords
// in the vertex shader as an optimization.
float4 sample = 0.0f;
for ( int i = 0; i < 8; i++ )
{
sample += tex2D( inputTex, IN.texCoords[i].xy );
sample += tex2D( inputTex, IN.texCoords[i].zw );
sample += TORQUE_TEX2D( inputTex, IN.texCoords[i].xy );
sample += TORQUE_TEX2D( inputTex, IN.texCoords[i].zw );
}
return sample / 16;

View file

@ -29,19 +29,20 @@
struct Conn
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 texCoords[8] : TEXCOORD0;
};
uniform float2 targetSize;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
Conn main( PFXVert In,
uniform float2 targetSize : register(C0) )
Conn main( PFXVert In )
{
Conn Out;
Out.hpos = In.pos;
Out.hpos = float4(In.pos,1.0);
// Sample from the 16 surrounding points. Since the center point will be in
// the exact center of 16 texels, a 0.5f offset is needed to specify a texel

View file

@ -22,11 +22,13 @@
#include "../../torque.hlsl"
#include "../postFx.hlsl"
#include "../../shaderModelAutoGen.hlsl"
uniform sampler2D sceneTex : register( s0 );
uniform sampler2D luminanceTex : register( s1 );
uniform sampler2D bloomTex : register( s2 );
uniform sampler1D colorCorrectionTex : register( s3 );
TORQUE_UNIFORM_SAMPLER2D(sceneTex, 0);
TORQUE_UNIFORM_SAMPLER2D(luminanceTex, 1);
TORQUE_UNIFORM_SAMPLER2D(bloomTex, 2);
TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 3);
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 4);
uniform float2 texSize0;
uniform float2 texSize2;
@ -34,20 +36,20 @@ uniform float2 texSize2;
uniform float g_fEnableToneMapping;
uniform float g_fMiddleGray;
uniform float g_fWhiteCutoff;
uniform float g_fEnableBlueShift;
uniform float3 g_fBlueShiftColor;
uniform float3 g_fBlueShiftColor;
uniform float g_fBloomScale;
uniform float g_fOneOverGamma;
uniform float Brightness;
uniform float Contrast;
float4 main( PFXVertToPix IN ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float4 sample = hdrDecode( tex2D( sceneTex, IN.uv0 ) );
float adaptedLum = tex2D( luminanceTex, float2( 0.5f, 0.5f ) ).r;
float4 bloom = tex2D( bloomTex, IN.uv0 );
float4 sample = hdrDecode( TORQUE_TEX2D( sceneTex, IN.uv0 ) );
float adaptedLum = TORQUE_TEX2D( luminanceTex, float2( 0.5f, 0.5f ) ).r;
float4 bloom = TORQUE_TEX2D( bloomTex, IN.uv0 );
// For very low light conditions, the rods will dominate the perception
// of light, and therefore color will be desaturated and shifted
@ -81,15 +83,24 @@ float4 main( PFXVertToPix IN ) : COLOR0
}
// Add the bloom effect.
sample += g_fBloomScale * bloom;
float depth = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
if (depth>0.9999)
sample += g_fBloomScale * bloom;
// Apply the color correction.
sample.r = tex1D( colorCorrectionTex, sample.r ).r;
sample.g = tex1D( colorCorrectionTex, sample.g ).g;
sample.b = tex1D( colorCorrectionTex, sample.b ).b;
sample.r = TORQUE_TEX1D( colorCorrectionTex, sample.r ).r;
sample.g = TORQUE_TEX1D( colorCorrectionTex, sample.g ).g;
sample.b = TORQUE_TEX1D( colorCorrectionTex, sample.b ).b;
// Apply gamma correction
sample.rgb = pow( abs(sample.rgb), g_fOneOverGamma );
// Apply contrast
sample.rgb = ((sample.rgb - 0.5f) * Contrast) + 0.5f;
// Apply brightness
sample.rgb += Brightness;
return sample;
}

View file

@ -23,11 +23,13 @@
#include "../../../gl/torque.glsl"
#include "../../../gl/hlslCompat.glsl"
#include "../../gl/postFX.glsl"
#include "shadergen:/autogenConditioners.h"
uniform sampler2D sceneTex;
uniform sampler2D luminanceTex;
uniform sampler2D bloomTex;
uniform sampler1D colorCorrectionTex;
uniform sampler2D prepassTex;
uniform vec2 texSize0;
uniform vec2 texSize2;
@ -47,6 +49,7 @@ uniform float Contrast;
out vec4 OUT_col;
void main()
{
vec4 _sample = hdrDecode( texture( sceneTex, IN_uv0 ) );
@ -85,7 +88,9 @@ void main()
}
// Add the bloom effect.
_sample += g_fBloomScale * bloom;
float depth = prepassUncondition( prepassTex, IN_uv0 ).w;
if (depth>0.9999)
_sample += g_fBloomScale * bloom;
// Apply the color correction.
_sample.r = texture( colorCorrectionTex, _sample.r ).r;
@ -94,12 +99,12 @@ void main()
// Apply gamma correction
_sample.rgb = pow( abs(_sample.rgb), vec3(g_fOneOverGamma) );
// Apply contrast
_sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f;
// Apply brightness
_sample.rgb += Brightness;
OUT_col = _sample;
}

View file

@ -22,15 +22,14 @@
#include "../postFx.hlsl"
#include "../../torque.hlsl"
#include "shadergen:/autogenConditioners.h"
uniform sampler2D inputTex : register(S0);
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
uniform float brightPassThreshold;
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float4 sample = hdrDecode( tex2D( inputTex, IN.uv0 ) );
float4 sample = hdrDecode( TORQUE_TEX2D( inputTex, IN.uv0 ) );
// Determine the brightness of this particular pixel.
float lum = hdrLuminance( sample.rgb );

View file

@ -23,7 +23,7 @@
#include "../../torque.hlsl"
#include "../postFx.hlsl"
uniform sampler2D inputTex : register( S0 );
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
uniform float2 texSize0;
uniform float g_fMinLuminace;
@ -36,7 +36,7 @@ static float2 gTapOffsets[9] =
};
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float2 tsize = 1.0 / texSize0;
@ -46,7 +46,7 @@ float4 main( PFXVertToPix IN ) : COLOR
for ( int i = 0; i < 9; i++ )
{
// Decode the hdr value.
sample = hdrDecode( tex2D( inputTex, IN.uv0 + ( gTapOffsets[i] * tsize ) ).rgb );
sample = hdrDecode( TORQUE_TEX2D( inputTex, IN.uv0 + ( gTapOffsets[i] * tsize ) ).rgb );
// Get the luminance and add it to the average.
float lum = max( hdrLuminance( sample ), g_fMinLuminace );

View file

@ -22,7 +22,7 @@
#include "../postFx.hlsl"
uniform sampler2D inputTex : register( S0 );
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
uniform float2 oneOverTargetSize;
@ -34,7 +34,7 @@ static float2 gTapOffsets[16] =
{ -1.5, 1.5 }, { -0.5, 1.5 }, { 0.5, 1.5 }, { 1.5, 1.5 }
};
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float2 pixelSize = oneOverTargetSize;
@ -42,7 +42,7 @@ float4 main( PFXVertToPix IN ) : COLOR
for ( int i = 0; i < 16; i++ )
{
float lum = tex2D( inputTex, IN.uv0 + ( gTapOffsets[i] * pixelSize ) ).r;
float lum = TORQUE_TEX2D( inputTex, IN.uv0 + ( gTapOffsets[i] * pixelSize ) ).r;
average += lum;
}

View file

@ -20,29 +20,29 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../shaderModelAutoGen.hlsl"
#include "../postFx.hlsl"
uniform sampler2D backBuffer : register( s0 ); // The original backbuffer.
uniform sampler2D prepassTex : register( s1 ); // The pre-pass depth and normals.
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 1);
uniform float brightScalar;
static const float3 LUMINANCE_VECTOR = float3(0.3125f, 0.6154f, 0.0721f);
float4 main( PFXVertToPix IN ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float4 col = float4( 0, 0, 0, 1 );
// Get the depth at this pixel.
float depth = prepassUncondition( prepassTex, IN.uv0 ).w;
float depth = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
// If the depth is equal to 1.0, read from the backbuffer
// and perform the exposure calculation on the result.
if ( depth >= 0.999 )
{
col = tex2D( backBuffer, IN.uv0 );
col = TORQUE_TEX2D( backBuffer, IN.uv0 );
//col = 1 - exp(-120000 * col);
col += dot( col.rgb, LUMINANCE_VECTOR ) + 0.0001f;

View file

@ -22,28 +22,29 @@
#include "../postFx.hlsl"
uniform sampler2D frameSampler : register( s0 );
uniform sampler2D backBuffer : register( s1 );
TORQUE_UNIFORM_SAMPLER2D(frameSampler, 0);
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 1);
uniform float3 camForward;
uniform int numSamples;
uniform float3 lightDirection;
uniform float density;
uniform float2 screenSunPos;
uniform float2 oneOverTargetSize;
uniform int numSamples;
uniform float density;
uniform float weight;
uniform float decay;
uniform float exposure;
float4 main( PFXVertToPix IN ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float4 texCoord = float4( IN.uv0.xy, 0, 0 );
// Store initial sample.
half3 color = (half3)tex2D( frameSampler, texCoord.xy ).rgb;
half3 color = (half3)TORQUE_TEX2D( frameSampler, texCoord.xy ).rgb;
// Store original bb color.
float4 bbCol = tex2D( backBuffer, IN.uv1 );
float4 bbCol = TORQUE_TEX2D( backBuffer, IN.uv1 );
// Set up illumination decay factor.
half illuminationDecay = 1.0;
@ -68,7 +69,7 @@ float4 main( PFXVertToPix IN ) : COLOR0
texCoord.xy -= deltaTexCoord;
// Retrieve sample at new location.
half3 sample = (half3)tex2Dlod( frameSampler, texCoord );
half3 sample = (half3)TORQUE_TEX2DLOD( frameSampler, texCoord );
// Apply sample attenuation scale/decay factors.
sample *= half(illuminationDecay * weight);

View file

@ -22,23 +22,22 @@
#include "./postFx.hlsl"
#include "../torque.hlsl"
#include "shadergen:/autogenConditioners.h"
#include "../shaderModelAutoGen.hlsl"
uniform float4x4 matPrevScreenToWorld;
uniform float4x4 matWorldToScreen;
// Passed in from setShaderConsts()
uniform float velocityMultiplier;
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 1);
uniform sampler2D backBuffer : register(S0);
uniform sampler2D prepassTex : register(S1);
float4 main(PFXVertToPix IN) : COLOR0
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
{
float samples = 5;
// First get the prepass texture for uv channel 0
float4 prepass = prepassUncondition( prepassTex, IN.uv0 );
float4 prepass = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 );
// Next extract the depth
float depth = prepass.a;
@ -58,12 +57,12 @@ float4 main(PFXVertToPix IN) : COLOR0
float2 velocity = ((screenPos - previousPos) / velocityMultiplier).xy;
// Generate the motion blur
float4 color = tex2D(backBuffer, IN.uv0);
float4 color = TORQUE_TEX2D(backBuffer, IN.uv0);
IN.uv0 += velocity;
for(int i = 1; i<samples; ++i, IN.uv0 += velocity)
{
float4 currentColor = tex2D(backBuffer, IN.uv0);
float4 currentColor = TORQUE_TEX2D(backBuffer, IN.uv0);
color += currentColor;
}

View file

@ -24,7 +24,7 @@
#include "../postFx.hlsl"
#include "../../torque.hlsl"
uniform sampler2D backBuffer : register(S0);
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
uniform float3 LensCenter; // x=Left X, y=Right X, z=Y
uniform float2 ScreenCenter;
@ -33,7 +33,7 @@ uniform float2 ScaleIn;
uniform float4 HmdWarpParam;
uniform float4 HmdChromaAbParam; // Chromatic aberration correction
float4 main( PFXVertToPix IN ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float2 texCoord;
float xOffset;
@ -75,18 +75,18 @@ float4 main( PFXVertToPix IN ) : COLOR0
{
// Now do blue texture lookup.
tcBlue.x += xOffset;
float blue = tex2D(backBuffer, tcBlue).b;
float blue = TORQUE_TEX2D(backBuffer, tcBlue).b;
// Do green lookup (no scaling).
float2 tcGreen = lensCenter + Scale * theta1;
tcGreen.x += xOffset;
float green = tex2D(backBuffer, tcGreen).g;
float green = TORQUE_TEX2D(backBuffer, tcGreen).g;
// Do red scale and lookup.
float2 thetaRed = theta1 * (HmdChromaAbParam.x + HmdChromaAbParam.y * rSq);
float2 tcRed = lensCenter + Scale * thetaRed;
tcRed.x += xOffset;
float red = tex2D(backBuffer, tcRed).r;
float red = TORQUE_TEX2D(backBuffer, tcRed).r;
color = float4(red, green, blue, 1);
}

View file

@ -20,11 +20,10 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../postFx.hlsl"
#include "../../torque.hlsl"
uniform sampler2D backBuffer : register(S0);
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
uniform float3 LensCenter; // x=Left X, y=Right X, z=Y
uniform float2 ScreenCenter;
@ -43,7 +42,7 @@ float2 HmdWarp(float2 in01, float2 lensCenter)
return lensCenter + Scale * theta1;
}
float4 main( PFXVertToPix IN ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float2 texCoord;
float xOffset;
@ -74,7 +73,7 @@ float4 main( PFXVertToPix IN ) : COLOR0
else
{
tc.x += xOffset;
color = tex2D(backBuffer, tc);
color = TORQUE_TEX2D(backBuffer, tc);
}
return color;

View file

@ -20,15 +20,14 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../postFx.hlsl"
#include "../../torque.hlsl"
uniform sampler2D backBuffer : register(S0);
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
uniform float2 LensXOffsets;
float4 main( PFXVertToPix IN ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float2 texCoord;
float xOffset;
@ -54,7 +53,7 @@ float4 main( PFXVertToPix IN ) : COLOR0
texCoord.x *= 0.5;
texCoord.x += 0.25;
float4 color = tex2D(backBuffer, texCoord);
float4 color = TORQUE_TEX2D(backBuffer, texCoord);
return color;
}

View file

@ -22,9 +22,9 @@
#include "./postFx.hlsl"
uniform sampler2D inputTex : register(S0);
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
return tex2D( inputTex, IN.uv0 );
return TORQUE_TEX2D( inputTex, IN.uv0 );
}

View file

@ -20,17 +20,18 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../shaderModel.hlsl"
struct PFXVert
{
float4 pos : POSITION;
float3 pos : POSITION;
float2 uv : TEXCOORD0;
float3 wsEyeRay : TEXCOORD1;
};
struct PFXVertToPix
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
float2 uv2 : TEXCOORD2;

View file

@ -33,7 +33,7 @@ PFXVertToPix main( PFXVert IN )
{
PFXVertToPix OUT;
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 );

View file

@ -20,15 +20,15 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
//#include "./../postFx.hlsl"
#include "../../ShaderModelAutoGen.hlsl"
#include "./../postFx.hlsl"
uniform sampler2D occludeMap : register(S0);
uniform sampler2D prepassMap : register(S1);
TORQUE_UNIFORM_SAMPLER2D(occludeMap, 0);
TORQUE_UNIFORM_SAMPLER2D(prepassMap, 1);
struct VertToPix
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
@ -49,7 +49,7 @@ uniform float blurNormalTol;
void sample( float2 uv, float weight, float4 centerTap, inout int usedCount, inout float occlusion, inout float total )
{
//return;
float4 tap = prepassUncondition( prepassMap, uv );
float4 tap = TORQUE_PREPASS_UNCONDITION( prepassMap, uv );
if ( abs( tap.a - centerTap.a ) < blurDepthTol )
{
@ -57,19 +57,19 @@ void sample( float2 uv, float weight, float4 centerTap, inout int usedCount, ino
{
usedCount++;
total += weight;
occlusion += tex2D( occludeMap, uv ).r * weight;
occlusion += TORQUE_TEX2D( occludeMap, uv ).r * weight;
}
}
}
float4 main( VertToPix IN ) : COLOR
float4 main( VertToPix IN ) : TORQUE_TARGET0
{
//float4 centerTap;
float4 centerTap = prepassUncondition( prepassMap, IN.uv0.zw );
float4 centerTap = TORQUE_PREPASS_UNCONDITION( prepassMap, IN.uv0.zw );
//return centerTap;
//float centerOcclude = tex2D( occludeMap, IN.uv0.zw ).r;
//float centerOcclude = TORQUE_TEX2D( occludeMap, IN.uv0.zw ).r;
//return float4( centerOcclude.rrr, 1 );
float4 kernel = float4( 0.175, 0.275, 0.375, 0.475 ); //25f;
@ -88,7 +88,7 @@ float4 main( VertToPix IN ) : COLOR
sample( IN.uv6, kernel.z, centerTap, usedCount, occlusion, total );
sample( IN.uv7, kernel.w, centerTap, usedCount, occlusion, total );
occlusion += tex2D( occludeMap, IN.uv0.zw ).r * 0.5;
occlusion += TORQUE_TEX2D( occludeMap, IN.uv0.zw ).r * 0.5;
total += 0.5;
//occlusion /= 3.0;
@ -100,7 +100,7 @@ float4 main( VertToPix IN ) : COLOR
//return float4( 0,0,0,occlusion );
//float3 color = tex2D( colorMap, IN.uv0.zw );
//float3 color = TORQUE_TEX2D( colorMap, IN.uv0.zw );
//return float4( color, occlusion );
}

View file

@ -25,12 +25,12 @@
uniform float2 texSize0;
uniform float2 oneOverTargetSize;
uniform float4 rtParams0;
uniform float2 oneOverTargetSize;
struct VertToPix
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 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 );

View file

@ -20,15 +20,15 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../ShaderModelAutoGen.hlsl"
#include "./../postFx.hlsl"
#define DOSMALL
#define DOLARGE
uniform sampler2D prepassMap : register(S0);
uniform sampler2D randNormalTex : register(S1);
uniform sampler1D powTable : register(S2);
TORQUE_UNIFORM_SAMPLER2D(prepassMap,0);
TORQUE_UNIFORM_SAMPLER2D(randNormalTex,1);
TORQUE_UNIFORM_SAMPLER1D(powTable,2);
uniform float2 nearFar;
uniform float2 worldToScreenScale;
@ -95,11 +95,11 @@ float getOcclusion( float depthDiff, float depthMin, float depthMax, float depth
normalDiff *= 1.0 - ( dt * 0.5 + 0.5 );
return ( 1.0 - tex1D( powTable, delta ).r ) * normalDiff;
return ( 1.0 - TORQUE_TEX1D( powTable, delta ).r ) * normalDiff;
}
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float3 ptSphere[32] =
{
@ -140,10 +140,10 @@ float4 main( PFXVertToPix IN ) : COLOR
// Sample a random normal for reflecting the
// sphere vector later in our loop.
float4 noiseMapUV = float4( ( IN.uv1 * ( targetSize / texSize1 ) ).xy, 0, 0 );
float3 reflectNormal = normalize( tex2Dlod( randNormalTex, noiseMapUV ).xyz * 2.0 - 1.0 );
float3 reflectNormal = normalize( TORQUE_TEX2DLOD( randNormalTex, noiseMapUV ).xyz * 2.0 - 1.0 );
//return float4( reflectNormal, 1 );
float4 prepass = prepassUncondition( prepassMap, IN.uv0 );
float4 prepass = TORQUE_PREPASS_UNCONDITION( prepassMap, IN.uv0 );
float3 normal = prepass.xyz;
float depth = prepass.a;
//return float4( ( depth ).xxx, 1 );
@ -197,7 +197,7 @@ float4 main( PFXVertToPix IN ) : COLOR
se = ep + ray;
occluderFragment = prepassUncondition( prepassMap, se.xy );
occluderFragment = TORQUE_PREPASS_UNCONDITION( prepassMap, se.xy );
depthDiff = se.z - occluderFragment.a;
@ -246,7 +246,7 @@ float4 main( PFXVertToPix IN ) : COLOR
se = ep + ray;
occluderFragment = prepassUncondition( prepassMap, se.xy );
occluderFragment = TORQUE_PREPASS_UNCONDITION( prepassMap, se.xy );
depthDiff = se.z - occluderFragment.a;

View file

@ -22,7 +22,7 @@
#include "./../postFx.hlsl"
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float power = pow( max( IN.uv0.x, 0 ), 0.1 );
return float4( power, 0, 0, 1 );

View file

@ -33,7 +33,7 @@ PFXVertToPix main( PFXVert IN )
{
PFXVertToPix OUT;
OUT.hpos = IN.pos;
OUT.hpos = float4(IN.pos,1.0);
OUT.uv0 = IN.uv; //viewportCoordToRenderTarget( IN.uv, rtParams0 );
OUT.uv1 = IN.uv; //viewportCoordToRenderTarget( IN.uv, rtParams1 );
OUT.uv2 = IN.uv; //viewportCoordToRenderTarget( IN.uv, rtParams2 );

View file

@ -25,8 +25,10 @@
uniform float accumTime;
uniform float2 projectionOffset;
uniform float4 targetViewport;
TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
float4 main( PFXVertToPix IN, uniform sampler2D inputTex : register(S0) ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float speed = 2.0;
float distortion = 6.0;
@ -38,5 +40,5 @@ float4 main( PFXVertToPix IN, uniform sampler2D inputTex : register(S0) ) : COLO
y = clamp(y, targetViewport.y, targetViewport.w);
x = clamp(x, targetViewport.x, targetViewport.z);
return tex2D (inputTex, float2(x, y));
return TORQUE_TEX2D(inputTex, float2(x, y));
}

View file

@ -20,10 +20,9 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "./postFx.hlsl"
#include "../torque.hlsl"
#include "../shaderModelAutoGen.hlsl"
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
@ -38,24 +37,25 @@
// Uniforms
//-----------------------------------------------------------------------------
uniform sampler2D prepassTex : register(S0);
uniform sampler2D backbuffer : register(S1);
uniform sampler1D waterDepthGradMap : register(S2);
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 0);
TORQUE_UNIFORM_SAMPLER2D(backbuffer, 1);
TORQUE_UNIFORM_SAMPLER1D(waterDepthGradMap, 2);
uniform float3 eyePosWorld;
uniform float waterDepthGradMax;
uniform float3 ambientColor;
uniform float4 waterColor;
uniform float4 waterFogData;
uniform float4 waterFogPlane;
uniform float2 nearFar;
uniform float4 rtParams0;
uniform float waterDepthGradMax;
float4 main( PFXVertToPix IN ) : COLOR
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
//float2 prepassCoord = IN.uv0;
//IN.uv0 = ( IN.uv0.xy * rtParams0.zw ) + rtParams0.xy;
float depth = prepassUncondition( prepassTex, IN.uv0 ).w;
float depth = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
//return float4( depth.rrr, 1 );
// Skip fogging the extreme far plane so that
@ -124,11 +124,11 @@ float4 main( PFXVertToPix IN ) : COLOR
//return float4( fogAmt.rrr, 1 );
// Calculate the water "base" color based on depth.
float4 fogColor = waterColor * tex1D( waterDepthGradMap, saturate( delta / waterDepthGradMax ) );
float4 fogColor = waterColor * TORQUE_TEX1D( waterDepthGradMap, saturate( delta / waterDepthGradMax ) );
// Modulate baseColor by the ambientColor.
fogColor *= float4( ambientColor.rgb, 1 );
float3 inColor = hdrDecode( tex2D( backbuffer, IN.uv0 ).rgb );
float3 inColor = hdrDecode( TORQUE_TEX2D( backbuffer, IN.uv0 ).rgb );
inColor.rgb *= 1.0 - saturate( abs( planeDist ) / WET_DEPTH ) * WET_DARKENING;
//return float4( inColor, 1 );

View file

@ -21,15 +21,14 @@
//-----------------------------------------------------------------------------
#include "../postFx.hlsl"
#include "shadergen:/autogenConditioners.h"
uniform sampler2D backBuffer : register(S0);
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
uniform float Vmax;
uniform float Vmin;
float4 main(PFXVertToPix IN) : COLOR0
float4 main(PFXVertToPix IN) : TORQUE_TARGET0
{
float4 base = tex2D(backBuffer, IN.uv0);
float4 base = TORQUE_TEX2D(backBuffer, IN.uv0);
float dist = distance(IN.uv0, float2(0.5,0.5));
base.rgb *= smoothstep(Vmax, Vmin, dist);
return base;