Direct3D11 common shader changes.

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,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 );
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,43 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "../../shaderModel.hlsl"
struct Appdata
{
float3 pos : POSITION;
float4 color : COLOR;
};
struct Conn
{
float4 hpos : TORQUE_POSITION;
};
uniform float4x4 modelview;
Conn main( Appdata In )
{
Conn Out;
Out.hpos = float4(In.pos,1.0);
return Out;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,7 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../shaderModelAutoGen.hlsl"
#include "farFrustumQuad.hlsl"
#include "lightingUtils.hlsl"
@ -31,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);
}

View file

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

View file

@ -20,7 +20,8 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../shaderModel.hlsl"
#include "../../shaderModelAutoGen.hlsl"
#include "farFrustumQuad.hlsl"
#include "lightingUtils.hlsl"
@ -31,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);
}

View file

@ -20,7 +20,8 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../shaderModel.hlsl"
#include "../../shaderModelAutoGen.hlsl"
#include "farFrustumQuad.hlsl"
#include "../../torque.hlsl"
@ -29,16 +30,55 @@
#include "../shadowMap/shadowMapIO_HLSL.h"
#include "softShadow.hlsl"
uniform sampler2D shadowMap : register(S1);
uniform sampler2D dynamicShadowMap : register(S2);
TORQUE_UNIFORM_SAMPLER2D(prePassBuffer, 0);
TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
TORQUE_UNIFORM_SAMPLER2D(dynamicShadowMap, 2);
#ifdef USE_SSAO_MASK
uniform sampler2D ssaoMask : register(S3);
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);
}

View file

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

View file

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

View file

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

View file

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