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

@ -1,6 +1,6 @@
singleton ShaderData( ClearGBufferShader )
{
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
DXVertexShaderFile = "shaders/common/lighting/advanced/deferredClearGBufferV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/deferredClearGBufferP.hlsl";
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";

View file

@ -21,44 +21,44 @@
//-----------------------------------------------------------------------------
// Volumetric Fog final pixel shader V2.00
#include "shadergen:/autogenConditioners.h"
#include "../shaderModel.hlsl"
#include "../shaderModelAutoGen.hlsl"
#include "../torque.hlsl"
uniform sampler2D prepassTex : register(S0);
uniform sampler2D depthBuffer : register(S1);
uniform sampler2D frontBuffer : register(S2);
uniform sampler2D density : register(S3);
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 0);
TORQUE_UNIFORM_SAMPLER2D(depthBuffer, 1);
TORQUE_UNIFORM_SAMPLER2D(frontBuffer, 2);
TORQUE_UNIFORM_SAMPLER2D(density, 3);
uniform float3 ambientColor;
uniform float accumTime;
uniform float4 fogColor;
uniform float4 modspeed;//xy speed layer 1, zw speed layer 2
uniform float2 viewpoint;
uniform float2 texscale;
uniform float fogDensity;
uniform float preBias;
uniform float textured;
uniform float modstrength;
uniform float4 modspeed;//xy speed layer 1, zw speed layer 2
uniform float2 viewpoint;
uniform float2 texscale;
uniform float3 ambientColor;
uniform float numtiles;
uniform float fadesize;
uniform float2 PixelSize;
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 htpos : TEXCOORD0;
float2 uv0 : TEXCOORD1;
};
float4 main( ConnectData IN ) : COLOR0
float4 main( ConnectData IN ) : TORQUE_TARGET0
{
float2 uvscreen=((IN.htpos.xy/IN.htpos.w) + 1.0 ) / 2.0;
uvscreen.y = 1.0 - uvscreen.y;
float obj_test = prepassUncondition( prepassTex, uvscreen).w * preBias;
float depth = tex2D(depthBuffer,uvscreen).r;
float front = tex2D(frontBuffer,uvscreen).r;
float obj_test = TORQUE_PREPASS_UNCONDITION(prepassTex, uvscreen).w * preBias;
float depth = TORQUE_TEX2D(depthBuffer, uvscreen).r;
float front = TORQUE_TEX2D(frontBuffer, uvscreen).r;
if (depth <= front)
return float4(0,0,0,0);
@ -73,8 +73,8 @@ float4 main( ConnectData IN ) : COLOR0
{
float2 offset = viewpoint + ((-0.5 + (texscale * uvscreen)) * numtiles);
float2 mod1 = tex2D(density,(offset + (modspeed.xy*accumTime))).rg;
float2 mod2= tex2D(density,(offset + (modspeed.zw*accumTime))).rg;
float2 mod1 = TORQUE_TEX2D(density, (offset + (modspeed.xy*accumTime))).rg;
float2 mod2 = TORQUE_TEX2D(density, (offset + (modspeed.zw*accumTime))).rg;
diff = (mod2.r + mod1.r) * modstrength;
col *= (2.0 - ((mod1.g + mod2.g) * fadesize))/2.0;
}

View file

@ -21,14 +21,15 @@
//-----------------------------------------------------------------------------
// Volumetric Fog prepass pixel shader V1.00
#include "../shaderModel.hlsl"
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 pos : TEXCOORD0;
};
float4 main( ConnectData IN ) : COLOR0
float4 main( ConnectData IN ) : TORQUE_TARGET0
{
float OUT;

View file

@ -22,11 +22,12 @@
// Volumetric Fog prepass vertex shader V1.00
#include "shaders/common/hlslstructs.h"
#include "../shaderModel.hlsl"
#include "../hlslStructs.hlsl"
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 pos : TEXCOORD0;
};
@ -35,12 +36,9 @@ uniform float4x4 modelView;
ConnectData main( VertexIn_P IN)
{
ConnectData OUT;
float4 inPos = IN.pos;
inPos.w = 1.0;
OUT.hpos = mul( modelView, inPos );
OUT.pos = OUT.hpos;
OUT.hpos = mul(modelView, float4(IN.pos, 1.0));
OUT.pos = OUT.hpos;
return OUT;
return OUT;
}

View file

@ -21,17 +21,18 @@
//-----------------------------------------------------------------------------
// Volumetric Fog Reflection pixel shader V1.00
#include "../shaderModel.hlsl"
uniform float4 fogColor;
uniform float fogDensity;
uniform float reflStrength;
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 pos : TEXCOORD0;
};
float4 main( ConnectData IN ) : COLOR0
float4 main( ConnectData IN ) : TORQUE_TARGET0
{
return float4(fogColor.rgb,saturate(fogDensity*reflStrength));
}

View file

@ -22,24 +22,25 @@
// Volumetric Fog final vertex shader V1.00
#include "shaders/common/hlslstructs.h"
#include "../shaderModel.hlsl"
#include "../hlslStructs.hlsl"
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 htpos : TEXCOORD0;
float2 uv0 : TEXCOORD1;
};
uniform float4x4 modelView;
ConnectData main( VertexIn_PNT IN)
ConnectData main( VertexIn_PNTT IN)
{
ConnectData OUT;
ConnectData OUT;
OUT.hpos = mul(modelView, IN.pos);
OUT.hpos = mul(modelView, float4(IN.pos,1.0));
OUT.htpos = OUT.hpos;
OUT.uv0 = IN.uv0;
return OUT;
return OUT;
}

View file

@ -24,14 +24,14 @@
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 texCoord : TEXCOORD0;
};
uniform sampler2D diffuseMap : register(S0);
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
float4 main( ConnectData IN ) : COLOR
float4 main( ConnectData IN ) : TORQUE_TARGET0
{
float4 col = tex2D( diffuseMap, IN.texCoord );
float4 col = TORQUE_TEX2D(diffuseMap, IN.texCoord);
return hdrEncode( col );
}

View file

