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.

62 lines
1.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "shaderlib/cshader.h"
  7. // memdbgon must be the last include file in a .cpp file!!!
  8. #include "tier0/memdbgon.h"
  9. DEFINE_FALLBACK_SHADER( Cable, Cable_DX6 )
  10. BEGIN_SHADER( Cable_DX6,
  11. "Help for Cable_DX6" )
  12. BEGIN_SHADER_PARAMS
  13. SHADER_PARAM( MINLIGHT, SHADER_PARAM_TYPE_FLOAT, "0.25", "Minimum amount of light (0-1 value)" )
  14. SHADER_PARAM( MAXLIGHT, SHADER_PARAM_TYPE_FLOAT, "0.25", "Maximum amount of light" )
  15. END_SHADER_PARAMS
  16. SHADER_INIT_PARAMS()
  17. {
  18. }
  19. SHADER_INIT
  20. {
  21. LoadTexture( BASETEXTURE );
  22. }
  23. int GetDrawFlagsPass1(IMaterialVar** params )
  24. {
  25. int flags = SHADER_DRAW_POSITION;
  26. if (IS_FLAG_SET(MATERIAL_VAR_VERTEXCOLOR))
  27. flags |= SHADER_DRAW_COLOR;
  28. flags |= SHADER_DRAW_TEXCOORD0;
  29. return flags;
  30. }
  31. SHADER_DRAW
  32. {
  33. SHADOW_STATE
  34. {
  35. pShaderShadow->EnableConstantColor( true );
  36. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  37. SetNormalBlendingShadowState( BASETEXTURE, true );
  38. pShaderShadow->DrawFlags( GetDrawFlagsPass1(params) );
  39. FogToFogColor();
  40. }
  41. DYNAMIC_STATE
  42. {
  43. BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME );
  44. SetFixedFunctionTextureTransform( MATERIAL_TEXTURE0, BASETEXTURETRANSFORM );
  45. Vector min, max;
  46. params[MINLIGHT]->GetVecValue( &min.x, 3 );
  47. params[MAXLIGHT]->GetVecValue( &max.x, 3 );
  48. Vector avg = ( min + max ) * 0.5f;
  49. pShaderAPI->Color3fv( &avg.x );
  50. }
  51. Draw( );
  52. }
  53. END_SHADER