aboutsummaryrefslogtreecommitdiff
path: root/sp/src/materialsystem/stdshaders/shadowmodel_vs20.fxc
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2013-12-23 14:58:45 -0800
committerJoe Ludwig <[email protected]>2013-12-23 15:00:03 -0800
commit7309a5f13f63fdcc7b1e090f6c176113a9d95061 (patch)
treead65c7fbe46a3c70bdc0a1426e88247ce1b0d7f5 /sp/src/materialsystem/stdshaders/shadowmodel_vs20.fxc
parentMerge pull request #182 from ardneran/master (diff)
downloadsource-sdk-2013-7309a5f13f63fdcc7b1e090f6c176113a9d95061.tar.xz
source-sdk-2013-7309a5f13f63fdcc7b1e090f6c176113a9d95061.zip
Added many shader source files
This should include the latest version of every shader that was in the 2007 SDK. It also includes a smattering of debug shaders, both VR distortion shaders, and other assorted shaders that will hopefully be useful. None of these new files are included in the game shader DLL project. If you need to modify one of these shaders for use in your mod you will need to rename it so that you don't collide with the version of that shader that lives in stdshader_dx9.dll.
Diffstat (limited to 'sp/src/materialsystem/stdshaders/shadowmodel_vs20.fxc')
-rw-r--r--sp/src/materialsystem/stdshaders/shadowmodel_vs20.fxc81
1 files changed, 81 insertions, 0 deletions
diff --git a/sp/src/materialsystem/stdshaders/shadowmodel_vs20.fxc b/sp/src/materialsystem/stdshaders/shadowmodel_vs20.fxc
new file mode 100644
index 00000000..9d1ff02c
--- /dev/null
+++ b/sp/src/materialsystem/stdshaders/shadowmodel_vs20.fxc
@@ -0,0 +1,81 @@
+// DYNAMIC: "DOWATERFOG" "0..1"
+// DYNAMIC: "SKINNING" "0..1"
+
+#include "common_vs_fxc.h"
+
+static const bool g_bSkinning = SKINNING ? true : false;
+static const int g_FogType = DOWATERFOG;
+
+const float4 cShadowTextureMatrix[3] : register( SHADER_SPECIFIC_CONST_0 );
+const float4 cTexOrigin : register( SHADER_SPECIFIC_CONST_3 );
+const float4 cTexScale : register( SHADER_SPECIFIC_CONST_4 );
+
+// { Shadow falloff offset, 1/Shadow distance, Shadow scale, 0 }
+const float3 cShadowConstants : register( SHADER_SPECIFIC_CONST_5 );
+#define flShadowFalloffOffset cShadowConstants.x
+#define flOneOverShadowDist cShadowConstants.y
+#define flShadowScale cShadowConstants.z
+
+
+struct VS_INPUT
+{
+ float4 vPos : POSITION;
+ float3 vNormal : NORMAL;
+ float4 vBoneWeights : BLENDWEIGHT;
+ float4 vBoneIndices : BLENDINDICES;
+};
+
+struct VS_OUTPUT
+{
+ float4 projPos : POSITION; // Projection-space position
+ float3 T0 : TEXCOORD0; // PS wants this to be 4D but VS doesn't? (see original asm sources)
+ float3 T1 : TEXCOORD1;
+ float3 T2 : TEXCOORD2;
+ float T3 : TEXCOORD3;
+ float4 vColor : COLOR0;
+ float fog : FOG;
+};
+
+VS_OUTPUT main( const VS_INPUT v )
+{
+ VS_OUTPUT o;
+
+ // Perform skinning
+ float3 worldNormal, worldPos;
+ SkinPositionAndNormal( g_bSkinning, v.vPos, v.vNormal, v.vBoneWeights, v.vBoneIndices, worldPos, worldNormal );
+
+ // Transform into projection space
+ o.projPos = mul( float4( worldPos, 1 ), cViewProj );
+
+ // Compute fog
+ o.fog = CalcFog( worldPos, o.projPos, g_FogType );
+
+ // Transform position into texture space (from 0 to 1)
+ float3 vTexturePos;
+ vTexturePos.x = dot( worldPos.xyz, cShadowTextureMatrix[0].xyz );
+ vTexturePos.y = dot( worldPos.xyz, cShadowTextureMatrix[1].xyz );
+ vTexturePos.z = dot( worldPos.xyz, cShadowTextureMatrix[2].xyz );
+
+ // Figure out the shadow fade amount
+ float flShadowFade = ( vTexturePos.z - flShadowFalloffOffset ) * flOneOverShadowDist;
+
+ // Offset it into the texture
+ o.T0 = vTexturePos * cTexScale + cTexOrigin;
+
+ // We're doing clipping by using texkill
+ o.T1.xyz = vTexturePos.xyz; // Also clips when shadow z < 0 !
+ o.T2.xyz = float3( 1.0f, 1.0f, 1.0f ) - vTexturePos.xyz;
+ o.T2.z = 1.0f - flShadowFade; // Clips when shadow z > shadow distance
+
+ // We're doing backface culling by using texkill also (wow yucky)
+ // --------------------------------------------------------------
+ // Transform z component of normal in texture space
+ // If it's negative, then don't draw the pixel
+ o.T3 = dot( worldNormal, -cShadowTextureMatrix[2] );
+
+ // Shadow color, falloff
+ o.vColor.xyz = cModulationColor.xyz;
+ o.vColor.w = flShadowFade * flShadowScale;
+
+ return o;
+}