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.

110 lines
3.3 KiB

  1. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b] [= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  2. // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
  3. // STATIC: "BASETEXTURE" "0..1"
  4. // STATIC: "MULTITEXTURE" "0..1"
  5. // STATIC: "REFLECT" "0..1"
  6. // STATIC: "REFRACT" "0..1"
  7. // STATIC: "ABOVEWATER" "0..1"
  8. // STATIC: "BLURRY_REFRACT" "0..1" [ps20b]
  9. // When we turn NORMAL_DECODE_MODE on, this shader only needs 0..1, not 0..2
  10. // STATIC: "NORMAL_DECODE_MODE" "0..0" [XBOX]
  11. // STATIC: "NORMAL_DECODE_MODE" "0..0" [PC]
  12. // DYNAMIC: "PIXELFOGTYPE" "0..1"
  13. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC]
  14. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX]
  15. // SKIP: $MULTITEXTURE && $BASETEXTURE
  16. #if defined(SHADER_MODEL_PS_2_0)
  17. # define BLURRY_REFRACT 0
  18. # define WRITE_DEPTH_TO_DESTALPHA 0
  19. #endif
  20. #include "water_ps2x_helper.h"
  21. sampler RefractSampler : register( s0 );
  22. #if BASETEXTURE
  23. sampler BaseTextureSampler : register( s1 );
  24. #endif
  25. sampler ReflectSampler : register( s2 );
  26. #if BASETEXTURE
  27. sampler LightmapSampler : register( s3 );
  28. #endif
  29. sampler NormalSampler : register( s4 );
  30. const HALF4 vRefractTint : register( c1 );
  31. const HALF4 vReflectTint : register( c4 );
  32. const float4 g_ReflectRefractScale : register( c5 ); // xy - reflect scale, zw - refract scale
  33. const HALF4 g_WaterFogColor : register( c6 );
  34. const HALF4 g_WaterFogParams : register( c7 );
  35. const float4 g_PixelFogParams : register( c8 );
  36. #define g_WaterFogStart g_WaterFogParams.x
  37. #define g_WaterFogEndMinusStart g_WaterFogParams.y
  38. #define g_Reflect_OverBright g_WaterFogParams.z
  39. struct PS_INPUT
  40. {
  41. float2 vBumpTexCoord : TEXCOORD0;
  42. half3 vTangentEyeVect : TEXCOORD1;
  43. float4 vReflectXY_vRefractYX : TEXCOORD2;
  44. float W : TEXCOORD3;
  45. float4 vProjPos : TEXCOORD4;
  46. float screenCoord : TEXCOORD5;
  47. #if MULTITEXTURE
  48. float4 vExtraBumpTexCoord : TEXCOORD6;
  49. #endif
  50. #if BASETEXTURE
  51. // CENTROID: TEXCOORD6
  52. HALF4 lightmapTexCoord1And2 : TEXCOORD6;
  53. // CENTROID: TEXCOORD7
  54. HALF4 lightmapTexCoord3 : TEXCOORD7;
  55. #endif
  56. float4 fogFactorW : COLOR1;
  57. };
  58. float4 main( PS_INPUT i ) : COLOR
  59. {
  60. DrawWater_params_t params;
  61. params.vBumpTexCoord = i.vBumpTexCoord;
  62. #if MULTITEXTURE
  63. params.vExtraBumpTexCoord = i.vExtraBumpTexCoord;
  64. #endif
  65. params.vReflectXY_vRefractYX = i.vReflectXY_vRefractYX;
  66. params.w = i.W;
  67. params.vReflectRefractScale = g_ReflectRefractScale;
  68. params.fReflectOverbright = g_Reflect_OverBright;
  69. params.vReflectTint = vReflectTint;
  70. params.vRefractTint = vRefractTint;
  71. params.vTangentEyeVect = i.vTangentEyeVect;
  72. params.waterFogColor = g_WaterFogColor;
  73. #if BASETEXTURE
  74. params.lightmapTexCoord1And2 = i.lightmapTexCoord1And2;
  75. params.lightmapTexCoord3 = i.lightmapTexCoord3;
  76. #endif
  77. params.vProjPos = i.vProjPos;
  78. params.pixelFogParams = g_PixelFogParams;
  79. params.fWaterFogStart = g_WaterFogStart;
  80. params.fWaterFogEndMinusStart = g_WaterFogEndMinusStart;
  81. float4 result;
  82. float fogFactor;
  83. DrawWater( params,
  84. // yay. . can't put sampler in a struct.
  85. #if BASETEXTURE
  86. BaseTextureSampler,
  87. LightmapSampler,
  88. #endif
  89. NormalSampler, RefractSampler, ReflectSampler,
  90. result, fogFactor );
  91. return FinalOutput( float4( result.rgb, 1.0f ), fogFactor, PIXELFOGTYPE, TONEMAP_SCALE_NONE, (WRITE_DEPTH_TO_DESTALPHA != 0), i.vProjPos.z );
  92. }