Counter Strike : Global Offensive Source Code
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.

133 lines
3.8 KiB

  1. //========= Copyright (c) 1996-2006, 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. // NOTE: This has to be the last file included!
  14. #include "tier0/memdbgon.h"
  15. BEGIN_VS_SHADER( Bik, "Help for Bik" )
  16. BEGIN_SHADER_PARAMS
  17. SHADER_PARAM( YTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Y Bink Texture" )
  18. // re-enable this if we want alpha blending
  19. // SHADER_PARAM( ATEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "A Bink Texture" )
  20. SHADER_PARAM( CRTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Cr Bink Texture" )
  21. SHADER_PARAM( CBTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Cb Bink Texture" )
  22. END_SHADER_PARAMS
  23. SHADER_INIT_PARAMS()
  24. {
  25. }
  26. SHADER_FALLBACK
  27. {
  28. return 0;
  29. }
  30. SHADER_INIT
  31. {
  32. if ( params[YTEXTURE]->IsDefined() )
  33. {
  34. LoadTexture( YTEXTURE );
  35. }
  36. // if ( params[ATEXTURE]->IsDefined() )
  37. // {
  38. // LoadTexture( ATEXTURE );
  39. // }
  40. if ( params[CRTEXTURE]->IsDefined() )
  41. {
  42. LoadTexture( CRTEXTURE );
  43. }
  44. if ( params[CBTEXTURE]->IsDefined() )
  45. {
  46. LoadTexture( CBTEXTURE );
  47. }
  48. }
  49. SHADER_DRAW
  50. {
  51. SHADOW_STATE
  52. {
  53. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  54. pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
  55. pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
  56. // pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
  57. unsigned int flags = VERTEX_POSITION | VERTEX_COLOR;
  58. bool bHasVertexAlpha = IS_FLAG_SET( MATERIAL_VAR_VERTEXALPHA );
  59. int numTexCoords = 1;
  60. pShaderShadow->VertexShaderVertexFormat( flags, numTexCoords, 0, 0 );
  61. DECLARE_STATIC_VERTEX_SHADER( bik_vs20 );
  62. SET_STATIC_VERTEX_SHADER( bik_vs20 );
  63. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  64. {
  65. DECLARE_STATIC_PIXEL_SHADER( bik_ps20b );
  66. SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha );
  67. SET_STATIC_PIXEL_SHADER( bik_ps20b );
  68. }
  69. else
  70. {
  71. DECLARE_STATIC_PIXEL_SHADER( bik_ps20 );
  72. SET_STATIC_PIXEL_SHADER_COMBO( VERTEXALPHA, bHasVertexAlpha );
  73. SET_STATIC_PIXEL_SHADER( bik_ps20 );
  74. }
  75. // The 360 needs an sRGB write, but NOT an sRGB read!
  76. // Commenting this out because we're not using PWL textures on X360 for Portal2. Also see the disabled shader sRGB read in bik_ps2x.fxc.
  77. //if ( IsX360() )
  78. // pShaderShadow->EnableSRGBWrite( true );
  79. //else
  80. pShaderShadow->EnableSRGBWrite( false );
  81. if ( bHasVertexAlpha )
  82. {
  83. EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
  84. }
  85. }
  86. DYNAMIC_STATE
  87. {
  88. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, YTEXTURE, FRAME );
  89. BindTexture( SHADER_SAMPLER1, TEXTURE_BINDFLAGS_NONE, CRTEXTURE, FRAME );
  90. BindTexture( SHADER_SAMPLER2, TEXTURE_BINDFLAGS_NONE, CBTEXTURE, FRAME );
  91. // BindTexture( SHADER_SAMPLER3, ATEXTURE, FRAME );
  92. // We need the view matrix
  93. LoadViewMatrixIntoVertexShaderConstant( VERTEX_SHADER_VIEWMODEL );
  94. DECLARE_DYNAMIC_VERTEX_SHADER( bik_vs20 );
  95. SET_DYNAMIC_VERTEX_SHADER( bik_vs20 );
  96. pShaderAPI->SetPixelShaderFogParams( PSREG_FOG_PARAMS );
  97. float vEyePos_SpecExponent[4];
  98. pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent );
  99. vEyePos_SpecExponent[3] = 0.0f;
  100. pShaderAPI->SetPixelShaderConstant( PSREG_EYEPOS_SPEC_EXPONENT, vEyePos_SpecExponent, 1 );
  101. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  102. {
  103. DECLARE_DYNAMIC_PIXEL_SHADER( bik_ps20b );
  104. SET_DYNAMIC_PIXEL_SHADER( bik_ps20b );
  105. }
  106. else
  107. {
  108. DECLARE_DYNAMIC_PIXEL_SHADER( bik_ps20 );
  109. SET_DYNAMIC_PIXEL_SHADER( bik_ps20 );
  110. }
  111. }
  112. Draw( );
  113. }
  114. END_SHADER