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.

86 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Header: $
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #include "BaseVSShader.h"
  9. #include "decalmodulate_vs11.inc"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. DEFINE_FALLBACK_SHADER( DecalModulate, DecalModulate_DX8 )
  13. BEGIN_VS_SHADER( DecalModulate_DX8, "" )
  14. BEGIN_SHADER_PARAMS
  15. END_SHADER_PARAMS
  16. SHADER_FALLBACK
  17. {
  18. if ( IsPC() && g_pHardwareConfig->GetDXSupportLevel() < 80 )
  19. return "DecalModulate_DX6";
  20. return 0;
  21. }
  22. SHADER_INIT_PARAMS()
  23. {
  24. SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE );
  25. }
  26. SHADER_INIT
  27. {
  28. LoadTexture( BASETEXTURE );
  29. }
  30. SHADER_DRAW
  31. {
  32. SHADOW_STATE
  33. {
  34. pShaderShadow->EnableAlphaTest( true );
  35. pShaderShadow->EnableDepthWrites( false );
  36. pShaderShadow->EnablePolyOffset( SHADER_POLYOFFSET_DECAL );
  37. pShaderShadow->EnableTexture( SHADER_TEXTURE_STAGE0, true );
  38. pShaderShadow->EnableBlending( true );
  39. pShaderShadow->BlendFunc( SHADER_BLEND_DST_COLOR, SHADER_BLEND_SRC_COLOR );
  40. FogToGrey();
  41. decalmodulate_vs11_Static_Index vshIndex;
  42. s_pShaderShadow->SetVertexShader( "decalmodulate_vs11", vshIndex.GetIndex() );
  43. s_pShaderShadow->SetPixelShader( "decalmodulate_ps11", 0 );
  44. pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 1, 0, 0, 0 );
  45. }
  46. DYNAMIC_STATE
  47. {
  48. if ( pShaderAPI->InFlashlightMode() )
  49. {
  50. // Don't draw anything for the flashlight pass
  51. Draw( false );
  52. return;
  53. }
  54. BindTexture( SHADER_TEXTURE_STAGE0, BASETEXTURE, FRAME );
  55. // Set an identity base texture transformation
  56. Vector4D transformation[2];
  57. transformation[0].Init( 1.0f, 0.0f, 0.0f, 0.0f );
  58. transformation[1].Init( 0.0f, 1.0f, 0.0f, 0.0f );
  59. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, transformation[0].Base(), 2 );
  60. MaterialFogMode_t fogType = s_pShaderAPI->GetSceneFogMode();
  61. int fogIndex = ( fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ? 1 : 0;
  62. decalmodulate_vs11_Dynamic_Index vshIndex;
  63. vshIndex.SetDOWATERFOG( fogIndex );
  64. vshIndex.SetSKINNING( 0 );
  65. s_pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() );
  66. }
  67. Draw();
  68. }
  69. END_SHADER