mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-19 14:43:47 +00:00
Direct3D11 common shader changes.
This commit is contained in:
parent
1ff6f221fb
commit
3a9b50f702
283 changed files with 3547 additions and 1834 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,17 +20,19 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
@ -20,39 +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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -61,8 +62,8 @@ 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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ out vec2 texCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = tMul(modelview, IN_pos);
|
||||
gl_Position.w = gl_Position.z;
|
||||
|
||||
vec2 uv = IN_uv0;
|
||||
uv += texOffset;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ void main()
|
|||
vec2 IN_uv0 = vTexCoord0.st;
|
||||
|
||||
gl_Position = modelview * IN_pos;
|
||||
gl_Position.w = gl_Position.z;
|
||||
|
||||
// Offset the uv so we don't have a seam directly over our head.
|
||||
vec2 uv = IN_uv0 + vec2( 0.5, 0.5 );
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "./torque.glsl"
|
||||
|
||||
#ifndef TORQUE_SHADERGEN
|
||||
|
||||
|
|
@ -207,14 +208,42 @@ void compute4Lights( vec3 wsView,
|
|||
///
|
||||
float AL_CalcSpecular( vec3 toLight, vec3 normal, vec3 toEye )
|
||||
{
|
||||
#ifdef PHONG_SPECULAR
|
||||
// (R.V)^c
|
||||
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
||||
#else
|
||||
// (N.H)^c [Blinn-Phong, TGEA style, default]
|
||||
float specVal = dot( normal, normalize( toLight + toEye ) );
|
||||
#endif
|
||||
// (R.V)^c
|
||||
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
||||
|
||||
// Return the specular factor.
|
||||
return pow( max( specVal, 0.00001f ), AL_ConstantSpecularPower );
|
||||
}
|
||||
|
||||
/// The output for Deferred Lighting
|
||||
///
|
||||
/// @param toLight Normalized vector representing direction from the pixel
|
||||
/// being lit, to the light source, in world space.
|
||||
///
|
||||
/// @param normal Normalized surface normal.
|
||||
///
|
||||
/// @param toEye The normalized vector representing direction from the pixel
|
||||
/// being lit to the camera.
|
||||
///
|
||||
vec4 AL_DeferredOutput(
|
||||
vec3 lightColor,
|
||||
vec3 diffuseColor,
|
||||
vec4 matInfo,
|
||||
vec4 ambient,
|
||||
float specular,
|
||||
float shadowAttenuation)
|
||||
{
|
||||
vec3 specularColor = vec3(specular);
|
||||
bool metalness = getFlag(matInfo.r, 3);
|
||||
if ( metalness )
|
||||
{
|
||||
specularColor = 0.04 * (1 - specular) + diffuseColor * specular;
|
||||
}
|
||||
|
||||
//specular = color * map * spec^gloss
|
||||
float specularOut = (specularColor * matInfo.b * min(pow(max(specular,1.0f), max((matInfo.a / AL_ConstantSpecularPower),1.0f)),matInfo.a)).r;
|
||||
|
||||
lightColor *= vec3(shadowAttenuation);
|
||||
lightColor += ambient.rgb;
|
||||
return vec4(lightColor.rgb, specularOut);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,5 +73,8 @@ void main()
|
|||
discard;
|
||||
|
||||
OUT_col.a = 1;
|
||||
|
||||
OUT_col = clamp(OUT_col, 0.0, 1.0);
|
||||
|
||||
OUT_col = hdrEncode( OUT_col );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,4 +284,37 @@ void fizzle(vec2 vpos, float visibility)
|
|||
/// @note This macro will only work in the void main() method of a pixel shader.
|
||||
#define assert(condition, color) { if(!any(condition)) { OUT_col = color; return; } }
|
||||
|
||||
// Deferred Shading: Material Info Flag Check
|
||||
bool getFlag(float flags, float num)
|
||||
{
|
||||
float process = round(flags * 255);
|
||||
float squareNum = pow(2.0, num);
|
||||
return (mod(process, pow(2.0, squareNum)) >= squareNum);
|
||||
}
|
||||
|
||||
// #define TORQUE_STOCK_GAMMA
|
||||
#ifdef TORQUE_STOCK_GAMMA
|
||||
// Sample in linear space. Decodes gamma.
|
||||
vec4 toLinear(vec4 tex)
|
||||
{
|
||||
return tex;
|
||||
}
|
||||
// Encodes gamma.
|
||||
vec4 toGamma(vec4 tex)
|
||||
{
|
||||
return tex;
|
||||
}
|
||||
#else
|
||||
// Sample in linear space. Decodes gamma.
|
||||
vec4 toLinear(vec4 tex)
|
||||
{
|
||||
return vec4(pow(abs(tex.rgb), vec3(2.2)), tex.a);
|
||||
}
|
||||
// Encodes gamma.
|
||||
vec4 toGamma(vec4 tex)
|
||||
{
|
||||
return vec4(pow(abs(tex.rgb), vec3(1.0/2.2)), tex.a);
|
||||
}
|
||||
#endif //
|
||||
|
||||
#endif // _TORQUE_GLSL_
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
114
Templates/Empty/game/shaders/common/hlslStructs.hlsl
Normal file
114
Templates/Empty/game/shaders/common/hlslStructs.hlsl
Normal 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;
|
||||
};
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "./torque.hlsl"
|
||||
|
||||
#ifndef TORQUE_SHADERGEN
|
||||
|
||||
|
|
@ -207,14 +208,42 @@ void compute4Lights( float3 wsView,
|
|||
///
|
||||
float AL_CalcSpecular( float3 toLight, float3 normal, float3 toEye )
|
||||
{
|
||||
#ifdef PHONG_SPECULAR
|
||||
// (R.V)^c
|
||||
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
||||
#else
|
||||
// (N.H)^c [Blinn-Phong, TGEA style, default]
|
||||
float specVal = dot( normal, normalize( toLight + toEye ) );
|
||||
#endif
|
||||
// (R.V)^c
|
||||
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
||||
|
||||
// Return the specular factor.
|
||||
return pow( max( specVal, 0.00001f ), AL_ConstantSpecularPower );
|
||||
}
|
||||
|
||||
/// The output for Deferred Lighting
|
||||
///
|
||||
/// @param toLight Normalized vector representing direction from the pixel
|
||||
/// being lit, to the light source, in world space.
|
||||
///
|
||||
/// @param normal Normalized surface normal.
|
||||
///
|
||||
/// @param toEye The normalized vector representing direction from the pixel
|
||||
/// being lit to the camera.
|
||||
///
|
||||
float4 AL_DeferredOutput(
|
||||
float3 lightColor,
|
||||
float3 diffuseColor,
|
||||
float4 matInfo,
|
||||
float4 ambient,
|
||||
float specular,
|
||||
float shadowAttenuation)
|
||||
{
|
||||
float3 specularColor = float3(specular, specular, specular);
|
||||
bool metalness = getFlag(matInfo.r, 3);
|
||||
if ( metalness )
|
||||
{
|
||||
specularColor = 0.04 * (1 - specular) + diffuseColor * specular;
|
||||
}
|
||||
|
||||
//specular = color * map * spec^gloss
|
||||
float specularOut = (specularColor * matInfo.b * min(pow(abs(specular), max(( matInfo.a/ AL_ConstantSpecularPower),1.0f)),matInfo.a)).r;
|
||||
|
||||
lightColor *= shadowAttenuation;
|
||||
lightColor += ambient.rgb;
|
||||
return float4(lightColor.rgb, specularOut);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../../postfx/postFx.hlsl"
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(colorBufferTex,0);
|
||||
|
||||
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
return float4(TORQUE_TEX2D( colorBufferTex, IN.uv0 ).rgb, 1.0);
|
||||
}
|
||||
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,15 +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
|
||||
{
|
||||
float3 lightcolor;
|
||||
float nl_Att, specular;
|
||||
lightinfoUncondition( tex2D( lightPrePassTex, IN.uv0 ), lightcolor, nl_Att, specular );
|
||||
return float4( lightcolor, 1.0 );
|
||||
float4 lightColor = TORQUE_TEX2D( lightPrePassTex, IN.uv0 );
|
||||
return float4( lightColor.rgb, 1.0 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,15 +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
|
||||
{
|
||||
float3 lightcolor;
|
||||
float nl_Att, specular;
|
||||
lightinfoUncondition( tex2D( lightPrePassTex, IN.uv0 ), lightcolor, nl_Att, specular );
|
||||
float specular = TORQUE_TEX2D( lightPrePassTex, IN.uv0 ).a;
|
||||
return float4( specular, specular, specular, 1.0 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
@ -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 );
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../../postfx/postFx.hlsl"
|
||||
|
||||
TORQUE_UNIFORM_SAMPLER2D(matinfoTex,0);
|
||||
|
||||
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
float specular = TORQUE_TEX2D( matinfoTex, IN.uv0 ).b;
|
||||
return float4( specular, specular, specular, 1.0 );
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 Conn
|
||||
{
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
};
|
||||
|
||||
struct Fragout
|
||||
{
|
||||
float4 col : TORQUE_TARGET0;
|
||||
float4 col1 : TORQUE_TARGET1;
|
||||
float4 col2 : TORQUE_TARGET2;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
Fragout main( Conn IN )
|
||||
{
|
||||
Fragout OUT;
|
||||
|
||||
// Clear Prepass Buffer ( Normals/Depth );
|
||||
OUT.col = float4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
// Clear Color Buffer.
|
||||
OUT.col1 = float4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
// Clear Material Info Buffer.
|
||||
OUT.col2 = float4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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 Fragout
|
||||
{
|
||||
float4 col : TORQUE_TARGET0;
|
||||
float4 col1 : TORQUE_TARGET1;
|
||||
float4 col2 : TORQUE_TARGET2;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
Fragout main( )
|
||||
{
|
||||
Fragout OUT;
|
||||
|
||||
OUT.col = float4(0.0, 0.0, 0.0, 0.0);
|
||||
OUT.col1 = float4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
// Draw on color buffer.
|
||||
OUT.col2 = float4(1.0, 0.0, 0.0, 1.0);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../../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 ) : TORQUE_TARGET0
|
||||
{
|
||||
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 = TORQUE_PREPASS_UNCONDITION( prepassTex, IN.uv0 ).w;
|
||||
|
||||
if (depth>0.9999)
|
||||
return float4(0,0,0,0);
|
||||
|
||||
// Diffuse Color Altered by Metalness
|
||||
bool metalness = getFlag(matInfo.r, 3);
|
||||
if ( metalness )
|
||||
{
|
||||
colorBuffer *= (1.0 - colorBuffer.a);
|
||||
}
|
||||
|
||||
colorBuffer *= float4(lightBuffer.rgb, 1.0);
|
||||
colorBuffer += float4(specular, specular, specular, 1.0);
|
||||
|
||||
return hdrEncode( float4(colorBuffer.rgb, 1.0) );
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../../../gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../../postfx/gl/postFx.glsl"
|
||||
|
||||
uniform sampler2D colorBufferTex;
|
||||
|
||||
out vec4 OUT_FragColor0;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_FragColor0 = vec4(texture( colorBufferTex, uv0 ).rgb, 1.0);
|
||||
}
|
||||
|
|
@ -24,13 +24,13 @@
|
|||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
in vec2 uv0;
|
||||
uniform sampler2D prepassBuffer;
|
||||
uniform sampler2D prepassTex;
|
||||
uniform sampler1D depthViz;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
float depth = prepassUncondition( prepassBuffer, uv0 ).w;
|
||||
float depth = prepassUncondition( prepassTex, uv0 ).w;
|
||||
OUT_col = vec4( texture( depthViz, depth ).rgb, 1.0 );
|
||||
}
|
||||
|
|
@ -24,14 +24,12 @@
|
|||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
in vec2 uv0;
|
||||
uniform sampler2D lightInfoBuffer;
|
||||
uniform sampler2D lightPrePassTex;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 lightcolor;
|
||||
float nl_Att, specular;
|
||||
lightinfoUncondition( texture( lightInfoBuffer, uv0 ), lightcolor, nl_Att, specular );
|
||||
OUT_col = vec4( lightcolor, 1.0 );
|
||||
vec4 lightColor = texture( lightPrePassTex, uv0 );
|
||||
OUT_col = vec4( lightColor.rgb, 1.0 );
|
||||
}
|
||||
|
|
@ -24,14 +24,12 @@
|
|||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
in vec2 uv0;
|
||||
uniform sampler2D lightInfoBuffer;
|
||||
uniform sampler2D lightPrePassTex;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 lightcolor;
|
||||
float nl_Att, specular;
|
||||
lightinfoUncondition( texture( lightInfoBuffer, uv0 ), lightcolor, nl_Att, specular );
|
||||
float specular = texture( lightPrePassTex, uv0 ).a;
|
||||
OUT_col = vec4( specular, specular, specular, 1.0 );
|
||||
}
|
||||
|
|
@ -24,12 +24,12 @@
|
|||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
in vec2 uv0;
|
||||
uniform sampler2D prepassBuffer;
|
||||
uniform sampler2D prepassTex;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 normal = prepassUncondition( prepassBuffer, uv0 ).xyz;
|
||||
vec3 normal = prepassUncondition( prepassTex, uv0 ).xyz;
|
||||
OUT_col = vec4( ( normal + 1.0 ) * 0.5, 1.0 );
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../../../gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../../postfx/gl/postFx.glsl"
|
||||
|
||||
uniform sampler2D matinfoTex;
|
||||
|
||||
out vec4 OUT_FragColor0;
|
||||
|
||||
void main()
|
||||
{
|
||||
float specular = texture( matinfoTex, uv0 ).a;
|
||||
OUT_FragColor0 = vec4( specular, specular, specular, 1.0 );
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
out vec4 OUT_col;
|
||||
out vec4 OUT_col1;
|
||||
out vec4 OUT_col2;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
// Clear Prepass Buffer ( Normals/Depth );
|
||||
OUT_col = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
// Clear Color Buffer.
|
||||
OUT_col1 = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
// Clear Material Info Buffer.
|
||||
OUT_col2 = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
layout (location = 0) out vec4 col;
|
||||
layout (location = 1) out vec4 col1;
|
||||
layout (location = 2) out vec4 col2;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
col = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
col1 = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
// Draw on color buffer.
|
||||
col2 = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 "../../../gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../../postfx/gl/postFx.glsl"
|
||||
#include "../../../gl/torque.glsl"
|
||||
|
||||
uniform sampler2D colorBufferTex;
|
||||
uniform sampler2D lightPrePassTex;
|
||||
uniform sampler2D matInfoTex;
|
||||
uniform sampler2D prepassTex;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
float depth = prepassUncondition( prepassTex, uv0 ).w;
|
||||
if (depth>0.9999)
|
||||
{
|
||||
OUT_col = vec4(0.0);
|
||||
return;
|
||||
}
|
||||
vec4 lightBuffer = texture( lightPrePassTex, uv0 );
|
||||
vec4 colorBuffer = texture( colorBufferTex, uv0 );
|
||||
vec4 matInfo = texture( matInfoTex, uv0 );
|
||||
float specular = clamp(lightBuffer.a,0.0,1.0);
|
||||
|
||||
// Diffuse Color Altered by Metalness
|
||||
bool metalness = getFlag(matInfo.r, 3);
|
||||
if ( metalness )
|
||||
{
|
||||
colorBuffer *= (1.0 - colorBuffer.a);
|
||||
}
|
||||
|
||||
colorBuffer *= vec4(lightBuffer.rgb, 1.0);
|
||||
colorBuffer += vec4(specular, specular, specular, 1.0);
|
||||
|
||||
OUT_col = hdrEncode( vec4(colorBuffer.rgb, 1.0) );
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
in vec4 wsEyeDir;
|
||||
in vec4 ssPos;
|
||||
in vec4 vsEyeDir;
|
||||
in vec4 color;
|
||||
|
||||
#ifdef USE_COOKIE_TEX
|
||||
|
||||
|
|
@ -111,6 +112,10 @@ uniform sampler2D prePassBuffer;
|
|||
uniform sampler2D dynamicShadowMap;
|
||||
#endif
|
||||
|
||||
uniform sampler2D lightBuffer;
|
||||
uniform sampler2D colorBuffer;
|
||||
uniform sampler2D matInfoBuffer;
|
||||
|
||||
uniform vec4 rtParams0;
|
||||
|
||||
uniform vec3 lightPosition;
|
||||
|
|
@ -133,6 +138,15 @@ void main()
|
|||
vec3 ssPos = ssPos.xyz / ssPos.w;
|
||||
vec2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
||||
|
||||
// Emissive.
|
||||
vec4 matInfo = texture( matInfoBuffer, uvScene );
|
||||
bool emissive = getFlag( matInfo.r, 0 );
|
||||
if ( emissive )
|
||||
{
|
||||
OUT_col = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Sample/unpack the normal/z data
|
||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
||||
vec3 normal = prepassSample.rgb;
|
||||
|
|
@ -244,5 +258,6 @@ void main()
|
|||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||
}
|
||||
|
||||
OUT_col = lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
||||
vec4 colorSample = texture( colorBuffer, uvScene );
|
||||
OUT_col = AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,10 +32,12 @@
|
|||
in vec4 wsEyeDir;
|
||||
in vec4 ssPos;
|
||||
in vec4 vsEyeDir;
|
||||
in vec4 color;
|
||||
|
||||
#define IN_wsEyeDir wsEyeDir
|
||||
#define IN_ssPos ssPos
|
||||
#define IN_vsEyeDir vsEyeDir
|
||||
#define IN_color color
|
||||
|
||||
#ifdef USE_COOKIE_TEX
|
||||
|
||||
|
|
@ -48,6 +50,10 @@ uniform sampler2D prePassBuffer;
|
|||
uniform sampler2D shadowMap;
|
||||
uniform sampler2D dynamicShadowMap;
|
||||
|
||||
uniform sampler2D lightBuffer;
|
||||
uniform sampler2D colorBuffer;
|
||||
uniform sampler2D matInfoBuffer;
|
||||
|
||||
uniform vec4 rtParams0;
|
||||
|
||||
uniform vec3 lightPosition;
|
||||
|
|
@ -74,6 +80,15 @@ void main()
|
|||
vec3 ssPos = IN_ssPos.xyz / IN_ssPos.w;
|
||||
vec2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
||||
|
||||
// Emissive.
|
||||
vec4 matInfo = texture( matInfoBuffer, uvScene );
|
||||
bool emissive = getFlag( matInfo.r, 0 );
|
||||
if ( emissive )
|
||||
{
|
||||
OUT_col = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Sample/unpack the normal/z data
|
||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
||||
vec3 normal = prepassSample.rgb;
|
||||
|
|
@ -180,5 +195,6 @@ void main()
|
|||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||
}
|
||||
|
||||
OUT_col = lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
||||
vec4 colorSample = texture( colorBuffer, uvScene );
|
||||
OUT_col = AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,10 +39,13 @@ uniform sampler2D dynamicShadowMap;
|
|||
|
||||
#ifdef USE_SSAO_MASK
|
||||
uniform sampler2D ssaoMask ;
|
||||
uniform vec4 rtParams2;
|
||||
uniform vec4 rtParams3;
|
||||
#endif
|
||||
|
||||
uniform sampler2D prePassBuffer;
|
||||
uniform sampler2D prePassBuffer;
|
||||
uniform sampler2D lightBuffer;
|
||||
uniform sampler2D colorBuffer;
|
||||
uniform sampler2D matInfoBuffer;
|
||||
uniform vec3 lightDirection;
|
||||
uniform vec4 lightColor;
|
||||
uniform float lightBrightness;
|
||||
|
|
@ -189,7 +192,16 @@ vec4 AL_VectorLightShadowCast( sampler2D _sourceshadowMap,
|
|||
|
||||
out vec4 OUT_col;
|
||||
void main()
|
||||
{
|
||||
{
|
||||
// Emissive.
|
||||
float4 matInfo = texture( matInfoBuffer, uv0 );
|
||||
bool emissive = getFlag( matInfo.r, 0 );
|
||||
if ( emissive )
|
||||
{
|
||||
OUT_col = vec4(1.0, 1.0, 1.0, 0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Sample/unpack the normal/z data
|
||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uv0 );
|
||||
vec3 normal = prepassSample.rgb;
|
||||
|
|
@ -228,8 +240,6 @@ void main()
|
|||
shadowSoftness,
|
||||
dotNL,
|
||||
overDarkPSSM);
|
||||
|
||||
|
||||
vec4 dynamic_shadowed_colors = AL_VectorLightShadowCast( dynamicShadowMap,
|
||||
uv0.xy,
|
||||
dynamicWorldToLightProj,
|
||||
|
|
@ -242,14 +252,13 @@ void main()
|
|||
shadowSoftness,
|
||||
dotNL,
|
||||
overDarkPSSM);
|
||||
|
||||
float static_shadowed = static_shadowed_colors.a;
|
||||
float dynamic_shadowed = dynamic_shadowed_colors.a;
|
||||
|
||||
#ifdef PSSM_DEBUG_RENDER
|
||||
debugColor = static_shadowed_colors.rgb*0.5+dynamic_shadowed_colors.rgb*0.5;
|
||||
#endif
|
||||
|
||||
|
||||
// Fade out the shadow at the end of the range.
|
||||
vec4 zDist = vec4(zNearFarInvNearFar.x + zNearFarInvNearFar.y * depth);
|
||||
float fadeOutAmt = ( zDist.x - fadeStartLength.x ) * fadeStartLength.y;
|
||||
|
|
@ -295,7 +304,7 @@ void main()
|
|||
|
||||
// Sample the AO texture.
|
||||
#ifdef USE_SSAO_MASK
|
||||
float ao = 1.0 - texture( ssaoMask, viewportCoordToRenderTarget( uv0.xy, rtParams2 ) ).r;
|
||||
float ao = 1.0 - texture( ssaoMask, viewportCoordToRenderTarget( uv0.xy, rtParams3 ) ).r;
|
||||
addToResult *= ao;
|
||||
#endif
|
||||
|
||||
|
|
@ -303,6 +312,6 @@ void main()
|
|||
lightColorOut = debugColor;
|
||||
#endif
|
||||
|
||||
OUT_col = lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
||||
|
||||
vec4 colorSample = texture( colorBuffer, uv0 );
|
||||
OUT_col = AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../shaderModelAutoGen.hlsl"
|
||||
|
||||
#include "farFrustumQuad.hlsl"
|
||||
#include "lightingUtils.hlsl"
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
struct ConvexConnectP
|
||||
{
|
||||
float4 pos : TORQUE_POSITION;
|
||||
float4 wsEyeDir : TEXCOORD0;
|
||||
float4 ssPos : TEXCOORD1;
|
||||
float4 vsEyeDir : TEXCOORD2;
|
||||
|
|
@ -40,7 +41,7 @@ struct ConvexConnectP
|
|||
#ifdef USE_COOKIE_TEX
|
||||
|
||||
/// The texture for cookie rendering.
|
||||
uniform samplerCUBE cookieMap : register(S3);
|
||||
TORQUE_UNIFORM_SAMPLERCUBE(cookieMap, 3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -52,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
|
||||
|
|
@ -105,40 +106,52 @@ 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 float4 rtParams0,
|
||||
uniform float lightBrightness;
|
||||
uniform float3 lightPosition;
|
||||
|
||||
uniform float3 lightPosition,
|
||||
uniform float4 lightColor,
|
||||
uniform float lightBrightness,
|
||||
uniform float lightRange,
|
||||
uniform float2 lightAttenuation,
|
||||
uniform float4 lightMapParams,
|
||||
uniform float4 lightMapParams;
|
||||
uniform float4 vsFarPlane;
|
||||
uniform float4 lightParams;
|
||||
|
||||
uniform float4 vsFarPlane,
|
||||
uniform float3x3 viewToLightProj,
|
||||
uniform float3x3 dynamicViewToLightProj,
|
||||
uniform float lightRange;
|
||||
uniform float shadowSoftness;
|
||||
uniform float2 lightAttenuation;
|
||||
|
||||
uniform float4 lightParams,
|
||||
uniform float shadowSoftness ) : COLOR0
|
||||
uniform float3x3 viewToLightProj;
|
||||
uniform float3x3 dynamicViewToLightProj;
|
||||
|
||||
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 = TORQUE_TEX2D( matInfoBuffer, uvScene );
|
||||
bool emissive = getFlag( matInfo.r, 0 );
|
||||
if ( emissive )
|
||||
{
|
||||
return float4(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
|
|
@ -175,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,
|
||||
|
|
@ -192,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,
|
||||
|
|
@ -210,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;
|
||||
|
|
@ -250,5 +263,6 @@ float4 main( ConvexConnectP IN,
|
|||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||
}
|
||||
|
||||
return lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
||||
float4 colorSample = TORQUE_TEX2D( colorBuffer, uvScene );
|
||||
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../shaderModel.hlsl"
|
||||
#include "../../shaderModelAutoGen.hlsl"
|
||||
|
||||
#include "farFrustumQuad.hlsl"
|
||||
#include "lightingUtils.hlsl"
|
||||
|
|
@ -31,49 +32,63 @@
|
|||
|
||||
struct ConvexConnectP
|
||||
{
|
||||
float4 pos : TORQUE_POSITION;
|
||||
float4 wsEyeDir : TEXCOORD0;
|
||||
float4 ssPos : TEXCOORD1;
|
||||
float4 vsEyeDir : TEXCOORD2;
|
||||
};
|
||||
|
||||
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 float4 rtParams0,
|
||||
uniform float4 lightColor;
|
||||
|
||||
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 float lightRange;
|
||||
uniform float3 lightDirection;
|
||||
|
||||
uniform float4 vsFarPlane,
|
||||
uniform float4x4 viewToLightProj,
|
||||
uniform float4x4 dynamicViewToLightProj,
|
||||
uniform float4 lightSpotParams;
|
||||
uniform float4 lightMapParams;
|
||||
uniform float4 vsFarPlane;
|
||||
uniform float4x4 viewToLightProj;
|
||||
uniform float4 lightParams;
|
||||
uniform float4x4 dynamicViewToLightProj;
|
||||
|
||||
uniform float4 lightParams,
|
||||
uniform float shadowSoftness ) : COLOR0
|
||||
uniform float2 lightAttenuation;
|
||||
uniform float shadowSoftness;
|
||||
|
||||
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 = TORQUE_TEX2D( matInfoBuffer, uvScene );
|
||||
bool emissive = getFlag( matInfo.r, 0 );
|
||||
if ( emissive )
|
||||
{
|
||||
return float4(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
|
|
@ -117,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,
|
||||
|
|
@ -125,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,
|
||||
|
|
@ -139,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;
|
||||
|
|
@ -179,5 +194,6 @@ float4 main( ConvexConnectP IN,
|
|||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||
}
|
||||
|
||||
return lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
||||
float4 colorSample = TORQUE_TEX2D( colorBuffer, uvScene );
|
||||
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
uniform float4 rtParams2;
|
||||
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,46 +192,18 @@ float4 AL_VectorLightShadowCast( sampler2D sourceShadowMap,
|
|||
dot( finalMask, overDarkPSSM ) ) );
|
||||
};
|
||||
|
||||
float4 main( FarFrustumQuadConnectP IN,
|
||||
|
||||
uniform sampler2D prePassBuffer : register(S0),
|
||||
|
||||
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 = TORQUE_TEX2D( matInfoBuffer, IN.uv0 );
|
||||
bool emissive = getFlag( matInfo.r, 0 );
|
||||
if ( emissive )
|
||||
{
|
||||
return float4(1.0, 1.0, 1.0, 0.0);
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
|
|
@ -217,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,
|
||||
|
|
@ -229,8 +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,
|
||||
|
|
@ -276,6 +286,7 @@ float4 main( FarFrustumQuadConnectP IN,
|
|||
|
||||
float Sat_NL_Att = saturate( dotNL * shadowed ) * lightBrightness;
|
||||
float3 lightColorOut = lightMapParams.rgb * lightColor.rgb;
|
||||
|
||||
float4 addToResult = (lightAmbient * (1 - ambientCameraFactor)) + ( lightAmbient * ambientCameraFactor * saturate(dot(normalize(-IN.vsEyeRay), normal)) );
|
||||
|
||||
// TODO: This needs to be removed when lightmapping is disabled
|
||||
|
|
@ -295,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, rtParams2 ) ).r;
|
||||
float ao = 1.0 - TORQUE_TEX2D( ssaoMask, viewportCoordToRenderTarget( IN.uv0.xy, rtParams3 ) ).r;
|
||||
addToResult *= ao;
|
||||
#endif
|
||||
|
||||
|
|
@ -303,5 +314,6 @@ float4 main( FarFrustumQuadConnectP IN,
|
|||
lightColorOut = debugColor;
|
||||
#endif
|
||||
|
||||
return lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
||||
float4 colorSample = TORQUE_TEX2D( colorBuffer, IN.uv0 );
|
||||
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -23,21 +23,22 @@
|
|||
#include "./../postFx.hlsl"
|
||||
|
||||
// These are set by the game engine.
|
||||
uniform sampler2D shrunkSampler : register(S0); // Output of DofDownsample()
|
||||
uniform sampler2D blurredSampler : register(S1); // Blurred version of the shrunk sampler
|
||||
TORQUE_UNIFORM_SAMPLER2D(shrunkSampler, 0); // Output of DofDownsample()
|
||||
TORQUE_UNIFORM_SAMPLER2D(blurredSampler, 1); // Blurred version of the shrunk sampler
|
||||
|
||||
|
||||
// This is the pixel shader function that calculates the actual
|
||||
// value used for the near circle of confusion.
|
||||
// "texCoords" are 0 at the bottom left pixel and 1 at the top right.
|
||||
float4 main( PFXVertToPix IN ) : COLOR
|
||||
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
float3 color;
|
||||
float coc;
|
||||
half4 blurred;
|
||||
half4 shrunk;
|
||||
|
||||
shrunk = tex2D( shrunkSampler, IN.uv0 );
|
||||
blurred = tex2D( blurredSampler, IN.uv1 );
|
||||
shrunk = half4(TORQUE_TEX2D( shrunkSampler, IN.uv0 ));
|
||||
blurred = half4(TORQUE_TEX2D( blurredSampler, IN.uv1 ));
|
||||
color = shrunk.rgb;
|
||||
//coc = shrunk.a;
|
||||
//coc = blurred.a;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ PFXVertToPix main( PFXVert IN )
|
|||
*/
|
||||
|
||||
|
||||
OUT.hpos = IN.pos;
|
||||
OUT.hpos = float4(IN.pos,1.0);
|
||||
OUT.uv0 = viewportCoordToRenderTarget( IN.uv, rtParams0 );
|
||||
OUT.uv1 = viewportCoordToRenderTarget( IN.uv, rtParams1 );
|
||||
OUT.uv2 = viewportCoordToRenderTarget( IN.uv, rtParams2 );
|
||||
|
|
|
|||
|
|
@ -20,22 +20,23 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../shaderModel.hlsl"
|
||||
#include "../../shaderModelAutoGen.hlsl"
|
||||
|
||||
// These are set by the game engine.
|
||||
// The render target size is one-quarter the scene rendering size.
|
||||
uniform sampler2D colorSampler : register(S0);
|
||||
uniform sampler2D depthSampler : register(S1);
|
||||
uniform float2 dofEqWorld;
|
||||
uniform float depthOffset;
|
||||
TORQUE_UNIFORM_SAMPLER2D(colorSampler, 0);
|
||||
TORQUE_UNIFORM_SAMPLER2D(depthSampler, 1);
|
||||
uniform float2 dofEqWorld;
|
||||
uniform float2 targetSize;
|
||||
uniform float depthOffset;
|
||||
uniform float maxWorldCoC;
|
||||
//uniform float2 dofEqWeapon;
|
||||
//uniform float2 dofRowDelta; // float2( 0, 0.25 / renderTargetHeight )
|
||||
|
||||
struct Pixel
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 position : TORQUE_POSITION;
|
||||
float2 tcColor0 : TEXCOORD0;
|
||||
float2 tcColor1 : TEXCOORD1;
|
||||
float2 tcDepth0 : TEXCOORD2;
|
||||
|
|
@ -44,7 +45,7 @@ struct Pixel
|
|||
float2 tcDepth3 : TEXCOORD5;
|
||||
};
|
||||
|
||||
half4 main( Pixel IN ) : COLOR
|
||||
half4 main( Pixel IN ) : TORQUE_TARGET0
|
||||
{
|
||||
//return float4( 1.0, 0.0, 1.0, 1.0 );
|
||||
|
||||
|
|
@ -69,57 +70,64 @@ half4 main( Pixel IN ) : COLOR
|
|||
|
||||
// Use bilinear filtering to average 4 color samples for free.
|
||||
color = 0;
|
||||
color += tex2D( colorSampler, IN.tcColor0.xy + rowOfs[0] ).rgb;
|
||||
color += tex2D( colorSampler, IN.tcColor1.xy + rowOfs[0] ).rgb;
|
||||
color += tex2D( colorSampler, IN.tcColor0.xy + rowOfs[2] ).rgb;
|
||||
color += tex2D( colorSampler, IN.tcColor1.xy + rowOfs[2] ).rgb;
|
||||
color += half3(TORQUE_TEX2D( colorSampler, IN.tcColor0.xy + rowOfs[0] ).rgb);
|
||||
color += half3(TORQUE_TEX2D(colorSampler, IN.tcColor1.xy + rowOfs[0]).rgb);
|
||||
color += half3(TORQUE_TEX2D(colorSampler, IN.tcColor0.xy + rowOfs[2]).rgb);
|
||||
color += half3(TORQUE_TEX2D(colorSampler, IN.tcColor1.xy + rowOfs[2]).rgb);
|
||||
color /= 4;
|
||||
|
||||
//declare thse here to save doing it in each loop below
|
||||
half4 zero4 = half4(0, 0, 0, 0);
|
||||
coc = zero4;
|
||||
half4 dofEqWorld4X = half4(dofEqWorld.xxxx);
|
||||
half4 dofEqWorld4Y = half4(dofEqWorld.yyyy);
|
||||
half4 maxWorldCoC4 = half4(maxWorldCoC, maxWorldCoC, maxWorldCoC, maxWorldCoC);
|
||||
// Process 4 samples at a time to use vector hardware efficiently.
|
||||
// The CoC will be 1 if the depth is negative, so use "min" to pick
|
||||
// between "sceneCoc" and "viewCoc".
|
||||
|
||||
for ( int i = 0; i < 4; i++ )
|
||||
// between "sceneCoc" and "viewCoc".
|
||||
[unroll] // coc[i] causes this anyway
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
depth[0] = prepassUncondition( depthSampler, float4( IN.tcDepth0.xy + rowOfs[i], 0, 0 ) ).w;
|
||||
depth[1] = prepassUncondition( depthSampler, float4( IN.tcDepth1.xy + rowOfs[i], 0, 0 ) ).w;
|
||||
depth[2] = prepassUncondition( depthSampler, float4( IN.tcDepth2.xy + rowOfs[i], 0, 0 ) ).w;
|
||||
depth[3] = prepassUncondition( depthSampler, float4( IN.tcDepth3.xy + rowOfs[i], 0, 0 ) ).w;
|
||||
coc[i] = clamp( dofEqWorld.x * depth + dofEqWorld.y, 0.0, maxWorldCoC );
|
||||
}
|
||||
depth[0] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth0.xy + rowOfs[i])).w;
|
||||
depth[1] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth1.xy + rowOfs[i])).w;
|
||||
depth[2] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth2.xy + rowOfs[i])).w;
|
||||
depth[3] = TORQUE_PREPASS_UNCONDITION(depthSampler, (IN.tcDepth3.xy + rowOfs[i])).w;
|
||||
|
||||
coc = max(coc, clamp(dofEqWorld4X * half4(depth)+dofEqWorld4Y, zero4, maxWorldCoC4));
|
||||
}
|
||||
|
||||
/*
|
||||
depth[0] = tex2D( depthSampler, pixel.tcDepth0.xy + rowOfs[0] ).r;
|
||||
depth[1] = tex2D( depthSampler, pixel.tcDepth1.xy + rowOfs[0] ).r;
|
||||
depth[2] = tex2D( depthSampler, pixel.tcDepth2.xy + rowOfs[0] ).r;
|
||||
depth[3] = tex2D( depthSampler, pixel.tcDepth3.xy + rowOfs[0] ).r;
|
||||
depth[0] = TORQUE_TEX2D( depthSampler, pixel.tcDepth0.xy + rowOfs[0] ).r;
|
||||
depth[1] = TORQUE_TEX2D( depthSampler, pixel.tcDepth1.xy + rowOfs[0] ).r;
|
||||
depth[2] = TORQUE_TEX2D( depthSampler, pixel.tcDepth2.xy + rowOfs[0] ).r;
|
||||
depth[3] = TORQUE_TEX2D( depthSampler, pixel.tcDepth3.xy + rowOfs[0] ).r;
|
||||
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
|
||||
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
|
||||
curCoc = min( viewCoc, sceneCoc );
|
||||
coc = curCoc;
|
||||
|
||||
depth[0] = tex2D( depthSampler, pixel.tcDepth0.xy + rowOfs[1] ).r;
|
||||
depth[1] = tex2D( depthSampler, pixel.tcDepth1.xy + rowOfs[1] ).r;
|
||||
depth[2] = tex2D( depthSampler, pixel.tcDepth2.xy + rowOfs[1] ).r;
|
||||
depth[3] = tex2D( depthSampler, pixel.tcDepth3.xy + rowOfs[1] ).r;
|
||||
depth[0] = TORQUE_TEX2D( depthSampler, pixel.tcDepth0.xy + rowOfs[1] ).r;
|
||||
depth[1] = TORQUE_TEX2D( depthSampler, pixel.tcDepth1.xy + rowOfs[1] ).r;
|
||||
depth[2] = TORQUE_TEX2D( depthSampler, pixel.tcDepth2.xy + rowOfs[1] ).r;
|
||||
depth[3] = TORQUE_TEX2D( depthSampler, pixel.tcDepth3.xy + rowOfs[1] ).r;
|
||||
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
|
||||
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
|
||||
curCoc = min( viewCoc, sceneCoc );
|
||||
coc = max( coc, curCoc );
|
||||
|
||||
depth[0] = tex2D( depthSampler, pixel.tcDepth0.xy + rowOfs[2] ).r;
|
||||
depth[1] = tex2D( depthSampler, pixel.tcDepth1.xy + rowOfs[2] ).r;
|
||||
depth[2] = tex2D( depthSampler, pixel.tcDepth2.xy + rowOfs[2] ).r;
|
||||
depth[3] = tex2D( depthSampler, pixel.tcDepth3.xy + rowOfs[2] ).r;
|
||||
depth[0] = TORQUE_TEX2D( depthSampler, pixel.tcDepth0.xy + rowOfs[2] ).r;
|
||||
depth[1] = TORQUE_TEX2D( depthSampler, pixel.tcDepth1.xy + rowOfs[2] ).r;
|
||||
depth[2] = TORQUE_TEX2D( depthSampler, pixel.tcDepth2.xy + rowOfs[2] ).r;
|
||||
depth[3] = TORQUE_TEX2D( depthSampler, pixel.tcDepth3.xy + rowOfs[2] ).r;
|
||||
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
|
||||
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
|
||||
curCoc = min( viewCoc, sceneCoc );
|
||||
coc = max( coc, curCoc );
|
||||
|
||||
depth[0] = tex2D( depthSampler, pixel.tcDepth0.xy + rowOfs[3] ).r;
|
||||
depth[1] = tex2D( depthSampler, pixel.tcDepth1.xy + rowOfs[3] ).r;
|
||||
depth[2] = tex2D( depthSampler, pixel.tcDepth2.xy + rowOfs[3] ).r;
|
||||
depth[3] = tex2D( depthSampler, pixel.tcDepth3.xy + rowOfs[3] ).r;
|
||||
depth[0] = TORQUE_TEX2D( depthSampler, pixel.tcDepth0.xy + rowOfs[3] ).r;
|
||||
depth[1] = TORQUE_TEX2D( depthSampler, pixel.tcDepth1.xy + rowOfs[3] ).r;
|
||||
depth[2] = TORQUE_TEX2D( depthSampler, pixel.tcDepth2.xy + rowOfs[3] ).r;
|
||||
depth[3] = TORQUE_TEX2D( depthSampler, pixel.tcDepth3.xy + rowOfs[3] ).r;
|
||||
viewCoc = saturate( dofEqWeapon.x * -depth + dofEqWeapon.y );
|
||||
sceneCoc = saturate( dofEqWorld.x * depth + dofEqWorld.y );
|
||||
curCoc = min( viewCoc, sceneCoc );
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@
|
|||
|
||||
struct Vert
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float3 pos : POSITION;
|
||||
float2 tc : TEXCOORD0;
|
||||
float3 wsEyeRay : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct Pixel
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 position : TORQUE_POSITION;
|
||||
float2 tcColor0 : TEXCOORD0;
|
||||
float2 tcColor1 : TEXCOORD1;
|
||||
float2 tcDepth0 : TEXCOORD2;
|
||||
|
|
@ -47,7 +47,7 @@ uniform float2 oneOverTargetSize;
|
|||
Pixel main( Vert IN )
|
||||
{
|
||||
Pixel OUT;
|
||||
OUT.position = IN.pos;
|
||||
OUT.position = float4(IN.pos,1.0);
|
||||
|
||||
float2 uv = viewportCoordToRenderTarget( IN.tc, rtParams0 );
|
||||
//OUT.position = mul( IN.pos, modelView );
|
||||
|
|
|
|||
|
|
@ -20,13 +20,14 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../shaderModelAutoGen.hlsl"
|
||||
#include "./../postFx.hlsl"
|
||||
|
||||
uniform sampler2D colorSampler : register(S0); // Original source image
|
||||
uniform sampler2D smallBlurSampler : register(S1); // Output of SmallBlurPS()
|
||||
uniform sampler2D largeBlurSampler : register(S2); // Blurred output of DofDownsample()
|
||||
uniform sampler2D depthSampler : register(S3); //
|
||||
TORQUE_UNIFORM_SAMPLER2D(colorSampler,0); // Original source image
|
||||
TORQUE_UNIFORM_SAMPLER2D(smallBlurSampler,1); // Output of SmallBlurPS()
|
||||
TORQUE_UNIFORM_SAMPLER2D(largeBlurSampler,2); // Blurred output of DofDownsample()
|
||||
TORQUE_UNIFORM_SAMPLER2D(depthSampler,3);
|
||||
|
||||
uniform float2 oneOverTargetSize;
|
||||
uniform float4 dofLerpScale;
|
||||
uniform float4 dofLerpBias;
|
||||
|
|
@ -40,9 +41,9 @@ uniform float maxFarCoC;
|
|||
//static float4 dofLerpBias = float4( 1.0, (1.0 - d2) / d1, 1.0 / d2, (d2 - 1.0) / d2 );
|
||||
//static float3 dofEqFar = float3( 2.0, 0.0, 1.0 );
|
||||
|
||||
float4 tex2Doffset( sampler2D s, float2 tc, float2 offset )
|
||||
float4 tex2Doffset(TORQUE_SAMPLER2D(s), float2 tc, float2 offset)
|
||||
{
|
||||
return tex2D( s, tc + offset * oneOverTargetSize );
|
||||
return TORQUE_TEX2D( s, tc + offset * oneOverTargetSize );
|
||||
}
|
||||
|
||||
half3 GetSmallBlurSample( float2 tc )
|
||||
|
|
@ -51,10 +52,10 @@ half3 GetSmallBlurSample( float2 tc )
|
|||
const half weight = 4.0 / 17;
|
||||
sum = 0; // Unblurred sample done by alpha blending
|
||||
//sum += weight * tex2Doffset( colorSampler, tc, float2( 0, 0 ) ).rgb;
|
||||
sum += weight * tex2Doffset( colorSampler, tc, float2( +0.5, -1.5 ) ).rgb;
|
||||
sum += weight * tex2Doffset( colorSampler, tc, float2( -1.5, -0.5 ) ).rgb;
|
||||
sum += weight * tex2Doffset( colorSampler, tc, float2( -0.5, +1.5 ) ).rgb;
|
||||
sum += weight * tex2Doffset( colorSampler, tc, float2( +1.5, +0.5 ) ).rgb;
|
||||
sum += weight * half3(tex2Doffset(TORQUE_SAMPLER2D_MAKEARG(colorSampler), tc, float2(+0.5, -1.5)).rgb);
|
||||
sum += weight * half3(tex2Doffset(TORQUE_SAMPLER2D_MAKEARG(colorSampler), tc, float2(-1.5, -0.5)).rgb);
|
||||
sum += weight * half3(tex2Doffset(TORQUE_SAMPLER2D_MAKEARG(colorSampler), tc, float2(-0.5, +1.5)).rgb);
|
||||
sum += weight * half3(tex2Doffset(TORQUE_SAMPLER2D_MAKEARG(colorSampler), tc, float2(+1.5, +0.5)).rgb);
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +73,7 @@ half4 InterpolateDof( half3 small, half3 med, half3 large, half t )
|
|||
//float4 dofLerpScale = float4( -1 / d0, -1 / d1, -1 / d2, 1 / d2 );
|
||||
//float4 dofLerpBias = float4( 1, (1 – d2) / d1, 1 / d2, (d2 – 1) / d2 );
|
||||
|
||||
weights = saturate( t * dofLerpScale + dofLerpBias );
|
||||
weights = half4(saturate( t * dofLerpScale + dofLerpBias ));
|
||||
weights.yz = min( weights.yz, 1 - weights.xy );
|
||||
|
||||
// Unblurred sample with weight "weights.x" done by alpha blending
|
||||
|
|
@ -84,11 +85,11 @@ half4 InterpolateDof( half3 small, half3 med, half3 large, half t )
|
|||
return half4( color, alpha );
|
||||
}
|
||||
|
||||
half4 main( PFXVertToPix IN ) : COLOR
|
||||
half4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
//return half4( 1,0,1,1 );
|
||||
//return half4( tex2D( colorSampler, IN.uv0 ).rgb, 1.0 );
|
||||
//return half4( tex2D( colorSampler, texCoords ).rgb, 0 );
|
||||
//return half4( TORQUE_TEX2D( colorSampler, IN.uv0 ).rgb, 1.0 );
|
||||
//return half4( TORQUE_TEX2D( colorSampler, texCoords ).rgb, 0 );
|
||||
half3 small;
|
||||
half4 med;
|
||||
half3 large;
|
||||
|
|
@ -100,10 +101,10 @@ half4 main( PFXVertToPix IN ) : COLOR
|
|||
small = GetSmallBlurSample( IN.uv0 );
|
||||
//small = half3( 1,0,0 );
|
||||
//return half4( small, 1.0 );
|
||||
med = tex2D( smallBlurSampler, IN.uv1 );
|
||||
med = half4(TORQUE_TEX2D( smallBlurSampler, IN.uv1 ));
|
||||
//med.rgb = half3( 0,1,0 );
|
||||
//return half4(med.rgb, 0.0);
|
||||
large = tex2D( largeBlurSampler, IN.uv2 ).rgb;
|
||||
large = half3(TORQUE_TEX2D(largeBlurSampler, IN.uv2).rgb);
|
||||
//large = half3( 0,0,1 );
|
||||
//return large;
|
||||
//return half4(large.rgb,1.0);
|
||||
|
|
@ -114,7 +115,7 @@ half4 main( PFXVertToPix IN ) : COLOR
|
|||
//med.rgb = large;
|
||||
|
||||
//nearCoc = 0;
|
||||
depth = prepassUncondition( depthSampler, float4( IN.uv3, 0, 0 ) ).w;
|
||||
depth = half(TORQUE_PREPASS_UNCONDITION( depthSampler, IN.uv3 ).w);
|
||||
//return half4(depth.rrr,1);
|
||||
//return half4(nearCoc.rrr,1.0);
|
||||
|
||||
|
|
@ -128,8 +129,8 @@ half4 main( PFXVertToPix IN ) : COLOR
|
|||
// dofEqFar.x and dofEqFar.y specify the linear ramp to convert
|
||||
// to depth for the distant out-of-focus region.
|
||||
// dofEqFar.z is the ratio of the far to the near blur radius.
|
||||
farCoc = clamp( dofEqFar.x * depth + dofEqFar.y, 0.0, maxFarCoC );
|
||||
coc = max( nearCoc, farCoc * dofEqFar.z );
|
||||
farCoc = half(clamp( dofEqFar.x * depth + dofEqFar.y, 0.0, maxFarCoC ));
|
||||
coc = half(max( nearCoc, farCoc * dofEqFar.z ));
|
||||
//coc = nearCoc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ PFXVertToPix main( PFXVert IN )
|
|||
*/
|
||||
|
||||
|
||||
OUT.hpos = IN.pos;
|
||||
OUT.hpos = float4(IN.pos,1.0);
|
||||
OUT.uv0 = viewportCoordToRenderTarget( IN.uv, rtParams0 );
|
||||
OUT.uv1 = viewportCoordToRenderTarget( IN.uv, rtParams1 ); // + float2( -5, 1 ) * oneOverTargetSize;
|
||||
OUT.uv2 = viewportCoordToRenderTarget( IN.uv, rtParams2 );
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@
|
|||
|
||||
#include "./../postFx.hlsl"
|
||||
|
||||
uniform sampler2D diffuseMap : register(S0);
|
||||
TORQUE_UNIFORM_SAMPLER2D(diffuseMap, 0);
|
||||
|
||||
struct VertToPix
|
||||
{
|
||||
float4 hpos : POSITION;
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
|
|
@ -39,20 +39,20 @@ struct VertToPix
|
|||
float2 uv7 : TEXCOORD7;
|
||||
};
|
||||
|
||||
float4 main( VertToPix IN ) : COLOR
|
||||
float4 main( VertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
float4 kernel = float4( 0.175, 0.275, 0.375, 0.475 ) * 0.5 / 1.3; //25f;
|
||||
|
||||
float4 OUT = 0;
|
||||
OUT += tex2D( diffuseMap, IN.uv0 ) * kernel.x;
|
||||
OUT += tex2D( diffuseMap, IN.uv1 ) * kernel.y;
|
||||
OUT += tex2D( diffuseMap, IN.uv2 ) * kernel.z;
|
||||
OUT += tex2D( diffuseMap, IN.uv3 ) * kernel.w;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv0 ) * kernel.x;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv1 ) * kernel.y;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv2 ) * kernel.z;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv3 ) * kernel.w;
|
||||
|
||||
OUT += tex2D( diffuseMap, IN.uv4 ) * kernel.x;
|
||||
OUT += tex2D( diffuseMap, IN.uv5 ) * kernel.y;
|
||||
OUT += tex2D( diffuseMap, IN.uv6 ) * kernel.z;
|
||||
OUT += tex2D( diffuseMap, IN.uv7 ) * kernel.w;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv4 ) * kernel.x;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv5 ) * kernel.y;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv6 ) * kernel.z;
|
||||
OUT += TORQUE_TEX2D( diffuseMap, IN.uv7 ) * kernel.w;
|
||||
|
||||
// Calculate a lumenance value in the alpha so we
|
||||
// can use alpha test to save fillrate.
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@
|
|||
#include "./../../torque.hlsl"
|
||||
|
||||
|
||||
uniform float2 texSize0;
|
||||
uniform float4 rtParams0;
|
||||
uniform float2 texSize0;
|
||||
uniform float2 oneOverTargetSize;
|
||||
|
||||
struct VertToPix
|
||||
{
|
||||
float4 hpos : POSITION;
|
||||
float4 hpos : TORQUE_POSITION;
|
||||
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
|
|
@ -47,7 +47,7 @@ VertToPix main( PFXVert IN )
|
|||
{
|
||||
VertToPix OUT;
|
||||
|
||||
OUT.hpos = IN.pos;
|
||||
OUT.hpos = float4(IN.pos,1.0);
|
||||
|
||||
IN.uv = viewportCoordToRenderTarget( IN.uv, rtParams0 );
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ PFXVertToPix main( PFXVert IN )
|
|||
*/
|
||||
|
||||
|
||||
OUT.hpos = IN.pos;
|
||||
OUT.hpos = float4(IN.pos,1.0);
|
||||
OUT.uv0 = viewportCoordToRenderTarget( IN.uv, rtParams0 );
|
||||
OUT.uv1 = viewportCoordToRenderTarget( IN.uv, rtParams1 );
|
||||
OUT.uv2 = viewportCoordToRenderTarget( IN.uv, rtParams2 );
|
||||
|
|
|
|||
|
|
@ -24,22 +24,23 @@
|
|||
// colorMapSampler, which is the same size as the render target.
|
||||
// The sample weights are 1/16 in the corners, 2/16 on the edges,
|
||||
// and 4/16 in the center.
|
||||
#include "../../shaderModel.hlsl"
|
||||
|
||||
uniform sampler2D colorSampler; // Output of DofNearCoc()
|
||||
TORQUE_UNIFORM_SAMPLER2D(colorSampler, 0); // Output of DofNearCoc()
|
||||
|
||||
struct Pixel
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 position : TORQUE_POSITION;
|
||||
float4 texCoords : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 main( Pixel IN ) : COLOR
|
||||
float4 main( Pixel IN ) : TORQUE_TARGET0
|
||||
{
|
||||
float4 color;
|
||||
color = 0.0;
|
||||
color += tex2D( colorSampler, IN.texCoords.xz );
|
||||
color += tex2D( colorSampler, IN.texCoords.yz );
|
||||
color += tex2D( colorSampler, IN.texCoords.xw );
|
||||
color += tex2D( colorSampler, IN.texCoords.yw );
|
||||
color += TORQUE_TEX2D( colorSampler, IN.texCoords.xz );
|
||||
color += TORQUE_TEX2D( colorSampler, IN.texCoords.yz );
|
||||
color += TORQUE_TEX2D( colorSampler, IN.texCoords.xw );
|
||||
color += TORQUE_TEX2D( colorSampler, IN.texCoords.yw );
|
||||
return color / 4.0;
|
||||
}
|
||||
|
|
@ -30,13 +30,13 @@
|
|||
|
||||
struct Vert
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float3 position : POSITION;
|
||||
float2 texCoords : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Pixel
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 position : TORQUE_POSITION;
|
||||
float4 texCoords : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ Pixel main( Vert IN )
|
|||
{
|
||||
Pixel OUT;
|
||||
const float4 halfPixel = { -0.5, 0.5, -0.5, 0.5 };
|
||||
OUT.position = IN.position; //Transform_ObjectToClip( IN.position );
|
||||
OUT.position = float4(IN.position,1.0); //Transform_ObjectToClip( IN.position );
|
||||
|
||||
//float2 uv = IN.texCoords + rtParams0.xy;
|
||||
float2 uv = viewportCoordToRenderTarget( IN.texCoords, rtParams0 );
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
// These are set by the game engine.
|
||||
uniform sampler2D shrunkSampler; // Output of DofDownsample()
|
||||
uniform sampler2D blurredSampler; // Blurred version of the shrunk sampler
|
||||
uniform sampler2D blurredSampler; // Blurred version of the shrunk sampler
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -24,23 +24,30 @@
|
|||
#include "./postFx.hlsl"
|
||||
#include "../torque.hlsl"
|
||||
|
||||
uniform sampler2D backBuffer : register(S0);
|
||||
uniform sampler1D colorCorrectionTex : register( s1 );
|
||||
TORQUE_UNIFORM_SAMPLER2D(backBuffer, 0);
|
||||
TORQUE_UNIFORM_SAMPLER1D(colorCorrectionTex, 1);
|
||||
|
||||
uniform float OneOverGamma;
|
||||
uniform float Brightness;
|
||||
uniform float Contrast;
|
||||
|
||||
|
||||
float4 main( PFXVertToPix IN ) : COLOR0
|
||||
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||
{
|
||||
float4 color = tex2D(backBuffer, IN.uv0.xy);
|
||||
float4 color = TORQUE_TEX2D(backBuffer, IN.uv0.xy);
|
||||
|
||||
// Apply the color correction.
|
||||
color.r = tex1D( colorCorrectionTex, color.r ).r;
|
||||
color.g = tex1D( colorCorrectionTex, color.g ).g;
|
||||
color.b = tex1D( colorCorrectionTex, color.b ).b;
|
||||
color.r = TORQUE_TEX1D( colorCorrectionTex, color.r ).r;
|
||||
color.g = TORQUE_TEX1D( colorCorrectionTex, color.g ).g;
|
||||
color.b = TORQUE_TEX1D( colorCorrectionTex, color.b ).b;
|
||||
|
||||
// Apply gamma correction
|
||||
color.rgb = pow( abs(color.rgb), OneOverGamma );
|
||||
|
||||
// Apply contrast
|
||||
color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;
|
||||
|
||||
// Apply brightness
|
||||
color.rgb += Brightness;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
|
@ -28,6 +28,8 @@ uniform sampler2D backBuffer;
|
|||
uniform sampler1D colorCorrectionTex;
|
||||
|
||||
uniform float OneOverGamma;
|
||||
uniform float Brightness;
|
||||
uniform float Contrast;
|
||||
|
||||
in vec2 uv0;
|
||||
|
||||
|
|
@ -45,5 +47,11 @@ void main()
|
|||
// Apply gamma correction
|
||||
color.rgb = pow( abs(color.rgb), vec3(OneOverGamma) );
|
||||
|
||||
// Apply contrast
|
||||
color.rgb = ((color.rgb - 0.5f) * Contrast) + 0.5f;
|
||||
|
||||
// Apply brightness
|
||||
color.rgb += Brightness;
|
||||
|
||||
OUT_col = color;
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ out vec4 OUT_col;
|
|||
void main()
|
||||
{
|
||||
vec4 kernel = vec4( 0.175, 0.275, 0.375, 0.475 ) * 0.5f;
|
||||
|
||||
|
||||
OUT_col = vec4(0);
|
||||
OUT_col += texture( diffuseMap, uv0 ) * kernel.x;
|
||||
OUT_col += texture( diffuseMap, uv1 ) * kernel.y;
|
||||
|
|
@ -55,5 +55,5 @@ void main()
|
|||
// can use alpha test to save fillrate.
|
||||
vec3 rgb2lum = vec3( 0.30, 0.59, 0.11 );
|
||||
OUT_col.a = dot( OUT_col.rgb, rgb2lum );
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue