Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Header: $
  6. // $NoKeywords: $
  7. //===========================================================================//
  8. #include "shaderlib/cshader.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. DEFINE_FALLBACK_SHADER( DecalBaseTimesLightmapAlphaBlendSelfIllum, DecalBaseTimesLightmapAlphaBlendSelfIllum_DX6 )
  12. BEGIN_SHADER( DecalBaseTimesLightmapAlphaBlendSelfIllum_DX6,
  13. "Help for DecalBaseTimesLightmapAlphaBlendSelfIllum_DX6" )
  14. BEGIN_SHADER_PARAMS
  15. SHADER_PARAM_OVERRIDE( BASETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "decals/decalporthole001b", "decal base texture", 0 )
  16. SHADER_PARAM( SELFILLUMTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "decals/decalporthole001b_mask", "self-illum texture" )
  17. SHADER_PARAM( SELFILLUMTEXTUREFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "self-illum texture frame" )
  18. END_SHADER_PARAMS
  19. SHADER_INIT_PARAMS()
  20. {
  21. SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE );
  22. SET_FLAGS2( MATERIAL_VAR2_LIGHTING_LIGHTMAP );
  23. }
  24. SHADER_INIT
  25. {
  26. LoadTexture( BASETEXTURE );
  27. LoadTexture( SELFILLUMTEXTURE );
  28. }
  29. SHADER_DRAW
  30. {
  31. if( g_pHardwareConfig->GetSamplerCount() < 2 )
  32. {
  33. ShaderWarning( "DecalBaseTimesLightmapAlphaBlendSelfIllum: not implemented for single-texturing hardware\n" );
  34. return;
  35. }
  36. SHADOW_STATE
  37. {
  38. pShaderShadow->EnableDepthWrites( false );
  39. pShaderShadow->EnablePolyOffset( SHADER_POLYOFFSET_DECAL );
  40. pShaderShadow->EnableBlending( true );
  41. pShaderShadow->BlendFunc( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
  42. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  43. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  44. pShaderShadow->OverbrightValue( SHADER_TEXTURE_STAGE1, OVERBRIGHT );
  45. pShaderShadow->DrawFlags( SHADER_DRAW_POSITION |
  46. SHADER_DRAW_TEXCOORD1 | SHADER_DRAW_LIGHTMAP_TEXCOORD0 );
  47. FogToFogColor();
  48. }
  49. DYNAMIC_STATE
  50. {
  51. pShaderAPI->BindStandardTexture( SHADER_SAMPLER0, TEXTURE_LIGHTMAP );
  52. BindTexture( SHADER_SAMPLER1, BASETEXTURE, FRAME );
  53. }
  54. Draw();
  55. SHADOW_STATE
  56. {
  57. SetInitialShadowState( );
  58. pShaderShadow->EnableDepthWrites( false );
  59. pShaderShadow->EnablePolyOffset( SHADER_POLYOFFSET_DECAL );
  60. pShaderShadow->EnableBlending( true );
  61. pShaderShadow->BlendFunc( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
  62. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  63. pShaderShadow->DrawFlags( SHADER_DRAW_POSITION | SHADER_DRAW_TEXCOORD0 );
  64. FogToBlack();
  65. }
  66. DYNAMIC_STATE
  67. {
  68. BindTexture( SHADER_SAMPLER0, SELFILLUMTEXTURE, SELFILLUMTEXTUREFRAME );
  69. }
  70. Draw();
  71. }
  72. END_SHADER