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.

115 lines
3.5 KiB

  1. //========= Copyright (c) 1996-2007, Valve Corporation, All rights reserved. ============//
  2. #include "BaseVSShader.h"
  3. #include "shaderlib/cshader.h"
  4. #include "debugtextureview_vs20.inc"
  5. #include "debugtextureview_ps20.inc"
  6. #include "debugtextureview_ps20b.inc"
  7. // NOTE: This has to be the last file included!
  8. #include "tier0/memdbgon.h"
  9. DEFINE_FALLBACK_SHADER( DebugTextureView, DebugTextureView_dx9 )
  10. BEGIN_VS_SHADER( DebugTextureView_dx9, "Help for DebugTextureView" )
  11. BEGIN_SHADER_PARAMS
  12. SHADER_PARAM( SHOWALPHA, SHADER_PARAM_TYPE_BOOL, "0", "" )
  13. END_SHADER_PARAMS
  14. SHADER_INIT
  15. {
  16. if ( params[BASETEXTURE]->IsDefined() )
  17. {
  18. LoadTexture( BASETEXTURE );
  19. }
  20. }
  21. SHADER_FALLBACK
  22. {
  23. return 0;
  24. }
  25. SHADER_DRAW
  26. {
  27. SHADOW_STATE
  28. {
  29. pShaderShadow->EnableDepthWrites( false );
  30. pShaderShadow->EnableAlphaTest( true );
  31. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  32. // Set stream format (note that this shader supports compression)
  33. unsigned int flags = VERTEX_POSITION | VERTEX_FORMAT_COMPRESSED;
  34. int nTexCoordCount = 1;
  35. int userDataSize = 0;
  36. pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize );
  37. DECLARE_STATIC_VERTEX_SHADER( debugtextureview_vs20 );
  38. SET_STATIC_VERTEX_SHADER( debugtextureview_vs20 );
  39. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  40. {
  41. DECLARE_STATIC_PIXEL_SHADER( debugtextureview_ps20b );
  42. SET_STATIC_PIXEL_SHADER_COMBO( SHOWALPHA, params[SHOWALPHA]->GetIntValue() != 0 );
  43. SET_STATIC_PIXEL_SHADER( debugtextureview_ps20b );
  44. }
  45. else
  46. {
  47. DECLARE_STATIC_PIXEL_SHADER( debugtextureview_ps20 );
  48. SET_STATIC_PIXEL_SHADER_COMBO( SHOWALPHA, params[SHOWALPHA]->GetIntValue() != 0 );
  49. SET_STATIC_PIXEL_SHADER( debugtextureview_ps20 );
  50. }
  51. }
  52. DYNAMIC_STATE
  53. {
  54. BindTexture( SHADER_SAMPLER0, TEXTURE_BINDFLAGS_NONE, BASETEXTURE, FRAME );
  55. //pShaderAPI->BindStandardTexture( SHADER_SAMPLER1, TEXTURE_LIGHTMAP );
  56. ITexture *pTexture = params[BASETEXTURE]->GetTextureValue();
  57. float cPsConst0[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
  58. if ( ( pTexture->GetImageFormat() == IMAGE_FORMAT_RGBA16161616F ) ||
  59. ( pTexture->GetImageFormat() == IMAGE_FORMAT_RGBA16161616 ) ||
  60. ( pTexture->GetImageFormat() == IMAGE_FORMAT_RGB323232F ) ||
  61. ( pTexture->GetImageFormat() == IMAGE_FORMAT_RGBA32323232F ) )
  62. {
  63. if ( pTexture->IsCubeMap() )
  64. cPsConst0[0] = 1.0f;
  65. else
  66. cPsConst0[1] = 1.0f;
  67. }
  68. if ( pTexture->IsVolumeTexture() )
  69. {
  70. int nSlices = pTexture->GetMappingDepth();
  71. int nDesiredSlice = int( Plat_FloatTime() ) % nSlices;
  72. cPsConst0[2] = float( nDesiredSlice * 2 + 1 ) / ( nSlices * 2 );
  73. }
  74. pShaderAPI->SetPixelShaderConstant( 0, cPsConst0 );
  75. DECLARE_DYNAMIC_VERTEX_SHADER( debugtextureview_vs20 );
  76. SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression );
  77. SET_DYNAMIC_VERTEX_SHADER( debugtextureview_vs20 );
  78. if( g_pHardwareConfig->SupportsPixelShaders_2_b() )
  79. {
  80. DECLARE_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20b );
  81. SET_DYNAMIC_PIXEL_SHADER_COMBO( ISCUBEMAP, pTexture->IsCubeMap() );
  82. SET_DYNAMIC_PIXEL_SHADER_COMBO( ISVOLUME, pTexture->IsVolumeTexture() );
  83. SET_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20b );
  84. }
  85. else
  86. {
  87. DECLARE_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20 );
  88. SET_DYNAMIC_PIXEL_SHADER_COMBO( ISCUBEMAP, pTexture->IsCubeMap() );
  89. SET_DYNAMIC_PIXEL_SHADER_COMBO( ISVOLUME, pTexture->IsVolumeTexture() );
  90. SET_DYNAMIC_PIXEL_SHADER( debugtextureview_ps20 );
  91. }
  92. }
  93. Draw();
  94. }
  95. END_SHADER