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.

81 lines
2.9 KiB

  1. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  2. // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
  3. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps20b] [PC]
  4. // DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..0" [ps20b] [XBOX]
  5. #include "common_ps_fxc.h"
  6. #if defined( SHADER_MODEL_PS_2_0 )
  7. # define WRITE_DEPTH_TO_DESTALPHA 0
  8. #endif
  9. sampler RGBSTextureSampler : register( s0 );
  10. HALF4 InputScale : register( c0 );
  11. float2 texWidthHeight : register( c1 );
  12. float4 texOffsets : register( c2 );
  13. struct PS_INPUT
  14. {
  15. //#if defined( _X360 )
  16. // float2 baseTexCoord : TEXCOORD0;
  17. //#else
  18. float2 baseTexCoord00 : TEXCOORD0;
  19. float2 baseTexCoord01 : TEXCOORD1;
  20. float2 baseTexCoord10 : TEXCOORD2;
  21. float2 baseTexCoord11 : TEXCOORD3;
  22. float2 baseTexCoord_In_Pixels: TEXCOORD4;
  23. //#endif
  24. };
  25. float4 main( PS_INPUT i ) : COLOR
  26. {
  27. float3 result;
  28. //#if defined( _X360 ) //360 has a cheaper way to handle RGBscale
  29. // float4 Weights;
  30. // float4 samples_0; //no arrays allowed in inline assembly
  31. // float4 samples_1;
  32. // float4 samples_2;
  33. // float4 samples_3;
  34. // float2 vTexCoord = i.baseTexCoord;
  35. //
  36. // asm {
  37. // tfetch2D samples_0, vTexCoord.xy, RGBSTextureSampler, OffsetX = -0.5, OffsetY = -0.5, MinFilter=point, MagFilter=point, MipFilter=keep, UseComputedLOD=false
  38. // tfetch2D samples_1, vTexCoord.xy, RGBSTextureSampler, OffsetX = 0.5, OffsetY = -0.5, MinFilter=point, MagFilter=point, MipFilter=keep, UseComputedLOD=false
  39. // tfetch2D samples_2, vTexCoord.xy, RGBSTextureSampler, OffsetX = -0.5, OffsetY = 0.5, MinFilter=point, MagFilter=point, MipFilter=keep, UseComputedLOD=false
  40. // tfetch2D samples_3, vTexCoord.xy, RGBSTextureSampler, OffsetX = 0.5, OffsetY = 0.5, MinFilter=point, MagFilter=point, MipFilter=keep, UseComputedLOD=false
  41. //
  42. // getWeights2D Weights, vTexCoord.xy, RGBSTextureSampler
  43. // };
  44. //
  45. // Weights = float4( (1-Weights.x)*(1-Weights.y), Weights.x*(1-Weights.y), (1-Weights.x)*Weights.y, Weights.x*Weights.y );
  46. //
  47. // result.rgb = samples_0.rgb * (samples_0.a * Weights.x);
  48. // result.rgb += samples_1.rgb * (samples_1.a * Weights.y);
  49. // result.rgb += samples_2.rgb * (samples_2.a * Weights.z);
  50. // result.rgb += samples_3.rgb * (samples_3.a * Weights.w);
  51. //
  52. //#else
  53. float4 s00 = tex2D(RGBSTextureSampler, i.baseTexCoord00);
  54. float4 s10 = tex2D(RGBSTextureSampler, i.baseTexCoord10);
  55. float4 s01 = tex2D(RGBSTextureSampler, i.baseTexCoord01);
  56. float4 s11 = tex2D(RGBSTextureSampler, i.baseTexCoord11);
  57. float2 fracCoord = frac(i.baseTexCoord_In_Pixels);
  58. s00.rgb*=s00.a;
  59. s10.rgb*=s10.a;
  60. s00.xyz = lerp(s00, s10, fracCoord.x);
  61. s01.rgb*=s01.a;
  62. s11.rgb*=s11.a;
  63. s01.xyz = lerp(s01, s11, fracCoord.x);
  64. result = lerp(s00, s01, fracCoord.y);
  65. //#endif
  66. // This is never fogged.
  67. return FinalOutput( float4( InputScale*result, 1.0f ), 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR, WRITE_DEPTH_TO_DESTALPHA, 1e20 ); //when writing depth to dest alpha, write a value guaranteed to saturate
  68. }