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
1.9 KiB

  1. // STATIC: "CONVERT_TO_SRGB" "0..1" [ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
  2. // STATIC: "CONVERT_TO_SRGB" "0..0" [= 0] [XBOX]
  3. // STATIC: "SHOWALPHA" "0..1"
  4. // DYNAMIC: "ISCUBEMAP" "0..1"
  5. #define HDRTYPE HDR_TYPE_NONE
  6. #include "common_ps_fxc.h"
  7. sampler g_tSampler : register( s0 );
  8. struct PS_INPUT
  9. {
  10. float2 texCoord : TEXCOORD0;
  11. };
  12. const float3 g_vConst0 : register( c0 );
  13. #define g_flIsHdrCube g_vConst0.x
  14. #define g_flIsHdr2D g_vConst0.y
  15. float4 main( PS_INPUT i ) : COLOR
  16. {
  17. float4 sample = tex2D( g_tSampler, i.texCoord );
  18. float4 result = { 0.0f, 0.0f, 0.0f, 1.0f };
  19. result.rgb = sample.rgb;
  20. #if SHOWALPHA
  21. result.rgb = sample.a;
  22. #endif
  23. if ( g_flIsHdr2D )
  24. result.rgb *= MAX_HDR_OVERBRIGHT;
  25. #if ISCUBEMAP
  26. bool bNoDataForThisPixel = false;
  27. float3 vec = float3( 0, 0, 0 );
  28. float x = i.texCoord.x;
  29. float y = i.texCoord.y;
  30. float x2 = frac( ( i.texCoord.x ) * 3.0f ) * 2.0f - 1.0f;
  31. float y2 = frac( ( i.texCoord.y ) * 4.0f ) * 2.0f - 1.0f;
  32. if ( ( x >= 0.3333f ) && ( x <= 0.6666f ) ) //Center row
  33. {
  34. if ( y >= 0.75f )
  35. vec = float3( x2, 1.0, y2 );
  36. else if ( y >= 0.5f )
  37. vec = float3( x2, y2, -1.0 );
  38. else if ( y >= 0.25f )
  39. vec = float3( x2, -1.0, -y2 );
  40. else if ( y >= 0.0f )
  41. vec = float3( x2, -y2, 1.0 );
  42. }
  43. else if ( ( y >= 0.25f ) && ( y <= 0.5f ) )
  44. {
  45. if ( x <= 0.3333f )
  46. vec = float3( -1.0f, -x2, -y2 );
  47. else if (x >= 0.6666f)
  48. vec = float3( 1.0f, x2, -y2 );
  49. else
  50. bNoDataForThisPixel = true;
  51. }
  52. else
  53. {
  54. bNoDataForThisPixel = true;
  55. }
  56. float4 cBase = texCUBE( g_tSampler, vec );
  57. #if SHOWALPHA
  58. cBase.rgb = cBase.a;
  59. #endif
  60. if ( g_flIsHdrCube )
  61. cBase.rgb *= ENV_MAP_SCALE;
  62. if ( bNoDataForThisPixel == true )
  63. cBase.rgb = float3( 0.9f, 0.4f, 0.15f );
  64. result.rgb = cBase.rgb;
  65. result.a = 1.0f; // - bNoDataForThisPixel;
  66. #endif
  67. return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
  68. }