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.

76 lines
2.2 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. BEGIN_SHADER( Cloud,
  12. "Help for Cloud" )
  13. BEGIN_SHADER_PARAMS
  14. SHADER_PARAM_OVERRIDE( BASETEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/cloud", "cloud texture", 0 )
  15. SHADER_PARAM( CLOUDALPHATEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/cloudalpha", "cloud alpha texture" )
  16. SHADER_PARAM( CLOUDSCALE, SHADER_PARAM_TYPE_VEC2, "[1 1]", "cloudscale" )
  17. SHADER_PARAM( MASKSCALE, SHADER_PARAM_TYPE_VEC2, "[1 1]", "maskscale" )
  18. END_SHADER_PARAMS
  19. SHADER_INIT
  20. {
  21. LoadTexture( BASETEXTURE );
  22. LoadTexture( CLOUDALPHATEXTURE );
  23. if( !params[CLOUDSCALE]->IsDefined() )
  24. {
  25. params[CLOUDSCALE]->SetVecValue( 1.0f, 1.0f );
  26. }
  27. if( !params[MASKSCALE]->IsDefined() )
  28. {
  29. params[MASKSCALE]->SetVecValue( 1.0f, 1.0f );
  30. }
  31. }
  32. SHADER_DRAW
  33. {
  34. if( g_pHardwareConfig->GetSamplerCount() >= 2 )
  35. {
  36. SHADOW_STATE
  37. {
  38. pShaderShadow->EnableDepthWrites( false );
  39. pShaderShadow->EnableBlending( true );
  40. if ( IS_FLAG_SET( MATERIAL_VAR_ADDITIVE ) )
  41. {
  42. pShaderShadow->BlendFunc( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
  43. }
  44. else
  45. {
  46. pShaderShadow->BlendFunc( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
  47. }
  48. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  49. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  50. pShaderShadow->DrawFlags( SHADER_DRAW_POSITION |
  51. SHADER_DRAW_TEXCOORD0 | SHADER_DRAW_TEXCOORD1 );
  52. DefaultFog();
  53. }
  54. DYNAMIC_STATE
  55. {
  56. BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME );
  57. BindTexture( SHADER_SAMPLER1, CLOUDALPHATEXTURE );
  58. // handle scrolling of base texture
  59. SetFixedFunctionTextureScaledTransform( MATERIAL_TEXTURE0,
  60. BASETEXTURETRANSFORM, CLOUDSCALE );
  61. SetFixedFunctionTextureScale( MATERIAL_TEXTURE1, MASKSCALE );
  62. }
  63. Draw();
  64. }
  65. else
  66. {
  67. ShaderWarning("Cloud not supported for single-texturing boards!\n");
  68. }
  69. }
  70. END_SHADER