@ -20,40 +20,40 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shaderModel.hlsl"
struct CloudVert
{
float4 pos : POSITION;
float3 normal : NORMAL;
float3 binormal : BINORMAL;
float3 tangent : TANGENT;
float3 pos : POSITION;
float2 uv0 : TEXCOORD0;
};
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 texCoord : TEXCOORD0;
};
uniform float4x4 modelview;
uniform float accumTime;
uniform float texScale;
uniform float2 texDirection;
uniform float2 texOffset;
uniform float accumTime;
uniform float texScale;
ConnectData main( CloudVert IN )
{
{
ConnectData OUT;
OUT.hpos = mul(modelview, IN.pos);
OUT.hpos = mul(modelview, float4(IN.pos,1.0));
OUT.hpos.w = OUT.hpos.z;
float2 uv = IN.uv0;
uv += texOffset;
uv *= texScale;
uv += accumTime * texDirection;
OUT.texCoord = uv;
OUT.texCoord = uv;
return OUT;
}

View file

@ -20,6 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shaderModel.hlsl"
#include "torque.hlsl"
//-----------------------------------------------------------------------------
@ -27,7 +28,7 @@
//-----------------------------------------------------------------------------
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 texCoord12 : TEXCOORD0;
float4 texCoord34 : TEXCOORD1;
float3 vLightTS : TEXCOORD2; // light vector in tangent space, denormalized
@ -38,7 +39,7 @@ struct ConnectData
//-----------------------------------------------------------------------------
// Uniforms
//-----------------------------------------------------------------------------
uniform sampler2D normalHeightMap : register(S0);
TORQUE_UNIFORM_SAMPLER2D(normalHeightMap, 0);
uniform float3 ambientColor;
uniform float3 sunColor;
uniform float cloudCoverage;
@ -99,7 +100,7 @@ float3 ComputeIllumination( float2 texCoord,
return finalColor;
}
float4 main( ConnectData IN ) : COLOR
float4 main( ConnectData IN ) : TORQUE_TARGET0
{
// Normalize the interpolated vectors:
float3 vViewTS = normalize( IN.vViewTS );
@ -109,11 +110,11 @@ float4 main( ConnectData IN ) : COLOR
float2 texSample = IN.texCoord12.xy;
float4 noise1 = tex2D( normalHeightMap, IN.texCoord12.zw );
float4 noise1 = TORQUE_TEX2D( normalHeightMap, IN.texCoord12.zw );
noise1 = normalize( ( noise1 - 0.5 ) * 2.0 );
//return noise1;
float4 noise2 = tex2D( normalHeightMap, IN.texCoord34.xy );
float4 noise2 = TORQUE_TEX2D(normalHeightMap, IN.texCoord34.xy);
noise2 = normalize( ( noise2 - 0.5 ) * 2.0 );
//return noise2;
@ -122,7 +123,7 @@ float4 main( ConnectData IN ) : COLOR
float noiseHeight = noise1.a * noise2.a * ( cloudCoverage / 2.0 + 0.5 );
float3 vNormalTS = normalize( tex2D( normalHeightMap, texSample ).xyz * 2.0 - 1.0 );
float3 vNormalTS = normalize( TORQUE_TEX2D(normalHeightMap, texSample).xyz * 2.0 - 1.0);
vNormalTS += noiseNormal;
vNormalTS = normalize( vNormalTS );
@ -130,7 +131,7 @@ float4 main( ConnectData IN ) : COLOR
cResultColor.rgb = ComputeIllumination( texSample, vLightTS, vViewTS, vNormalTS );
float coverage = ( cloudCoverage - 0.5 ) * 2.0;
cResultColor.a = tex2D( normalHeightMap, texSample ).a + coverage + noiseHeight;
cResultColor.a = TORQUE_TEX2D(normalHeightMap, texSample).a + coverage + noiseHeight;
if ( cloudCoverage > -1.0 )
cResultColor.a /= 1.0 + coverage;

View file

@ -23,10 +23,11 @@
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
#include "shaderModel.hlsl"
struct CloudVert
{
float4 pos : POSITION;
float3 pos : POSITION;
float3 normal : NORMAL;
float3 binormal : BINORMAL;
float3 tangent : TANGENT;
@ -35,7 +36,7 @@ struct CloudVert
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 texCoord12 : TEXCOORD0;
float4 texCoord34 : TEXCOORD1;
float3 vLightTS : TEXCOORD2; // light vector in tangent space, denormalized
@ -60,9 +61,9 @@ uniform float3 texScale;
ConnectData main( CloudVert IN )
{
ConnectData OUT;
OUT.hpos = mul(modelview, IN.pos);
OUT.hpos = mul(modelview, float4(IN.pos,1.0));
OUT.hpos.w = OUT.hpos.z;
// Offset the uv so we don't have a seam directly over our head.
float2 uv = IN.uv0 + float2( 0.5, 0.5 );
@ -85,7 +86,7 @@ ConnectData main( CloudVert IN )
float3 vBinormalWS = -IN.binormal;
// Compute position in world space:
float4 vPositionWS = IN.pos + float4( eyePosWorld, 1 ); //mul( IN.pos, objTrans );
float4 vPositionWS = float4(IN.pos, 1.0) + float4(eyePosWorld, 1); //mul( IN.pos, objTrans );
// Compute and output the world view vector (unnormalized):
float3 vViewWS = eyePosWorld - vPositionWS.xyz;

View file

@ -20,9 +20,18 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
float4 main( float4 color_in : COLOR0,
float2 texCoord_in : TEXCOORD0,
uniform sampler2D diffuseMap : register(S0) ) : COLOR0
#include "../shaderModel.hlsl"
struct Conn
{
return float4(color_in.rgb, color_in.a * tex2D(diffuseMap, texCoord_in).a);
float4 HPOS : TORQUE_POSITION;
float4 color : COLOR;
float2 texCoord : TEXCOORD0;
};
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
float4 main( Conn IN ) : TORQUE_TARGET0
{
return float4(IN.color.rgb, IN.color.a * TORQUE_TEX2D(diffuseMap, IN.texCoord).a);
}

View file

@ -20,22 +20,28 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../shaderModel.hlsl"
struct Appdata
{
float4 position : POSITION;
float3 position : POSITION;
float4 color : COLOR;
float2 texCoord : TEXCOORD0;
};
struct Conn
{
float4 HPOS : POSITION;
float4 HPOS : TORQUE_POSITION;
float4 color : COLOR;
float2 texCoord : TEXCOORD0;
};
Conn main( Appdata In, uniform float4x4 modelview : register(C0) )
uniform float4x4 modelview;
Conn main( Appdata In )
{
Conn Out;
Out.HPOS = mul(modelview, In.position);
Out.HPOS = mul(modelview, float4(In.position,1.0));
Out.color = In.color;
Out.texCoord = In.texCoord;
return Out;

View file

@ -20,7 +20,15 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
float4 main( float4 color_in : COLOR0, uniform sampler2D diffuseMap : register(S0) ) : COLOR0
#include "../shaderModel.hlsl"
struct Conn
{
return color_in;
float4 HPOS : TORQUE_POSITION;
float4 color : COLOR;
};
float4 main(Conn IN) : TORQUE_TARGET0
{
return IN.color;
}

View file

@ -20,20 +20,26 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../shaderModel.hlsl"
struct Appdata
{
float4 position : POSITION;
float3 position : POSITION;
float4 color : COLOR;
};
struct Conn
{
float4 HPOS : POSITION;
float4 HPOS : TORQUE_POSITION;
float4 color : COLOR;
};
Conn main( Appdata In, uniform float4x4 modelview : register(C0) )
uniform float4x4 modelview;
Conn main( Appdata In )
{
Conn Out;
Out.HPOS = mul(modelview, In.position);
Out.HPOS = mul(modelview, float4(In.position,1.0));
Out.color = In.color;
return Out;
}

View file

@ -20,9 +20,18 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
float4 main( float4 color_in : COLOR0,
float2 texCoord_in : TEXCOORD0,
uniform sampler2D diffuseMap : register(S0) ) : COLOR0
#include "../shaderModel.hlsl"
struct Conn
{
return tex2D(diffuseMap, texCoord_in) * color_in;
float4 HPOS : TORQUE_POSITION;
float4 color : COLOR;
float2 texCoord : TEXCOORD0;
};
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
float4 main( Conn IN ) : TORQUE_TARGET0
{
return TORQUE_TEX2D(diffuseMap, IN.texCoord) * IN.color;
}

View file

@ -20,22 +20,28 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../shaderModel.hlsl"
struct Appdata
{
float4 position : POSITION;
float3 position : POSITION;
float4 color : COLOR;
float2 texCoord : TEXCOORD0;
};
struct Conn
{
float4 HPOS : POSITION;
float4 HPOS : TORQUE_POSITION;
float4 color : COLOR;
float2 texCoord : TEXCOORD0;
};
Conn main( Appdata In, uniform float4x4 modelview : register(C0) )
uniform float4x4 modelview;
Conn main( Appdata In )
{
Conn Out;
Out.HPOS = mul(modelview, In.position);
Out.HPOS = mul(modelview, float4(In.position,1.0));
Out.color = In.color;
Out.texCoord = In.texCoord;
return Out;

View file

@ -0,0 +1,36 @@
//-----------------------------------------------------------------------------
// 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 "../shaderModel.hlsl"
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
struct Conn
{
float4 hpos : TORQUE_POSITION;
float2 texCoord : TEXCOORD0;
};
float4 main(Conn IN) : TORQUE_TARGET0
{
return TORQUE_TEX2D(diffuseMap, IN.texCoord);
}

View file

@ -0,0 +1,46 @@
//-----------------------------------------------------------------------------
// 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 "../shaderModel.hlsl"
struct Appdata
{
float3 position : POSITION;
float4 color : COLOR;
float2 texCoord : TEXCOORD0;
};
struct Conn
{
float4 hpos : TORQUE_POSITION;
float2 texCoord : TEXCOORD0;
};
uniform float4x4 modelview;
Conn main( Appdata In )
{
Conn Out;
Out.hpos = mul(modelview, float4(In.position, 1.0));
Out.texCoord = In.texCoord;
return Out;
}

View file

@ -30,11 +30,11 @@
#define MAX_COVERTYPES 8
uniform float2 gc_fadeParams;
uniform float2 gc_windDir;
uniform float3 gc_camRight;
uniform float3 gc_camUp;
uniform float4 gc_typeRects[MAX_COVERTYPES];
uniform float2 gc_fadeParams;
uniform float2 gc_windDir;
// .x = gust length
// .y = premultiplied simulation time and gust frequency

View file

@ -21,36 +21,39 @@
//-----------------------------------------------------------------------------
#include "shdrConsts.h"
#include "shaderModel.hlsl"
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
struct ConnectData
{
float2 texCoord : TEXCOORD0;
float4 lum : COLOR0;
float4 hpos : TORQUE_POSITION;
float2 outTexCoord : TEXCOORD0;
float4 color : COLOR0;
float4 groundAlphaCoeff : COLOR1;
float2 alphaLookup : TEXCOORD1;
};
struct Fragout
{
float4 col : COLOR0;
float4 col : TORQUE_TARGET0;
};
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
TORQUE_UNIFORM_SAMPLER2D(alphaMap, 1);
uniform float4 groundAlpha;
uniform float4 ambient;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
Fragout main( ConnectData IN,
uniform sampler2D diffuseMap : register(S0),
uniform sampler2D alphaMap : register(S1),
uniform float4 groundAlpha,
uniform float4 ambient )
Fragout main( ConnectData IN )
{
Fragout OUT;
float4 alpha = tex2D(alphaMap, IN.alphaLookup);
OUT.col = float4( ambient.rgb * IN.lum.rgb, 1.0 ) * tex2D(diffuseMap, IN.texCoord);
float4 alpha = TORQUE_TEX2D(alphaMap, IN.alphaLookup);
OUT.col = float4( ambient.rgb * IN.lum.rgb, 1.0 ) * TORQUE_TEX2D(diffuseMap, IN.texCoord);
OUT.col.a = OUT.col.a * min(alpha, groundAlpha + IN.groundAlphaCoeff.x).x;
return OUT;

View file

@ -23,39 +23,42 @@
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
#include "shaderModel.hlsl"
struct VertData
{
float2 texCoord : TEXCOORD0;
float2 waveScale : TEXCOORD1;
float3 position : POSITION;
float3 normal : NORMAL;
float4 position : POSITION;
float2 texCoord : TEXCOORD0;
float2 waveScale : TEXCOORD1;
};
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 outTexCoord : TEXCOORD0;
float4 color : COLOR0;
float4 groundAlphaCoeff : COLOR1;
float2 alphaLookup : TEXCOORD1;
};
uniform float4x4 projection : register(C0);
uniform float4x4 world : register(C4);
uniform float GlobalSwayPhase : register(C8);
uniform float SwayMagnitudeSide : register(C9);
uniform float SwayMagnitudeFront : register(C10);
uniform float GlobalLightPhase : register(C11);
uniform float LuminanceMagnitude : register(C12);
uniform float LuminanceMidpoint : register(C13);
uniform float DistanceRange : register(C14);
uniform float3 CameraPos : register(C15);
uniform float TrueBillboard : register(C16);
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
ConnectData main( VertData IN,
uniform float4x4 projection : register(C0),
uniform float4x4 world : register(C4),
uniform float GlobalSwayPhase : register(C8),
uniform float SwayMagnitudeSide : register(C9),
uniform float SwayMagnitudeFront : register(C10),
uniform float GlobalLightPhase : register(C11),
uniform float LuminanceMagnitude : register(C12),
uniform float LuminanceMidpoint : register(C13),
uniform float DistanceRange : register(C14),
uniform float3 CameraPos : register(C15),
uniform float TrueBillboard : register(C16)
)
ConnectData main( VertData IN )
{
ConnectData OUT;
@ -113,7 +116,7 @@ ConnectData main( VertData IN,
float Luminance = LuminanceMidpoint + LuminanceMagnitude * cos(GlobalLightPhase + IN.normal.y);
// Alpha
float3 worldPos = float3(IN.position.x, IN.position.y, IN.position.z);
float3 worldPos = IN.position;
float alpha = abs(distance(worldPos, CameraPos)) / DistanceRange;
alpha = clamp(alpha, 0.0f, 1.0f); //pass it through

View file

@ -20,23 +20,25 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "hlslStructs.h"
#include "hlslStructs.hlsl"
#include "shaderModel.hlsl"
struct MaterialDecoratorConnectV
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 uv0 : TEXCOORD0;
};
uniform float4x4 modelview : register(C0);
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
MaterialDecoratorConnectV main( VertexIn_PCT IN,
uniform float4x4 modelview : register(C0) )
MaterialDecoratorConnectV main( VertexIn_PCT IN )
{
MaterialDecoratorConnectV OUT;
OUT.hpos = mul(modelview, IN.pos);
OUT.hpos = mul(modelview, float4(IN.pos,1.0));
OUT.uv0 = IN.uv0;
return OUT;

View file

@ -0,0 +1,114 @@
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
// The purpose of this file is to get all of our HLSL structures into one place.
// Please use the structures here instead of redefining input and output structures
// in each shader file. If structures are added, please adhere to the naming convention.
//------------------------------------------------------------------------------
// Vertex Input Structures
//
// These structures map to FVFs/Vertex Declarations in Torque. See gfxStructs.h
//------------------------------------------------------------------------------
// Notes
//
// Position should be specified as a float3 as our vertex structures in
// the engine output float3s for position.
struct VertexIn_P
{
float3 pos : POSITION;
};
struct VertexIn_PT
{
float3 pos : POSITION;
float2 uv0 : TEXCOORD0;
};
struct VertexIn_PTTT
{
float3 pos : POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
float2 uv2 : TEXCOORD2;
};
struct VertexIn_PC
{
float3 pos : POSITION;
float4 color : DIFFUSE;
};
struct VertexIn_PNC
{
float3 pos : POSITION;
float3 normal : NORMAL;
float4 color : DIFFUSE;
};
struct VertexIn_PCT
{
float3 pos : POSITION;
float4 color : DIFFUSE;
float2 uv0 : TEXCOORD0;
};
struct VertexIn_PN
{
float3 pos : POSITION;
float3 normal : NORMAL;
};
struct VertexIn_PNT
{
float3 pos : POSITION;
float3 normal : NORMAL;
float2 uv0 : TEXCOORD0;
};
struct VertexIn_PNTT
{
float3 pos : POSITION;
float3 normal : NORMAL;
float3 tangent : TANGENT;
float2 uv0 : TEXCOORD0;
};
struct VertexIn_PNCT
{
float3 pos : POSITION;
float3 normal : NORMAL;
float4 color : DIFFUSE;
float2 uv0 : TEXCOORD0;
};
struct VertexIn_PNTTTB
{
float3 pos : POSITION;
float3 normal : NORMAL;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
float3 T : TEXCOORD2;
float3 B : TEXCOORD3;
};

View file

@ -241,7 +241,7 @@ float4 AL_DeferredOutput(
}
//specular = color * map * spec^gloss
float specularOut = (specularColor * matInfo.b * min(pow(specular, max(( matInfo.a/ AL_ConstantSpecularPower),1.0f)),matInfo.a)).r;
float specularOut = (specularColor * matInfo.b * min(pow(abs(specular), max(( matInfo.a/ AL_ConstantSpecularPower),1.0f)),matInfo.a)).r;
lightColor *= shadowAttenuation;
lightColor += ambient.rgb;

View file

@ -20,17 +20,24 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../hlslStructs.h"
#include "../../hlslStructs.hlsl"
#include "../../shaderModel.hlsl"
struct VertData
{
float3 pos : POSITION;
float4 color : COLOR;
};
struct ConvexConnectV
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 wsEyeDir : TEXCOORD0;
float4 ssPos : TEXCOORD1;
float4 vsEyeDir : TEXCOORD2;
};
ConvexConnectV main( VertexIn_P IN,
ConvexConnectV main( VertData IN,
uniform float4x4 modelview,
uniform float4x4 objTrans,
uniform float4x4 worldViewOnly,
@ -38,9 +45,9 @@ ConvexConnectV main( VertexIn_P IN,
{
ConvexConnectV OUT;
OUT.hpos = mul( modelview, IN.pos );
OUT.wsEyeDir = mul( objTrans, IN.pos ) - float4( eyePosWorld, 0.0 );
OUT.vsEyeDir = mul( worldViewOnly, IN.pos );
OUT.hpos = mul( modelview, float4(IN.pos,1.0) );
OUT.wsEyeDir = mul(objTrans, float4(IN.pos, 1.0)) - float4(eyePosWorld, 0.0);
OUT.vsEyeDir = mul(worldViewOnly, float4(IN.pos, 1.0));
OUT.ssPos = OUT.hpos;
return OUT;

View file

@ -20,12 +20,11 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../postfx/postFx.hlsl"
TORQUE_UNIFORM_SAMPLER2D(colorBufferTex,0);
float4 main( PFXVertToPix IN,
uniform sampler2D colorBufferTex : register(S0) ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
return float4(tex2D( colorBufferTex, IN.uv0 ).rgb, 1.0);
return float4(TORQUE_TEX2D( colorBufferTex, IN.uv0 ).rgb, 1.0);
}

View file

@ -20,14 +20,14 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../postfx/postFx.hlsl"
#include "../../shaderModelAutoGen.hlsl"
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 0);
TORQUE_UNIFORM_SAMPLER1D(depthViz, 1);
float4 main( PFXVertToPix IN,
uniform sampler2D prepassTex : register(S0),
uniform sampler1D depthViz : register(S1) ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float depth = prepassUncondition( prepassTex, IN.uv0 ).w;
return float4( tex1D( depthViz, depth ).rgb, 1.0 );
float depth = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
return float4( TORQUE_TEX1D( depthViz, depth ).rgb, 1.0 );
}

View file

@ -20,12 +20,11 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../postfx/postFx.hlsl"
TORQUE_UNIFORM_SAMPLER2D(glowBuffer, 0);
float4 main( PFXVertToPix IN,
uniform sampler2D glowBuffer : register(S0) ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
return tex2D(glowBuffer, IN.uv0);
return TORQUE_TEX2D(glowBuffer, IN.uv0);
}

View file

@ -20,13 +20,13 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../shaderModelAutoGen.hlsl"
#include "../../postfx/postFx.hlsl"
TORQUE_UNIFORM_SAMPLER2D(lightPrePassTex,0);
float4 main( PFXVertToPix IN,
uniform sampler2D lightPrePassTex : register(S0) ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float4 lightColor = tex2D( lightPrePassTex, IN.uv0 );
float4 lightColor = TORQUE_TEX2D( lightPrePassTex, IN.uv0 );
return float4( lightColor.rgb, 1.0 );
}

View file

@ -20,13 +20,12 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../postfx/postFx.hlsl"
TORQUE_UNIFORM_SAMPLER2D(lightPrePassTex,0);
float4 main( PFXVertToPix IN,
uniform sampler2D lightPrePassTex : register(S0) ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float specular = tex2D( lightPrePassTex, IN.uv0 ).a;
float specular = TORQUE_TEX2D( lightPrePassTex, IN.uv0 ).a;
return float4( specular, specular, specular, 1.0 );
}

View file

@ -20,13 +20,13 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../postfx/postFx.hlsl"
#include "../../shaderModelAutoGen.hlsl"
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 0);
float4 main( PFXVertToPix IN,
uniform sampler2D prepassTex : register(S0) ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float3 normal = prepassUncondition( prepassTex, IN.uv0 ).xyz;
float3 normal = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).xyz;
return float4( ( normal + 1.0 ) * 0.5, 1.0 );
}

View file

@ -20,15 +20,19 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../shaderModel.hlsl"
struct MaterialDecoratorConnectV
{
float4 hpos : TORQUE_POSITION;
float2 uv0 : TEXCOORD0;
};
float4 main( MaterialDecoratorConnectV IN,
uniform sampler2D shadowMap : register(S0),
uniform sampler1D depthViz : register(S1) ) : COLOR0
TORQUE_UNIFORM_SAMPLER2D(shadowMap, 0);
TORQUE_UNIFORM_SAMPLER1D(depthViz, 1);
float4 main( MaterialDecoratorConnectV IN ) : TORQUE_TARGET0
{
float depth = saturate( tex2D( shadowMap, IN.uv0 ).r );
return float4( tex1D( depthViz, depth ).rgb, 1 );
float depth = saturate( TORQUE_TEX2D( shadowMap, IN.uv0 ).r );
return float4( TORQUE_TEX1D( depthViz, depth ).rgb, 1 );
}

View file

@ -20,13 +20,12 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../postfx/postFx.hlsl"
TORQUE_UNIFORM_SAMPLER2D(matinfoTex,0);
float4 main( PFXVertToPix IN,
uniform sampler2D matinfoTex : register(S0) ) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float specular = tex2D( matinfoTex, IN.uv0 ).b;
float specular = TORQUE_TEX2D( matinfoTex, IN.uv0 ).b;
return float4( specular, specular, specular, 1.0 );
}

View file

@ -20,17 +20,24 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../shaderModel.hlsl"
struct Conn
{
float4 hpos : TORQUE_POSITION;
};
struct Fragout
{
float4 col : COLOR0;
float4 col1 : COLOR1;
float4 col2 : COLOR2;
float4 col : TORQUE_TARGET0;
float4 col1 : TORQUE_TARGET1;
float4 col2 : TORQUE_TARGET2;
};
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
Fragout main( )
Fragout main( Conn IN )
{
Fragout OUT;

View file

@ -0,0 +1,43 @@
//-----------------------------------------------------------------------------
// 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 "../../shaderModel.hlsl"
struct Appdata
{
float3 pos : POSITION;
float4 color : COLOR;
};
struct Conn
{
float4 hpos : TORQUE_POSITION;
};
uniform float4x4 modelview;
Conn main( Appdata In )
{
Conn Out;
Out.hpos = float4(In.pos,1.0);
return Out;
}

View file

@ -20,11 +20,13 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../shaderModel.hlsl"
struct Fragout
{
float4 col : COLOR0;
float4 col1 : COLOR1;
float4 col2 : COLOR2;
float4 col : TORQUE_TARGET0;
float4 col1 : TORQUE_TARGET1;
float4 col2 : TORQUE_TARGET2;
};
//-----------------------------------------------------------------------------

View file

@ -20,22 +20,22 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../shaderModelAutoGen.hlsl"
#include "../../postfx/postFx.hlsl"
#include "shaders/common/torque.hlsl"
TORQUE_UNIFORM_SAMPLER2D(colorBufferTex,0);
TORQUE_UNIFORM_SAMPLER2D(lightPrePassTex,1);
TORQUE_UNIFORM_SAMPLER2D(matInfoTex,2);
TORQUE_UNIFORM_SAMPLER2D(prepassTex,3);
float4 main( PFXVertToPix IN,
uniform sampler2D colorBufferTex : register(S0),
uniform sampler2D lightPrePassTex : register(S1),
uniform sampler2D matInfoTex : register(S2),
uniform sampler2D prepassTex : register(S3)) : COLOR0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float4 lightBuffer = tex2D( lightPrePassTex, IN.uv0 );
float4 colorBuffer = tex2D( colorBufferTex, IN.uv0 );
float4 matInfo = tex2D( matInfoTex, IN.uv0 );
float4 lightBuffer = TORQUE_TEX2D( lightPrePassTex, IN.uv0 );
float4 colorBuffer = TORQUE_TEX2D( colorBufferTex, IN.uv0 );
float4 matInfo = TORQUE_TEX2D( matInfoTex, IN.uv0 );
float specular = saturate(lightBuffer.a);
float depth = prepassUncondition( prepassTex, IN.uv0 ).w;
float depth = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
if (depth>0.9999)
return float4(0,0,0,0);

View file

@ -19,10 +19,11 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../shaderModel.hlsl"
struct FarFrustumQuadConnectV
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 uv0 : TEXCOORD0;
float3 wsEyeRay : TEXCOORD1;
float3 vsEyeRay : TEXCOORD2;
@ -30,6 +31,7 @@ struct FarFrustumQuadConnectV
struct FarFrustumQuadConnectP
{
float4 hpos : TORQUE_POSITION;
float2 uv0 : TEXCOORD0;
float3 wsEyeRay : TEXCOORD1;
float3 vsEyeRay : TEXCOORD2;

View file

@ -20,7 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../hlslStructs.h"
#include "../../hlslStructs.hlsl"
#include "farFrustumQuad.hlsl"
@ -36,8 +36,8 @@ FarFrustumQuadConnectV main( VertexIn_PNTT IN,
// Interpolators will generate eye rays the
// from far-frustum corners.
OUT.wsEyeRay = IN.tangent.xyz;
OUT.vsEyeRay = IN.normal.xyz;
OUT.wsEyeRay = IN.tangent;
OUT.vsEyeRay = IN.normal;
return OUT;
}

View file

@ -20,35 +20,36 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "farFrustumQuad.hlsl"
#include "lightingUtils.hlsl"
#include "../../lighting.hlsl"
#include "../../shaderModel.hlsl"
#include "../../shaderModelAutoGen.hlsl"
struct ConvexConnectP
{
float4 pos : TORQUE_POSITION;
float4 ssPos : TEXCOORD0;
float3 vsEyeDir : TEXCOORD1;
};
float4 main( ConvexConnectP IN,
uniform sampler2D prePassBuffer : register(S0),
uniform float4 lightPosition,
uniform float4 lightColor,
uniform float lightRange,
uniform float4 vsFarPlane,
uniform float4 rtParams0 ) : COLOR0
TORQUE_UNIFORM_SAMPLER2D(prePassBuffer, 0);
uniform float4 lightPosition;
uniform float4 lightColor;
uniform float lightRange;
uniform float4 vsFarPlane;
uniform float4 rtParams0;
float4 main( ConvexConnectP IN ) : TORQUE_TARGET0
{
// Compute scene UV
float3 ssPos = IN.ssPos.xyz / IN.ssPos.w;
float2 uvScene = getUVFromSSPos(ssPos, rtParams0);
// Sample/unpack the normal/z data
float4 prepassSample = prepassUncondition(prePassBuffer, uvScene);
float4 prepassSample = TORQUE_PREPASS_UNCONDITION(prePassBuffer, uvScene);
float3 normal = prepassSample.rgb;
float depth = prepassSample.a;

View file

@ -20,24 +20,26 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../hlslStructs.h"
#include "../../hlslStructs.hlsl"
#include "../../shaderModel.hlsl"
struct ConvexConnectV
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 ssPos : TEXCOORD0;
float3 vsEyeDir : TEXCOORD1;
};
ConvexConnectV main( VertexIn_P IN,
uniform float4x4 viewProj,
uniform float4x4 view,
uniform float3 particlePosWorld,
uniform float lightRange )
uniform float4x4 viewProj;
uniform float4x4 view;
uniform float3 particlePosWorld;
uniform float lightRange;
ConvexConnectV main( VertexIn_P IN )
{
ConvexConnectV OUT;
float4 vPosWorld = IN.pos + float4(particlePosWorld, 0.0) + float4(IN.pos.xyz, 0.0) * lightRange;
float4 pos = float4(IN.pos, 0.0);
float4 vPosWorld = pos + float4(particlePosWorld, 0.0) + pos * lightRange;
OUT.hpos = mul(viewProj, vPosWorld);
OUT.vsEyeDir = mul(view, vPosWorld);
OUT.ssPos = OUT.hpos;

View file

@ -20,7 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../shaderModelAutoGen.hlsl"
#include "farFrustumQuad.hlsl"
#include "lightingUtils.hlsl"
@ -31,17 +31,17 @@
struct ConvexConnectP
{
float4 pos : TORQUE_POSITION;
float4 wsEyeDir : TEXCOORD0;
float4 ssPos : TEXCOORD1;
float4 vsEyeDir : TEXCOORD2;
float4 color : COLOR0;
};
#ifdef USE_COOKIE_TEX
/// The texture for cookie rendering.
uniform samplerCUBE cookieMap : register(S3);
TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 3);
#endif
@ -53,9 +53,9 @@ uniform samplerCUBE cookieMap : register(S3);
return shadowCoord;
}
float4 shadowSample( samplerCUBE shadowMap, float3 shadowCoord )
float4 shadowSample( TORQUE_SAMPLERCUBE(shadowMap), float3 shadowCoord )
{
return texCUBE( shadowMap, shadowCoord );
return TORQUE_TEXCUBE( shadowMap, shadowCoord );
}
#else
@ -106,44 +106,44 @@ uniform samplerCUBE cookieMap : register(S3);
#endif
TORQUE_UNIFORM_SAMPLER2D(prePassBuffer, 0);
float4 main( ConvexConnectP IN,
#ifdef SHADOW_CUBE
TORQUE_UNIFORM_SAMPLERCUBE(shadowMap, 1);
#else
TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
TORQUE_UNIFORM_SAMPLER2D(dynamicShadowMap, 2);
#endif
uniform sampler2D prePassBuffer : register(S0),
TORQUE_UNIFORM_SAMPLER2D(lightBuffer, 5);
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 6);
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 7);
#ifdef SHADOW_CUBE
uniform samplerCUBE shadowMap : register(S1),
#else
uniform sampler2D shadowMap : register(S1),
uniform sampler2D dynamicShadowMap : register(S2),
#endif
uniform float4 rtParams0;
uniform float4 lightColor;
uniform sampler2D lightBuffer : register(S5),
uniform sampler2D colorBuffer : register(S6),
uniform sampler2D matInfoBuffer : register(S7),
uniform float lightBrightness;
uniform float3 lightPosition;
uniform float4 rtParams0,
uniform float4 lightMapParams;
uniform float4 vsFarPlane;
uniform float4 lightParams;
uniform float3 lightPosition,
uniform float4 lightColor,
uniform float lightBrightness,
uniform float lightRange,
uniform float2 lightAttenuation,
uniform float4 lightMapParams,
uniform float lightRange;
uniform float shadowSoftness;
uniform float2 lightAttenuation;
uniform float4 vsFarPlane,
uniform float3x3 viewToLightProj,
uniform float3x3 dynamicViewToLightProj,
uniform float3x3 viewToLightProj;
uniform float3x3 dynamicViewToLightProj;
uniform float4 lightParams,
uniform float shadowSoftness ) : COLOR0
float4 main( ConvexConnectP IN ) : TORQUE_TARGET0
{
// Compute scene UV
float3 ssPos = IN.ssPos.xyz / IN.ssPos.w;
float2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
// Emissive.
float4 matInfo = tex2D( matInfoBuffer, uvScene );
float4 matInfo = TORQUE_TEX2D( matInfoBuffer, uvScene );
bool emissive = getFlag( matInfo.r, 0 );
if ( emissive )
{
@ -151,7 +151,7 @@ float4 main( ConvexConnectP IN,
}
// Sample/unpack the normal/z data
float4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
float4 prepassSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, uvScene );
float3 normal = prepassSample.rgb;
float depth = prepassSample.a;
@ -188,14 +188,14 @@ float4 main( ConvexConnectP IN,
#ifdef SHADOW_CUBE
// TODO: We need to fix shadow cube to handle soft shadows!
float occ = texCUBE( shadowMap, mul( viewToLightProj, -lightVec ) ).r;
float occ = TORQUE_TEXCUBE( shadowMap, mul( viewToLightProj, -lightVec ) ).r;
float shadowed = saturate( exp( lightParams.y * ( occ - distToLight ) ) );
#else
// Static
float2 shadowCoord = decodeShadowCoord( mul( viewToLightProj, -lightVec ) ).xy;
float static_shadowed = softShadow_filter( shadowMap,
float static_shadowed = softShadow_filter( TORQUE_SAMPLER2D_MAKEARG(shadowMap),
ssPos.xy,
shadowCoord,
shadowSoftness,
@ -205,7 +205,7 @@ float4 main( ConvexConnectP IN,
// Dynamic
float2 dynamicShadowCoord = decodeShadowCoord( mul( dynamicViewToLightProj, -lightVec ) ).xy;
float dynamic_shadowed = softShadow_filter( dynamicShadowMap,
float dynamic_shadowed = softShadow_filter( TORQUE_SAMPLER2D_MAKEARG(dynamicShadowMap),
ssPos.xy,
dynamicShadowCoord,
shadowSoftness,
@ -223,7 +223,7 @@ float4 main( ConvexConnectP IN,
#ifdef USE_COOKIE_TEX
// Lookup the cookie sample.
float4 cookie = texCUBE( cookieMap, mul( viewToLightProj, -lightVec ) );
float4 cookie = TORQUE_TEXCUBE( cookieMap, mul( viewToLightProj, -lightVec ) );
// Multiply the light with the cookie tex.
lightcol *= cookie.rgb;
@ -263,6 +263,6 @@ float4 main( ConvexConnectP IN,
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
}
float4 colorSample = tex2D( colorBuffer, uvScene );
float4 colorSample = TORQUE_TEX2D( colorBuffer, uvScene );
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
}

View file

@ -20,6 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../shaderModel.hlsl"
#if defined( SOFTSHADOW ) && defined( SOFTSHADOW_HIGH_QUALITY )
@ -69,10 +70,9 @@ static float2 sNonUniformTaps[NUM_PRE_TAPS] =
/// The texture used to do per-pixel pseudorandom
/// rotations of the filter taps.
uniform sampler2D gTapRotationTex : register(S4);
TORQUE_UNIFORM_SAMPLER2D(gTapRotationTex, 4);
float softShadow_sampleTaps( sampler2D shadowMap,
float softShadow_sampleTaps( TORQUE_SAMPLER2D(shadowMap1),
float2 sinCos,
float2 shadowPos,
float filterRadius,
@ -88,7 +88,7 @@ float softShadow_sampleTaps( sampler2D shadowMap,
{
tap.x = ( sNonUniformTaps[t].x * sinCos.y - sNonUniformTaps[t].y * sinCos.x ) * filterRadius;
tap.y = ( sNonUniformTaps[t].y * sinCos.y + sNonUniformTaps[t].x * sinCos.x ) * filterRadius;
float occluder = tex2Dlod( shadowMap, float4( shadowPos + tap, 0, 0 ) ).r;
float occluder = TORQUE_TEX2DLOD( shadowMap1, float4( shadowPos + tap, 0, 0 ) ).r;
float esm = saturate( exp( esmFactor * ( occluder - distToLight ) ) );
shadow += esm / float( endTap - startTap );
@ -98,7 +98,7 @@ float softShadow_sampleTaps( sampler2D shadowMap,
}
float softShadow_filter( sampler2D shadowMap,
float softShadow_filter( TORQUE_SAMPLER2D(shadowMap),
float2 vpos,
float2 shadowPos,
float filterRadius,
@ -111,16 +111,15 @@ float softShadow_filter( sampler2D shadowMap,
// If softshadow is undefined then we skip any complex
// filtering... just do a single sample ESM.
float occluder = tex2Dlod( shadowMap, float4( shadowPos, 0, 0 ) ).r;
float occluder = TORQUE_TEX2DLOD(shadowMap, float4(shadowPos, 0, 0)).r;
float shadow = saturate( exp( esmFactor * ( occluder - distToLight ) ) );
#else
// Lookup the random rotation for this screen pixel.
float2 sinCos = ( tex2Dlod( gTapRotationTex, float4( vpos * 16, 0, 0 ) ).rg - 0.5 ) * 2;
float2 sinCos = ( TORQUE_TEX2DLOD(gTapRotationTex, float4(vpos * 16, 0, 0)).rg - 0.5) * 2;
// Do the prediction taps first.
float shadow = softShadow_sampleTaps( shadowMap,
float shadow = softShadow_sampleTaps( TORQUE_SAMPLER2D_MAKEARG(shadowMap),
sinCos,
shadowPos,
filterRadius,
@ -137,7 +136,7 @@ float softShadow_filter( sampler2D shadowMap,
// in a partially shadowed area.
if ( shadow * ( 1.0 - shadow ) * max( dotNL, 0 ) > 0.06 )
{
shadow += softShadow_sampleTaps( shadowMap,
shadow += softShadow_sampleTaps( TORQUE_SAMPLER2D_MAKEARG(shadowMap),
sinCos,
shadowPos,
filterRadius,

View file

@ -20,7 +20,8 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../shaderModel.hlsl"
#include "../../shaderModelAutoGen.hlsl"
#include "farFrustumQuad.hlsl"
#include "lightingUtils.hlsl"
@ -31,54 +32,55 @@
struct ConvexConnectP
{
float4 pos : TORQUE_POSITION;
float4 wsEyeDir : TEXCOORD0;
float4 ssPos : TEXCOORD1;
float4 vsEyeDir : TEXCOORD2;
float4 color : COLOR0;
};
TORQUE_UNIFORM_SAMPLER2D(prePassBuffer, 0);
TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
TORQUE_UNIFORM_SAMPLER2D(dynamicShadowMap,2);
#ifdef USE_COOKIE_TEX
/// The texture for cookie rendering.
uniform sampler2D cookieMap : register(S3);
TORQUE_UNIFORM_SAMPLER2D(cookieMap, 3);
#endif
TORQUE_UNIFORM_SAMPLER2D(lightBuffer, 5);
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 6);
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 7);
float4 main( ConvexConnectP IN,
uniform float4 rtParams0;
uniform sampler2D prePassBuffer : register(S0),
uniform sampler2D shadowMap : register(S1),
uniform sampler2D dynamicShadowMap : register(S2),
uniform float lightBrightness;
uniform float3 lightPosition;
uniform sampler2D lightBuffer : register(S5),
uniform sampler2D colorBuffer : register(S6),
uniform sampler2D matInfoBuffer : register(S7),
uniform float4 lightColor;
uniform float4 rtParams0,
uniform float lightRange;
uniform float3 lightDirection;
uniform float3 lightPosition,
uniform float4 lightColor,
uniform float lightBrightness,
uniform float lightRange,
uniform float2 lightAttenuation,
uniform float3 lightDirection,
uniform float4 lightSpotParams,
uniform float4 lightMapParams,
uniform float4 lightSpotParams;
uniform float4 lightMapParams;
uniform float4 vsFarPlane;
uniform float4x4 viewToLightProj;
uniform float4 lightParams;
uniform float4x4 dynamicViewToLightProj;
uniform float4 vsFarPlane,
uniform float4x4 viewToLightProj,
uniform float4x4 dynamicViewToLightProj,
uniform float2 lightAttenuation;
uniform float shadowSoftness;
uniform float4 lightParams,
uniform float shadowSoftness ) : COLOR0
float4 main( ConvexConnectP IN ) : TORQUE_TARGET0
{
// Compute scene UV
float3 ssPos = IN.ssPos.xyz / IN.ssPos.w;
float2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
// Emissive.
float4 matInfo = tex2D( matInfoBuffer, uvScene );
float4 matInfo = TORQUE_TEX2D( matInfoBuffer, uvScene );
bool emissive = getFlag( matInfo.r, 0 );
if ( emissive )
{
@ -86,7 +88,7 @@ float4 main( ConvexConnectP IN,
}
// Sample/unpack the normal/z data
float4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
float4 prepassSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, uvScene );
float3 normal = prepassSample.rgb;
float depth = prepassSample.a;
@ -130,7 +132,7 @@ float4 main( ConvexConnectP IN,
// Get a linear depth from the light source.
float distToLight = pxlPosLightProj.z / lightRange;
float static_shadowed = softShadow_filter( shadowMap,
float static_shadowed = softShadow_filter( TORQUE_SAMPLER2D_MAKEARG(shadowMap),
ssPos.xy,
shadowCoord,
shadowSoftness,
@ -138,7 +140,7 @@ float4 main( ConvexConnectP IN,
nDotL,
lightParams.y );
float dynamic_shadowed = softShadow_filter( dynamicShadowMap,
float dynamic_shadowed = softShadow_filter( TORQUE_SAMPLER2D_MAKEARG(dynamicShadowMap),
ssPos.xy,
dynshadowCoord,
shadowSoftness,
@ -152,7 +154,7 @@ float4 main( ConvexConnectP IN,
#ifdef USE_COOKIE_TEX
// Lookup the cookie sample.
float4 cookie = tex2D( cookieMap, shadowCoord );
float4 cookie = TORQUE_TEX2D( cookieMap, shadowCoord );
// Multiply the light with the cookie tex.
lightcol *= cookie.rgb;
@ -192,6 +194,6 @@ float4 main( ConvexConnectP IN,
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
}
float4 colorSample = tex2D( colorBuffer, uvScene );
float4 colorSample = TORQUE_TEX2D( colorBuffer, uvScene );
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
}

View file

@ -20,7 +20,8 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../shaderModel.hlsl"
#include "../../shaderModelAutoGen.hlsl"
#include "farFrustumQuad.hlsl"
#include "../../torque.hlsl"
@ -29,16 +30,55 @@
#include "../shadowMap/shadowMapIO_HLSL.h"
#include "softShadow.hlsl"
uniform sampler2D shadowMap : register(S1);
uniform sampler2D dynamicShadowMap : register(S2);
TORQUE_UNIFORM_SAMPLER2D(prePassBuffer, 0);
TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
TORQUE_UNIFORM_SAMPLER2D(dynamicShadowMap, 2);
#ifdef USE_SSAO_MASK
uniform sampler2D ssaoMask : register(S3);
TORQUE_UNIFORM_SAMPLER2D(ssaoMask, 3);
uniform float4 rtParams3;
#endif
//register 4?
TORQUE_UNIFORM_SAMPLER2D(lightBuffer, 5);
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 6);
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 7);
float4 AL_VectorLightShadowCast( sampler2D sourceShadowMap,
uniform float lightBrightness;
uniform float3 lightDirection;
uniform float4 lightColor;
uniform float4 lightAmbient;
uniform float shadowSoftness;
uniform float3 eyePosWorld;
uniform float4 atlasXOffset;
uniform float4 atlasYOffset;
uniform float4 zNearFarInvNearFar;
uniform float4 lightMapParams;
uniform float4 farPlaneScalePSSM;
uniform float4 overDarkPSSM;
uniform float2 fadeStartLength;
uniform float2 atlasScale;
uniform float4x4 eyeMat;
// Static Shadows
uniform float4x4 worldToLightProj;
uniform float4 scaleX;
uniform float4 scaleY;
uniform float4 offsetX;
uniform float4 offsetY;
// Dynamic Shadows
uniform float4x4 dynamicWorldToLightProj;
uniform float4 dynamicScaleX;
uniform float4 dynamicScaleY;
uniform float4 dynamicOffsetX;
uniform float4 dynamicOffsetY;
uniform float4 dynamicFarPlaneScalePSSM;
float4 AL_VectorLightShadowCast( TORQUE_SAMPLER2D(sourceShadowMap),
float2 texCoord,
float4x4 worldToLightProj,
float4 worldPos,
@ -52,8 +92,7 @@ float4 AL_VectorLightShadowCast( sampler2D sourceShadowMap,
float2 atlasScale,
float shadowSoftness,
float dotNL ,
float4 overDarkPSSM
)
float4 overDarkPSSM)
{
// Compute shadow map coordinate
float4 pxlPosLightProj = mul(worldToLightProj, worldPos);
@ -144,7 +183,7 @@ float4 AL_VectorLightShadowCast( sampler2D sourceShadowMap,
distToLight *= farPlaneScale;
return float4(debugColor,
softShadow_filter( sourceShadowMap,
softShadow_filter( TORQUE_SAMPLER2D_MAKEARG(sourceShadowMap),
texCoord,
shadowCoord,
farPlaneScale * shadowSoftness,
@ -153,50 +192,10 @@ float4 AL_VectorLightShadowCast( sampler2D sourceShadowMap,
dot( finalMask, overDarkPSSM ) ) );
};
float4 main( FarFrustumQuadConnectP IN,
uniform sampler2D prePassBuffer : register(S0),
uniform sampler2D lightBuffer : register(S5),
uniform sampler2D colorBuffer : register(S6),
uniform sampler2D matInfoBuffer : register(S7),
uniform float3 lightDirection,
uniform float4 lightColor,
uniform float lightBrightness,
uniform float4 lightAmbient,
uniform float4x4 eyeMat,
uniform float3 eyePosWorld,
uniform float4 atlasXOffset,
uniform float4 atlasYOffset,
uniform float2 atlasScale,
uniform float4 zNearFarInvNearFar,
uniform float4 lightMapParams,
uniform float2 fadeStartLength,
uniform float4 overDarkPSSM,
uniform float shadowSoftness,
// Static Shadows
uniform float4x4 worldToLightProj,
uniform float4 scaleX,
uniform float4 scaleY,
uniform float4 offsetX,
uniform float4 offsetY,
uniform float4 farPlaneScalePSSM,
// Dynamic Shadows
uniform float4x4 dynamicWorldToLightProj,
uniform float4 dynamicScaleX,
uniform float4 dynamicScaleY,
uniform float4 dynamicOffsetX,
uniform float4 dynamicOffsetY,
uniform float4 dynamicFarPlaneScalePSSM
) : COLOR0
float4 main( FarFrustumQuadConnectP IN ) : TORQUE_TARGET0
{
// Emissive.
float4 matInfo = tex2D( matInfoBuffer, IN.uv0 );
float4 matInfo = TORQUE_TEX2D( matInfoBuffer, IN.uv0 );
bool emissive = getFlag( matInfo.r, 0 );
if ( emissive )
{
@ -204,7 +203,7 @@ float4 main( FarFrustumQuadConnectP IN,
}
// Sample/unpack the normal/z data
float4 prepassSample = prepassUncondition( prePassBuffer, IN.uv0 );
float4 prepassSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, IN.uv0 );
float3 normal = prepassSample.rgb;
float depth = prepassSample.a;
@ -229,7 +228,7 @@ float4 main( FarFrustumQuadConnectP IN,
#else
float4 static_shadowed_colors = AL_VectorLightShadowCast( shadowMap,
float4 static_shadowed_colors = AL_VectorLightShadowCast( TORQUE_SAMPLER2D_MAKEARG(shadowMap),
IN.uv0.xy,
worldToLightProj,
worldPos,
@ -241,7 +240,7 @@ float4 main( FarFrustumQuadConnectP IN,
shadowSoftness,
dotNL,
overDarkPSSM);
float4 dynamic_shadowed_colors = AL_VectorLightShadowCast( dynamicShadowMap,
float4 dynamic_shadowed_colors = AL_VectorLightShadowCast( TORQUE_SAMPLER2D_MAKEARG(dynamicShadowMap),
IN.uv0.xy,
dynamicWorldToLightProj,
worldPos,
@ -307,7 +306,7 @@ float4 main( FarFrustumQuadConnectP IN,
// Sample the AO texture.
#ifdef USE_SSAO_MASK
float ao = 1.0 - tex2D( ssaoMask, viewportCoordToRenderTarget( IN.uv0.xy, rtParams3 ) ).r;
float ao = 1.0 - TORQUE_TEX2D( ssaoMask, viewportCoordToRenderTarget( IN.uv0.xy, rtParams3 ) ).r;
addToResult *= ao;
#endif
@ -315,6 +314,6 @@ float4 main( FarFrustumQuadConnectP IN,
lightColorOut = debugColor;
#endif
float4 colorSample = tex2D( colorBuffer, IN.uv0 );
float4 colorSample = TORQUE_TEX2D( colorBuffer, IN.uv0 );
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
}

View file

@ -22,11 +22,11 @@
#include "shaders/common/postFx/postFx.hlsl"
uniform sampler2D diffuseMap : register(S0);
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
struct VertToPix
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 uv : TEXCOORD0;
};
@ -35,15 +35,15 @@ static float weight[3] = { 0.2270270270, 0.3162162162, 0.0702702703 };
uniform float2 oneOverTargetSize;
float4 main( VertToPix IN ) : COLOR
float4 main( VertToPix IN ) : TORQUE_TARGET0
{
float4 OUT = tex2D( diffuseMap, IN.uv ) * weight[0];
float4 OUT = TORQUE_TEX2D( diffuseMap, IN.uv ) * weight[0];
for ( int i=1; i < 3; i++ )
{
float2 sample = (BLUR_DIR * offset[i]) * oneOverTargetSize;
OUT += tex2D( diffuseMap, IN.uv + sample ) * weight[i];
OUT += tex2D( diffuseMap, IN.uv - sample ) * weight[i];
OUT += TORQUE_TEX2D( diffuseMap, IN.uv + sample ) * weight[i];
OUT += TORQUE_TEX2D(diffuseMap, IN.uv - sample) * weight[i];
}
return OUT;

View file

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

View file

@ -23,10 +23,12 @@
//*****************************************************************************
// Box Filter
//*****************************************************************************
#include "../ShaderModel.hlsl"
struct ConnectData
{
float2 tex0 : TEXCOORD0;
float4 hpos : TORQUE_POSITION;
float2 tex0 : TEXCOORD0;
};
// If not defined from ShaderData then define
@ -40,12 +42,12 @@ float log_conv ( float x0, float X, float y0, float Y )
return (X + log(x0 + (y0 * exp(Y - X))));
}
float4 main( ConnectData IN,
uniform sampler2D diffuseMap0 : register(S0),
uniform float texSize : register(C0),
uniform float2 blurDimension : register(C2),
uniform float2 blurBoundaries : register(C3)
) : COLOR0
TORQUE_UNIFORM_SAMPLER2D(diffuseMap0, 0);
uniform float texSize : register(C0);
uniform float2 blurDimension : register(C2);
uniform float2 blurBoundaries : register(C3);
float4 main( ConnectData IN ) : TORQUE_TARGET0
{
// 5x5
if (IN.tex0.x <= blurBoundaries.x)
@ -56,8 +58,8 @@ float4 main( ConnectData IN,
float2 texCoord = IN.tex0;
float accum = log_conv(0.3125, tex2D(diffuseMap0, texCoord - sampleOffset), 0.375, tex2D(diffuseMap0, texCoord));
accum = log_conv(1, accum, 0.3125, tex2D(diffuseMap0, texCoord + sampleOffset));
float accum = log_conv(0.3125, TORQUE_TEX2D(diffuseMap0, texCoord - sampleOffset), 0.375, tex2D(diffuseMap0, texCoord));
accum = log_conv(1, accum, 0.3125, TORQUE_TEX2D(diffuseMap0, texCoord + sampleOffset));
return accum;
} else {
@ -73,7 +75,7 @@ float4 main( ConnectData IN,
return accum;
} else {
return tex2D(diffuseMap0, IN.tex0);
return TORQUE_TEX2D(diffuseMap0, IN.tex0);
}
}
}

View file

@ -26,15 +26,18 @@
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
#include "../ShaderModel.hlsl"
struct VertData
{
float2 texCoord : TEXCOORD0;
float4 position : POSITION;
float3 position : POSITION;
float2 texCoord : TEXCOORD0;
};
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 tex0 : TEXCOORD0;
};
@ -47,7 +50,7 @@ ConnectData main( VertData IN,
{
ConnectData OUT;
OUT.hpos = mul(modelview, IN.position);
OUT.hpos = mul(modelview, float4(IN.position,1.0));
OUT.tex0 = IN.texCoord;
return OUT;

View file

@ -20,22 +20,30 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "torque.hlsl"
#include "shaderModel.hlsl"
uniform sampler2D colorSource : register(S0);
TORQUE_UNIFORM_SAMPLER2D(colorSource, 0);
uniform float4 offscreenTargetParams;
#ifdef TORQUE_LINEAR_DEPTH
#define REJECT_EDGES
uniform sampler2D edgeSource : register(S1);
TORQUE_UNIFORM_SAMPLER2D(edgeSource, 1);
uniform float4 edgeTargetParams;
#endif
struct Conn
{
float4 hpos : TORQUE_POSITION;
float4 offscreenPos : TEXCOORD0;
float4 backbufferPos : TEXCOORD1;
};
float4 main( float4 offscreenPos : TEXCOORD0, float4 backbufferPos : TEXCOORD1 ) : COLOR
float4 main(Conn IN) : TORQUE_TARGET0
{
// Off-screen particle source screenspace position in XY
// Back-buffer screenspace position in ZW
float4 ssPos = float4(offscreenPos.xy / offscreenPos.w, backbufferPos.xy / backbufferPos.w);
float4 ssPos = float4(IN.offscreenPos.xy / IN.offscreenPos.w, IN.backbufferPos.xy / IN.backbufferPos.w);
float4 uvScene = ( ssPos + 1.0 ) / 2.0;
uvScene.yw = 1.0 - uvScene.yw;
@ -44,10 +52,10 @@ float4 main( float4 offscreenPos : TEXCOORD0, float4 backbufferPos : TEXCOORD1 )
#ifdef REJECT_EDGES
// Cut out particles along the edges, this will create the stencil mask
uvScene.zw = viewportCoordToRenderTarget(uvScene.zw, edgeTargetParams);
float edge = tex2D( edgeSource, uvScene.zw ).r;
float edge = TORQUE_TEX2D( edgeSource, uvScene.zw ).r;
clip( -edge );
#endif
// Sample offscreen target and return
return tex2D( colorSource, uvScene.xy );
return TORQUE_TEX2D( colorSource, uvScene.xy );
}

View file

@ -20,22 +20,28 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "hlslStructs.h"
#include "shaderModel.hlsl"
struct VertOut
struct Vertex
{
float4 hpos : POSITION;
float3 pos : POSITION;
float4 uvCoord : COLOR0;
};
struct Conn
{
float4 hpos : TORQUE_POSITION;
float4 offscreenPos : TEXCOORD0;
float4 backbufferPos : TEXCOORD1;
};
uniform float4 screenRect; // point, extent
VertOut main( float4 uvCoord : COLOR )
Conn main(Vertex IN)
{
VertOut OUT;
Conn OUT;
OUT.hpos = float4(uvCoord.xy, 1.0, 1.0);
OUT.hpos = float4(IN.uvCoord.xy, 1.0, 1.0);
OUT.hpos.xy *= screenRect.zw;
OUT.hpos.xy += screenRect.xy;

View file

@ -21,7 +21,7 @@
//-----------------------------------------------------------------------------
#include "torque.hlsl"
#include "shaderModel.hlsl"
// With advanced lighting we get soft particles.
#ifdef TORQUE_LINEAR_DEPTH
#define SOFTPARTICLES
@ -29,11 +29,11 @@
#ifdef SOFTPARTICLES
#include "shadergen:/autogenConditioners.h"
#include "shaderModelAutoGen.hlsl"
uniform float oneOverSoftness;
uniform float oneOverFar;
uniform sampler2D prepassTex : register(S1);
TORQUE_UNIFORM_SAMPLER2D(prepassTex, 1);
//uniform float3 vEye;
uniform float4 prePassTargetParams;
#endif
@ -42,14 +42,14 @@
struct Conn
{
float4 hpos : TORQUE_POSITION;
float4 color : TEXCOORD0;
float2 uv0 : TEXCOORD1;
float4 pos : TEXCOORD2;
float4 pos : TEXCOORD2;
};
uniform sampler2D diffuseMap : register(S0);
uniform sampler2D paraboloidLightMap : register(S2);
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
TORQUE_UNIFORM_SAMPLER2D(paraboloidLightMap, 2);
float4 lmSample( float3 nrm )
{
@ -69,14 +69,14 @@ float4 lmSample( float3 nrm )
// Atlasing front and back maps, so scale
lmCoord.x *= 0.5;
return tex2D(paraboloidLightMap, lmCoord);
return TORQUE_TEX2D(paraboloidLightMap, lmCoord);
}
uniform float alphaFactor;
uniform float alphaScale;
float4 main( Conn IN ) : COLOR
float4 main( Conn IN ) : TORQUE_TARGET0
{
float softBlend = 1;
@ -84,7 +84,7 @@ float4 main( Conn IN ) : COLOR
float2 tc = IN.pos.xy * float2(1.0, -1.0) / IN.pos.w;
tc = viewportCoordToRenderTarget(saturate( ( tc + 1.0 ) * 0.5 ), prePassTargetParams);
float sceneDepth = prepassUncondition( prepassTex, tc ).w;
float sceneDepth = TORQUE_PREPASS_UNCONDITION(prepassTex, tc).w;
float depth = IN.pos.w * oneOverFar;
float diff = sceneDepth - depth;
#ifdef CLIP_Z
@ -96,7 +96,7 @@ float4 main( Conn IN ) : COLOR
softBlend = saturate( diff * oneOverSoftness );
#endif
float4 diffuse = tex2D( diffuseMap, IN.uv0 );
float4 diffuse = TORQUE_TEX2D( diffuseMap, IN.uv0 );
//return float4( lmSample(float3(0, 0, -1)).rgb, IN.color.a * diffuse.a * softBlend * alphaScale);

View file

@ -20,16 +20,18 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shaderModel.hlsl"
struct Vertex
{
float4 pos : POSITION;
float3 pos : POSITION;
float4 color : COLOR0;
float2 uv0 : TEXCOORD0;
};
struct Conn
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 color : TEXCOORD0;
float2 uv0 : TEXCOORD1;
float4 pos : TEXCOORD2;
@ -43,8 +45,8 @@ Conn main( Vertex In )
{
Conn Out;
Out.hpos = mul( modelViewProj, In.pos );
Out.pos = mul( fsModelViewProj, In.pos );
Out.hpos = mul( modelViewProj, float4(In.pos,1.0) );
Out.pos = mul(fsModelViewProj, float4(In.pos, 1.0) );
Out.color = In.color;
Out.uv0 = In.uv0;

View file

@ -23,18 +23,26 @@
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
#include "shaderModel.hlsl"
struct ConnectData
{
float4 texCoord : TEXCOORD0;
float2 tex2 : TEXCOORD1;
float4 hpos : TORQUE_POSITION;
float2 texCoord : TEXCOORD0;
float4 tex2 : TEXCOORD1;
};
struct Fragout
{
float4 col : COLOR0;
float4 col : TORQUE_TARGET0;
};
TORQUE_UNIFORM_SAMPLER2D(texMap, 0);
TORQUE_UNIFORM_SAMPLER2D(refractMap, 1);
TORQUE_UNIFORM_SAMPLER2D(bumpMap, 2);
//-----------------------------------------------------------------------------
// Fade edges of axis for texcoord passed in
@ -54,15 +62,11 @@ float fadeAxis( float val )
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
Fragout main( ConnectData IN,
uniform sampler2D refractMap : register(S1),
uniform sampler2D texMap : register(S0),
uniform sampler2D bumpMap : register(S2)
)
Fragout main( ConnectData IN )
{
Fragout OUT;
float3 bumpNorm = tex2D( bumpMap, IN.tex2 ) * 2.0 - 1.0;
float3 bumpNorm = TORQUE_TEX2D( bumpMap, IN.tex2 ) * 2.0 - 1.0;
float2 offset = float2( bumpNorm.x, bumpNorm.y );
float4 texIndex = IN.texCoord;
@ -74,8 +78,8 @@ Fragout main( ConnectData IN,
const float distortion = 0.2;
texIndex.xy += offset * distortion * fadeVal;
float4 reflectColor = tex2Dproj( refractMap, texIndex );
float4 diffuseColor = tex2D( texMap, IN.tex2 );
float4 reflectColor = TORQUE_TEX2DPROJ( refractMap, texIndex );
float4 diffuseColor = TORQUE_TEX2D( texMap, IN.tex2 );
OUT.col = diffuseColor + reflectColor * diffuseColor.a;

View file

@ -22,36 +22,37 @@
#define IN_HLSL
#include "shdrConsts.h"
#include "shaderModel.hlsl"
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
struct VertData
{
float3 position : POSITION;
float3 normal : NORMAL;
float2 texCoord : TEXCOORD0;
float2 lmCoord : TEXCOORD1;
float3 T : TEXCOORD2;
float3 B : TEXCOORD3;
float3 normal : NORMAL;
float4 position : POSITION;
float3 B : TEXCOORD3;
};
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float4 texCoord : TEXCOORD0;
float2 tex2 : TEXCOORD1;
};
uniform float4x4 modelview;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
ConnectData main( VertData IN,
uniform float4x4 modelview )
ConnectData main( VertData IN )
{
ConnectData OUT;
OUT.hpos = mul(modelview, IN.position);
OUT.hpos = mul(modelview, float4(IN.position,1.0));
float4x4 texGenTest = { 0.5, 0.0, 0.0, 0.5,
0.0, -0.5, 0.0, 0.5,

View file

@ -23,31 +23,34 @@
//-----------------------------------------------------------------------------
// Structures
//-----------------------------------------------------------------------------
#include "shaderModel.hlsl"
struct ConnectData
{
float2 texCoord : TEXCOORD0;
float4 tex2 : TEXCOORD1;
float4 hpos : TORQUE_POSITION;
float2 texCoord : TEXCOORD0;
float4 tex2 : TEXCOORD1;
};
struct Fragout
{
float4 col : COLOR0;
float4 col : TORQUE_TARGET0;
};
TORQUE_UNIFORM_SAMPLER2D(texMap, 0);
TORQUE_UNIFORM_SAMPLER2D(refractMap, 1);
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
Fragout main( ConnectData IN,
uniform sampler2D texMap : register(S0),
uniform sampler2D refractMap : register(S1)
)
Fragout main( ConnectData IN )
{
Fragout OUT;
float4 diffuseColor = tex2D( texMap, IN.texCoord );
float4 reflectColor = tex2Dproj( refractMap, IN.tex2 );
float4 diffuseColor = TORQUE_TEX2D( texMap, IN.texCoord );
float4 reflectColor = TORQUE_TEX2DPROJ(refractMap, IN.tex2);
OUT.col = diffuseColor + reflectColor * diffuseColor.a;

View file

@ -21,7 +21,8 @@
//-----------------------------------------------------------------------------
#define IN_HLSL
#include "hlslStructs.h"
#include "hlslStructs.hlsl"
#include "shaderModel.hlsl"
//-----------------------------------------------------------------------------
// Structures
@ -29,20 +30,20 @@
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 texCoord : TEXCOORD0;
float4 tex2 : TEXCOORD1;
};
uniform float4x4 modelview;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
ConnectData main( VertexIn_PNTTTB IN,
uniform float4x4 modelview : register(C0)
)
ConnectData main( VertexIn_PNTTTB IN )
{
ConnectData OUT;
OUT.hpos = mul(modelview, IN.pos);
OUT.hpos = mul(modelview, float4(IN.pos,1.0));
float4x4 texGenTest = { 0.5, 0.0, 0.0, 0.5,
0.0, -0.5, 0.0, 0.5,

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

@ -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,21 +24,21 @@
#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 );

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

@ -20,15 +20,15 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#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 );
uniform sampler2D prepassTex : register(S4);
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;
@ -36,22 +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
@ -85,14 +83,14 @@ float4 main( PFXVertToPix IN ) : COLOR0
}
// Add the bloom effect.
float depth = prepassUncondition( prepassTex, IN.uv0 ).w;
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

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

Some files were not shown because too many files have changed in this diff Show more