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.

82 lines
2.9 KiB

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