diff options
| author | Joe Ludwig <[email protected]> | 2013-12-23 14:58:45 -0800 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-12-23 15:00:03 -0800 |
| commit | 7309a5f13f63fdcc7b1e090f6c176113a9d95061 (patch) | |
| tree | ad65c7fbe46a3c70bdc0a1426e88247ce1b0d7f5 /sp/src/materialsystem/stdshaders/Cable.vsh | |
| parent | Merge pull request #182 from ardneran/master (diff) | |
| download | source-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/Cable.vsh')
| -rw-r--r-- | sp/src/materialsystem/stdshaders/Cable.vsh | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/sp/src/materialsystem/stdshaders/Cable.vsh b/sp/src/materialsystem/stdshaders/Cable.vsh new file mode 100644 index 00000000..857a2e3b --- /dev/null +++ b/sp/src/materialsystem/stdshaders/Cable.vsh @@ -0,0 +1,117 @@ +vs.1.1 + +#include "macros.vsh" + +# DYNAMIC: "DOWATERFOG" "0..1" + +;------------------------------------------------------------------------------ +; The cable equation is: +; [L dot N] * C * T +; +; where: +; C = directional light color +; T = baseTexture +; N = particle normal (stored in the normal map) +; L = directional light direction +; +; $SHADER_SPECIFIC_CONST_0 = Directional light direction +;------------------------------------------------------------------------------ + + +;------------------------------------------------------------------------------ +; Transform position from object to projection space +;------------------------------------------------------------------------------ + +&AllocateRegister( \$projPos ); + +dp4 $projPos.x, $vPos, $cModelViewProj0 +dp4 $projPos.y, $vPos, $cModelViewProj1 +dp4 $projPos.z, $vPos, $cModelViewProj2 +dp4 $projPos.w, $vPos, $cModelViewProj3 + +mov oPos, $projPos + + +;------------------------------------------------------------------------------ +; Fog +;------------------------------------------------------------------------------ + +alloc $worldPos +if( $DOWATERFOG == 1 ) +{ + ; Get the worldpos z component only since that's all we need for height fog + dp4 $worldPos.z, $vPos, $cModel2 +} +&CalcFog( $worldPos, $projPos ); +free $worldPos + +&FreeRegister( \$projPos ); + +;------------------------------------------------------------------------------ +; Setup the tangent space +;------------------------------------------------------------------------------ + +&AllocateRegister( \$tmp1 ); +&AllocateRegister( \$tmp2 ); +&AllocateRegister( \$tmp3 ); +&AllocateRegister( \$r ); + +; Get S crossed with T (call it R) +mov $tmp1, $vTangentS +mov $tmp2, $vTangentT + +mul $tmp3, $vTangentS.yzxw, $tmp2.zxyw +mad $r, -$vTangentS.zxyw, $tmp2.yzxw, $tmp3 + +&FreeRegister( \$tmp2 ); +&FreeRegister( \$tmp3 ); + +&AllocateRegister( \$s ); + +; Normalize S (into $s) +dp3 $s.w, $vTangentS, $vTangentS +rsq $s.w, $s.w +mul $s.xyz, $vTangentS, $s.w + +; Normalize R (into $r) +dp3 $r.w, $r, $r +rsq $r.w, $r.w +mul $r.xyz, $r, $r.w + +&AllocateRegister( \$t ); + +; Regenerate T (into $t) +mul $t, $r.yzxw, $tmp1.zxyw +mad $t, -$r.zxyw, $tmp1.yzxw, $t + +&FreeRegister( \$tmp1 ); + +;------------------------------------------------------------------------------ +; Transform the light direction (into oD1) +;------------------------------------------------------------------------------ + +&AllocateRegister( \$lightDirection ); + +dp3 $lightDirection.x, $s, $SHADER_SPECIFIC_CONST_0 +dp3 $lightDirection.y, $t, $SHADER_SPECIFIC_CONST_0 +dp3 $lightDirection.z, $r, $SHADER_SPECIFIC_CONST_0 + +&FreeRegister( \$r ); +&FreeRegister( \$s ); +&FreeRegister( \$t ); + +; Scale into 0-1 range (we're assuming light direction was normalized prior to here) +add oT2, $lightDirection, $cHalf ; + 0.5 +&FreeRegister( \$lightDirection ); + +;------------------------------------------------------------------------------ +; Copy texcoords for the normal map and base texture +;------------------------------------------------------------------------------ + +mov oT0, $vTexCoord0 +mov oT1, $vTexCoord1 + +; Pass the dirlight color through +mov oD0.xyzw, $vColor + + |