summaryrefslogtreecommitdiff
path: root/materialsystem/stdshaders/ShatteredGlass_inc.vsh
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /materialsystem/stdshaders/ShatteredGlass_inc.vsh
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'materialsystem/stdshaders/ShatteredGlass_inc.vsh')
-rw-r--r--materialsystem/stdshaders/ShatteredGlass_inc.vsh105
1 files changed, 105 insertions, 0 deletions
diff --git a/materialsystem/stdshaders/ShatteredGlass_inc.vsh b/materialsystem/stdshaders/ShatteredGlass_inc.vsh
new file mode 100644
index 0000000..608bb2a
--- /dev/null
+++ b/materialsystem/stdshaders/ShatteredGlass_inc.vsh
@@ -0,0 +1,105 @@
+#include "macros.vsh"
+
+;------------------------------------------------------------------------------
+; $SHADER_SPECIFIC_CONST_0-$SHADER_SPECIFIC_CONST_1 = Base texture transform + envmap mask transform
+; $SHADER_SPECIFIC_CONST_2-$SHADER_SPECIFIC_CONST_3 = Detail texture transform
+;------------------------------------------------------------------------------
+
+sub ShatteredGlass
+{
+ local( $detail ) = shift;
+ local( $envmap ) = shift;
+ local( $envmapcameraspace ) = shift;
+ local( $envmapsphere ) = shift;
+ local( $vertexcolor ) = shift;
+
+ local( $worldPos, $worldNormal, $projPos, $reflectionVector );
+
+ &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
+
+ &AllocateRegister( \$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 );
+ &FreeRegister( \$projPos );
+
+ ;------------------------------------------------------------------------------
+ ; Texture coordinates
+ ;------------------------------------------------------------------------------
+ ; base texcoords
+ dp4 oT0.x, $vTexCoord0, $SHADER_SPECIFIC_CONST_0
+ dp4 oT0.y, $vTexCoord0, $SHADER_SPECIFIC_CONST_1
+
+ ; lightmap texcoords
+ mov oT1, $vTexCoord1
+
+ if( $envmap )
+ {
+ &AllocateRegister( \$worldNormal );
+
+ ; Transform the position + normal to world space
+ dp4 $worldPos.x, $vPos, $cModel0
+ dp4 $worldPos.y, $vPos, $cModel1
+ if( $DOWATERFOG == 0 )
+ {
+ dp4 $worldPos.z, $vPos, $cModel2
+ }
+
+ dp3 $worldNormal.x, $vNormal, $cModel0
+ dp3 $worldNormal.y, $vNormal, $cModel1
+ dp3 $worldNormal.z, $vNormal, $cModel2
+
+ if( $envmapcameraspace )
+ {
+ &AllocateRegister( \$reflectionVector );
+ &ComputeReflectionVector( $worldPos, $worldNormal, $reflectionVector );
+ ; transform reflection vector into view space
+ dp3 oT2.x, $reflectionVector, $cViewModel0
+ dp3 oT2.y, $reflectionVector, $cViewModel1
+ dp3 oT2.z, $reflectionVector, $cViewModel2
+ &FreeRegister( \$reflectionVector );
+ }
+ elsif( $envmapsphere )
+ {
+ &AllocateRegister( \$reflectionVector );
+ &ComputeReflectionVector( $worldPos, $worldNormal, $reflectionVector );
+ &ComputeSphereMapTexCoords( $reflectionVector, "oT2" );
+ &FreeRegister( \$reflectionVector );
+ }
+ else
+ {
+ &ComputeReflectionVector( $worldPos, $worldNormal, "oT2" );
+ }
+
+ &FreeRegister( \$worldNormal );
+ }
+
+ &FreeRegister( \$worldPos );
+
+ if( $detail )
+ {
+ dp4 oT3.x, $vTexCoord2, $SHADER_SPECIFIC_CONST_2
+ dp4 oT3.y, $vTexCoord2, $SHADER_SPECIFIC_CONST_3
+ }
+
+ if( $vertexcolor )
+ {
+ ; Modulation color
+ mul oD0, $vColor, $cModulationColor
+ }
+ else
+ {
+ ; Modulation color
+ mov oD0, $cModulationColor
+ }
+}