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.

97 lines
2.4 KiB

  1. //===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $Header: $
  6. // $NoKeywords: $
  7. //===========================================================================//
  8. #include "shaderlib/CShader.h"
  9. #include "debugluxel_ps20b.inc"
  10. #include "debugluxel_ps20.inc"
  11. #include "debugluxel_vs20.inc"
  12. // memdbgon must be the last include file in a .cpp file!!!
  13. #include "tier0/memdbgon.h"
  14. BEGIN_SHADER_FLAGS( DebugLuxels, "Help for DebugLuxels", SHADER_NOT_EDITABLE )
  15. BEGIN_SHADER_PARAMS
  16. SHADER_PARAM( NOSCALE, SHADER_PARAM_TYPE_BOOL, "0", "fixme" )
  17. END_SHADER_PARAMS
  18. SHADER_INIT_PARAMS()
  19. {
  20. SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE );
  21. SET_FLAGS2( MATERIAL_VAR2_LIGHTING_LIGHTMAP );
  22. if( g_pHardwareConfig->GetDXSupportLevel() >= 90 )
  23. {
  24. SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
  25. }
  26. }
  27. SHADER_INIT
  28. {
  29. LoadTexture( BASETEXTURE );
  30. }
  31. SHADER_DRAW
  32. {
  33. SHADOW_STATE
  34. {
  35. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  36. DECLARE_STATIC_VERTEX_SHADER( debugluxel_vs20 );
  37. SET_STATIC_VERTEX_SHADER( debugluxel_vs20 );
  38. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  39. {
  40. DECLARE_STATIC_PIXEL_SHADER( debugluxel_ps20b );
  41. SET_STATIC_PIXEL_SHADER( debugluxel_ps20b );
  42. }
  43. else
  44. {
  45. DECLARE_STATIC_PIXEL_SHADER( debugluxel_ps20 );
  46. SET_STATIC_PIXEL_SHADER( debugluxel_ps20 );
  47. }
  48. SetDefaultBlendingShadowState( BASETEXTURE );
  49. DisableFog();
  50. pShaderShadow->VertexShaderVertexFormat( VERTEX_POSITION, 2, NULL, 0 );
  51. }
  52. DYNAMIC_STATE
  53. {
  54. BindTexture( SHADER_SAMPLER0, BASETEXTURE, FRAME );
  55. int texCoordScaleX = 1, texCoordScaleY = 1;
  56. if (!params[NOSCALE]->GetIntValue())
  57. {
  58. pShaderAPI->GetLightmapDimensions( &texCoordScaleX, &texCoordScaleY );
  59. }
  60. DECLARE_DYNAMIC_VERTEX_SHADER( debugluxel_vs20 );
  61. SET_DYNAMIC_VERTEX_SHADER( debugluxel_vs20 );
  62. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  63. {
  64. DECLARE_DYNAMIC_PIXEL_SHADER( debugluxel_ps20b );
  65. SET_DYNAMIC_PIXEL_SHADER( debugluxel_ps20b );
  66. }
  67. else
  68. {
  69. DECLARE_DYNAMIC_PIXEL_SHADER( debugluxel_ps20 );
  70. SET_DYNAMIC_PIXEL_SHADER( debugluxel_ps20 );
  71. }
  72. //texture scale transform
  73. Vector4D transformation[2];
  74. transformation[0].Init( texCoordScaleX, 0.0f, 0.0f, 0.0f );
  75. transformation[1].Init( 0.0f, texCoordScaleY, 0.0f, 0.0f );
  76. s_pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, transformation[0].Base(), 2 );
  77. }
  78. Draw();
  79. }
  80. END_SHADER