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.

77 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 "cloud_vs11.inc"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. BEGIN_VS_SHADER( Cloud_dx8, "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, TEXTUREFLAGS_SRGB );
  22. LoadTexture( CLOUDALPHATEXTURE, TEXTUREFLAGS_SRGB );
  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. SHADOW_STATE
  35. {
  36. pShaderShadow->EnableDepthWrites( false );
  37. pShaderShadow->EnableBlending( true );
  38. if ( IS_FLAG_SET( MATERIAL_VAR_ADDITIVE ) )
  39. {
  40. pShaderShadow->BlendFunc( SHADER_BLEND_ONE, SHADER_BLEND_ONE );
  41. }
  42. else
  43. {
  44. pShaderShadow->BlendFunc( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
  45. }
  46. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  47. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  48. pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 2, 0, 0 );
  49. cloud_vs11_Static_Index vshIndex;
  50. pShaderShadow->SetVertexShader( "cloud_vs11", vshIndex.GetIndex() );
  51. pShaderShadow->SetPixelShader( "cloud_ps11" );
  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. SetVertexShaderTextureScaledTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, BASETEXTURETRANSFORM, CLOUDSCALE );
  60. SetVertexShaderTextureScale( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, MASKSCALE );
  61. pShaderAPI->SetVertexShaderIndex( 0 );
  62. }
  63. Draw();
  64. }
  65. END_SHADER