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.

132 lines
3.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Header: $
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #include "BaseVSShader.h"
  9. #include "cpp_shader_constant_register_map.h"
  10. #include "bik_ps20.inc"
  11. #include "bik_ps20b.inc"
  12. #include "bik_vs20.inc"
  13. BEGIN_VS_SHADER( Bik, "Help for Bik" )
  14. BEGIN_SHADER_PARAMS
  15. SHADER_PARAM( YTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Y Bink Texture" )
  16. // re-enable this if we want alpha blending
  17. // SHADER_PARAM( ATEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "A Bink Texture" )
  18. SHADER_PARAM( CRTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Cr Bink Texture" )
  19. SHADER_PARAM( CBTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Cb Bink Texture" )
  20. END_SHADER_PARAMS
  21. SHADER_INIT_PARAMS()
  22. {
  23. }
  24. SHADER_FALLBACK
  25. {
  26. if ( g_pHardwareConfig->GetDXSupportLevel() < 90 )
  27. {
  28. return "bik_dx81";
  29. }
  30. return 0;
  31. }
  32. SHADER_INIT
  33. {
  34. if ( params[YTEXTURE]->IsDefined() )
  35. {
  36. LoadTexture( YTEXTURE );
  37. }
  38. // if ( params[ATEXTURE]->IsDefined() )
  39. // {
  40. // LoadTexture( ATEXTURE );
  41. // }
  42. if ( params[CRTEXTURE]->IsDefined() )
  43. {
  44. LoadTexture( CRTEXTURE );
  45. }
  46. if ( params[CBTEXTURE]->IsDefined() )
  47. {
  48. LoadTexture( CBTEXTURE );
  49. }
  50. }
  51. SHADER_DRAW
  52. {
  53. SHADOW_STATE
  54. {
  55. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  56. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  57. pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
  58. // pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
  59. unsigned int flags = VERTEX_POSITION;
  60. int numTexCoords = 1;
  61. pShaderShadow->VertexShaderVertexFormat( flags, numTexCoords, 0, 0 );
  62. DECLARE_STATIC_VERTEX_SHADER( bik_vs20 );
  63. SET_STATIC_VERTEX_SHADER( bik_vs20 );
  64. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  65. {
  66. DECLARE_STATIC_PIXEL_SHADER( bik_ps20b );
  67. SET_STATIC_PIXEL_SHADER( bik_ps20b );
  68. }
  69. else
  70. {
  71. DECLARE_STATIC_PIXEL_SHADER( bik_ps20 );
  72. SET_STATIC_PIXEL_SHADER( bik_ps20 );
  73. }
  74. // The 360 needs an sRGB write, but NOT an sRGB read!
  75. if ( IsX360() )
  76. pShaderShadow->EnableSRGBWrite( true );
  77. else
  78. pShaderShadow->EnableSRGBWrite( false );
  79. // EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
  80. }
  81. DYNAMIC_STATE
  82. {
  83. BindTexture( SHADER_SAMPLER0, YTEXTURE, FRAME );
  84. BindTexture( SHADER_SAMPLER1, CRTEXTURE, FRAME );
  85. BindTexture( SHADER_SAMPLER2, CBTEXTURE, FRAME );
  86. // BindTexture( SHADER_SAMPLER3, ATEXTURE, FRAME );
  87. // We need the view matrix
  88. LoadViewMatrixIntoVertexShaderConstant( VERTEX_SHADER_VIEWMODEL );
  89. MaterialFogMode_t fogType = pShaderAPI->GetSceneFogMode();
  90. int fogIndex = ( fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ? 1 : 0;
  91. DECLARE_DYNAMIC_VERTEX_SHADER( bik_vs20 );
  92. SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex );
  93. SET_DYNAMIC_VERTEX_SHADER( bik_vs20 );
  94. pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS );
  95. float vEyePos_SpecExponent[4];
  96. pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent );
  97. vEyePos_SpecExponent[3] = 0.0f;
  98. pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 );
  99. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  100. {
  101. DECLARE_DYNAMIC_PIXEL_SHADER( bik_ps20b );
  102. SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
  103. SET_DYNAMIC_PIXEL_SHADER( bik_ps20b );
  104. }
  105. else
  106. {
  107. DECLARE_DYNAMIC_PIXEL_SHADER( bik_ps20 );
  108. SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
  109. SET_DYNAMIC_PIXEL_SHADER( bik_ps20 );
  110. }
  111. }
  112. Draw( );
  113. }
  114. END_SHADER