summaryrefslogtreecommitdiff
path: root/materialsystem/stdshaders/decalmodulate.cpp
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/decalmodulate.cpp
downloadarchived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.tar.xz
archived-source-engine-2018-hl2-src-3bf9df6b2785fa6d951086978a3e66f49427166a.zip
Diffstat (limited to 'materialsystem/stdshaders/decalmodulate.cpp')
-rw-r--r--materialsystem/stdshaders/decalmodulate.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/materialsystem/stdshaders/decalmodulate.cpp b/materialsystem/stdshaders/decalmodulate.cpp
new file mode 100644
index 0000000..8484ccd
--- /dev/null
+++ b/materialsystem/stdshaders/decalmodulate.cpp
@@ -0,0 +1,63 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $Header: $
+// $NoKeywords: $
+//=============================================================================//
+
+#include "shaderlib/cshader.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+DEFINE_FALLBACK_SHADER( DecalModulate, DecalModulate_DX6 )
+
+BEGIN_SHADER( DecalModulate_dx6,
+ "Help for DecalModulate_dx6" )
+
+ BEGIN_SHADER_PARAMS
+ END_SHADER_PARAMS
+
+ SHADER_INIT_PARAMS()
+ {
+ SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE );
+ }
+
+ SHADER_INIT
+ {
+ LoadTexture( BASETEXTURE );
+ }
+
+ SHADER_DRAW
+ {
+ SHADOW_STATE
+ {
+ pShaderShadow->EnableAlphaTest( true );
+ pShaderShadow->AlphaFunc( SHADER_ALPHAFUNC_GREATER, 0.0f );
+ pShaderShadow->EnableDepthWrites( false );
+ pShaderShadow->EnablePolyOffset( SHADER_POLYOFFSET_DECAL );
+ pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
+ pShaderShadow->EnableBlending( true );
+ pShaderShadow->BlendFunc( SHADER_BLEND_DST_COLOR, SHADER_BLEND_SRC_COLOR );
+ pShaderShadow->DrawFlags( SHADER_DRAW_POSITION | SHADER_DRAW_TEXCOORD0 );
+ FogToGrey();
+ }
+ DYNAMIC_STATE
+ {
+ // This is kinda gross. We really don't want to render anything here for the flashlight
+ // pass since we are multiplying by what is already flashlight lit in the framebuffer.
+ // There is no easy way to draw nothing conditionally, so I'll bind grey and multiply
+ // which shouldn't change the contents of the framebuffer much.
+ if( pShaderAPI->InFlashlightMode() )
+ {
+ pShaderAPI->BindStandardTexture( SHADER_SAMPLER0, TEXTURE_GREY );
+ }
+ else
+ {
+ BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME );
+ }
+ }
+ Draw( );
+ }
+END_SHADER