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.

99 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "BaseVSShader.h"
  8. #include "predator.inc"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. DEFINE_FALLBACK_SHADER( Predator, Predator_DX80 )
  12. BEGIN_VS_SHADER( Predator_DX80,
  13. "Help for Predator" )
  14. BEGIN_SHADER_PARAMS
  15. SHADER_PARAM( REFRACTIONAMOUNT, SHADER_PARAM_TYPE_VEC2, "[0.2 0.2]", "refaction amount" )
  16. SHADER_PARAM( ENVMAP, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_env", "envmap" )
  17. SHADER_PARAM( ENVMAPFRAME, SHADER_PARAM_TYPE_INTEGER, "", "envmap frame number" )
  18. SHADER_PARAM( ENVMAPMASK, SHADER_PARAM_TYPE_TEXTURE, "shadertest/shadertest_envmask", "envmap mask" )
  19. SHADER_PARAM( ENVMAPMASKFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "" )
  20. SHADER_PARAM( ENVMAPMASKSCALE, SHADER_PARAM_TYPE_FLOAT, "1", "envmap mask scale" )
  21. SHADER_PARAM( ENVMAPTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "envmap tint" )
  22. SHADER_PARAM( REFRACTTINT, SHADER_PARAM_TYPE_COLOR, "[1 1 1]", "refraction tint" )
  23. SHADER_PARAM( BUMPMAP, SHADER_PARAM_TYPE_TEXTURE, "models/shadertes/shader1_normal", "bump map" )
  24. SHADER_PARAM( BUMPFRAME, SHADER_PARAM_TYPE_INTEGER, "0", "frame number for $bumpmap" )
  25. SHADER_PARAM( BUMPOFFSET, SHADER_PARAM_TYPE_VEC2, "[0 0]", "2D bump offset for texture scrolling" )
  26. END_SHADER_PARAMS
  27. SHADER_INIT_PARAMS()
  28. {
  29. SET_FLAGS2( MATERIAL_VAR2_NEEDS_TANGENT_SPACES );
  30. SET_FLAGS2( MATERIAL_VAR2_SUPPORTS_HW_SKINNING );
  31. SET_FLAGS( MATERIAL_VAR_TRANSLUCENT );
  32. SET_FLAGS2( MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE );
  33. }
  34. SHADER_FALLBACK
  35. {
  36. if (!g_pHardwareConfig->SupportsVertexAndPixelShaders())
  37. return "Predator_DX60";
  38. return 0;
  39. }
  40. SHADER_INIT
  41. {
  42. if( params[ENVMAP]->IsDefined() )
  43. {
  44. LoadCubeMap( ENVMAP );
  45. }
  46. if( params[ENVMAPMASK]->IsDefined() )
  47. {
  48. LoadTexture( ENVMAPMASK );
  49. }
  50. if( !params[ENVMAPTINT]->IsDefined() )
  51. {
  52. params[ENVMAPTINT]->SetVecValue( 1.0f, 1.0f, 1.0f );
  53. }
  54. if( !params[REFRACTTINT]->IsDefined() )
  55. {
  56. params[REFRACTTINT]->SetVecValue( 1.0f, 1.0f, 1.0f );
  57. }
  58. }
  59. SHADER_DRAW
  60. {
  61. // Refractive pass
  62. SHADOW_STATE
  63. {
  64. pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
  65. int fmt = VERTEX_POSITION | VERTEX_NORMAL;
  66. pShaderShadow->VertexShaderVertexFormat( fmt, 1, 0, 0 );
  67. predator_Static_Index vshIndex;
  68. pShaderShadow->SetVertexShader( "predator", vshIndex.GetIndex() );
  69. pShaderShadow->SetPixelShader( "predator" );
  70. }
  71. DYNAMIC_STATE
  72. {
  73. pShaderAPI->SetDefaultState();
  74. pShaderAPI->BindStandardTexture( SHADER_SAMPLER0, TEXTURE_FRAME_BUFFER_FULL_TEXTURE_0 );
  75. SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_4, REFRACTIONAMOUNT );
  76. float c95[4] = { 1.0f, 1.0f, 0.0f, 0.0f };
  77. pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_5, c95, 1 );
  78. SetPixelShaderConstant( 2, REFRACTTINT );
  79. predator_Dynamic_Index vshIndex;
  80. vshIndex.SetDOWATERFOG( pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z );
  81. vshIndex.SetSKINNING( pShaderAPI->GetCurrentNumBones() > 0 );
  82. pShaderAPI->SetVertexShaderIndex( vshIndex.GetIndex() );
  83. }
  84. Draw();
  85. }
  86. END_SHADER