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.

94 lines
2.9 KiB

  1. //========= Copyright � 1996-2009, Valve Corporation, All rights reserved. ============//
  2. //
  3. //=====================================================================================//
  4. #include "BaseVSShader.h"
  5. #include "black_vs20.inc"
  6. #include "black_ps20.inc"
  7. #include "black_ps20b.inc"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. BEGIN_VS_SHADER( Black, "Help for Black" )
  11. BEGIN_SHADER_PARAMS
  12. END_SHADER_PARAMS
  13. SHADER_INIT_PARAMS()
  14. {
  15. SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
  16. SET_FLAGS( MATERIAL_VAR_VERTEXFOG );
  17. }
  18. SHADER_FALLBACK
  19. {
  20. return 0;
  21. }
  22. SHADER_INIT
  23. {
  24. }
  25. SHADER_DRAW
  26. {
  27. SHADOW_STATE
  28. {
  29. // Set stream format (note that this shader supports compression)
  30. int flags = VERTEX_POSITION | VERTEX_FORMAT_COMPRESSED;
  31. // NOTE: Have to say that we want 1 texcoord here even though we don't use it or you'll get this Warning in another part of the code:
  32. // "ERROR: shader asking for a too-narrow vertex format - you will see errors if running with debug D3D DLLs!\n\tPadding the vertex format with extra texcoords"
  33. int nTexCoordCount = 1;
  34. int userDataSize = 0;
  35. pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
  36. DECLARE_STATIC_VERTEX_SHADER( black_vs20 );
  37. SET_STATIC_VERTEX_SHADER( black_vs20 );
  38. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  39. {
  40. DECLARE_STATIC_PIXEL_SHADER( black_ps20b );
  41. SET_STATIC_PIXEL_SHADER( black_ps20b );
  42. }
  43. else
  44. {
  45. DECLARE_STATIC_PIXEL_SHADER( black_ps20 );
  46. SET_STATIC_PIXEL_SHADER( black_ps20 );
  47. }
  48. pShaderShadow->EnableSRGBWrite( true );
  49. FogToFogColor();
  50. }
  51. DYNAMIC_STATE
  52. {
  53. DECLARE_DYNAMIC_VERTEX_SHADER( black_vs20 );
  54. SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, s_pShaderAPI->GetCurrentNumBones() > 0 );
  55. SET_DYNAMIC_VERTEX_SHADER( black_vs20 );
  56. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  57. {
  58. DECLARE_DYNAMIC_PIXEL_SHADER( black_ps20b );
  59. SET_DYNAMIC_PIXEL_SHADER( black_ps20b );
  60. }
  61. else
  62. {
  63. DECLARE_DYNAMIC_PIXEL_SHADER( black_ps20 );
  64. SET_DYNAMIC_PIXEL_SHADER( black_ps20 );
  65. }
  66. unsigned char gammaFogColor[3];
  67. pShaderAPI->GetSceneFogColor( gammaFogColor );
  68. Vector4D fogColorPostTonemapLinearSpace;
  69. float flToneMappingScaleLinear = pShaderAPI->GetToneMappingScaleLinear().x;
  70. fogColorPostTonemapLinearSpace.x = flToneMappingScaleLinear * SrgbGammaToLinear( ( 1.0f / 255.0f ) * gammaFogColor[0] );
  71. fogColorPostTonemapLinearSpace.y = flToneMappingScaleLinear * SrgbGammaToLinear( ( 1.0f / 255.0f ) * gammaFogColor[1] );
  72. fogColorPostTonemapLinearSpace.z = flToneMappingScaleLinear * SrgbGammaToLinear( ( 1.0f / 255.0f ) * gammaFogColor[2] );
  73. fogColorPostTonemapLinearSpace.w = 1.0f;
  74. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, fogColorPostTonemapLinearSpace.Base() );
  75. }
  76. Draw();
  77. }
  78. END_SHADER