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.

98 lines
2.2 KiB

  1. //========== Copyright (c) Valve Corporation, All rights reserved. ==========//
  2. // STATIC: "SHOWALPHA" "0..1"
  3. // DYNAMIC: "ISCUBEMAP" "0..1"
  4. // DYNAMIC: "ISVOLUME" "0..1"
  5. // SKIP: $ISCUBEMAP && $ISVOLUME
  6. #include "common_ps_fxc.h"
  7. #if ISVOLUME
  8. sampler3D g_tSampler : register( s0 );
  9. #elif ISCUBEMAP
  10. samplerCUBE g_tSampler : register( s0 );
  11. #else // ISCUBEMAP
  12. sampler g_tSampler : register( s0 );
  13. #endif // !ISCUBEMAP
  14. struct PS_INPUT
  15. {
  16. float2 texCoord : TEXCOORD0;
  17. };
  18. const float4 g_vConst0 : register( c0 );
  19. #define g_flIsHdrCube g_vConst0.x
  20. #define g_flIsHdr2D g_vConst0.y
  21. #define g_flSliceCoord g_vConst0.z
  22. float4_color_return_type main( PS_INPUT i ) : COLOR
  23. {
  24. float4 result = { 0.0f, 0.0f, 0.0f, 1.0f };
  25. #if !ISCUBEMAP
  26. #if ISVOLUME
  27. float4 sample = tex3D( g_tSampler, float3( i.texCoord, g_flSliceCoord ) );
  28. #else
  29. float4 sample = tex2D( g_tSampler, i.texCoord );
  30. #endif
  31. result.rgb = sample.rgb;
  32. #if SHOWALPHA
  33. result.rgb = sample.a;
  34. #endif
  35. if ( g_flIsHdr2D )
  36. result.rgb *= MAX_HDR_OVERBRIGHT;
  37. #else // ISCUBEMAP
  38. bool bNoDataForThisPixel = false;
  39. float3 vec = float3( 0, 0, 0 );
  40. float x = i.texCoord.x;
  41. float y = i.texCoord.y;
  42. float x2 = frac( ( i.texCoord.x ) * 3.0f ) * 2.0f - 1.0f;
  43. float y2 = frac( ( i.texCoord.y ) * 4.0f ) * 2.0f - 1.0f;
  44. if ( ( x >= 0.3333f ) && ( x <= 0.6666f ) ) //Center row
  45. {
  46. if ( y >= 0.75f )
  47. vec = float3( x2, 1.0, y2 );
  48. else if ( y >= 0.5f )
  49. vec = float3( x2, y2, -1.0 );
  50. else if ( y >= 0.25f )
  51. vec = float3( x2, -1.0, -y2 );
  52. else if ( y >= 0.0f )
  53. vec = float3( x2, -y2, 1.0 );
  54. }
  55. else if ( ( y >= 0.25f ) && ( y <= 0.5f ) )
  56. {
  57. if ( x <= 0.3333f )
  58. vec = float3( -1.0f, -x2, -y2 );
  59. else if (x >= 0.6666f)
  60. vec = float3( 1.0f, x2, -y2 );
  61. else
  62. bNoDataForThisPixel = true;
  63. }
  64. else
  65. {
  66. bNoDataForThisPixel = true;
  67. }
  68. float4 cBase = texCUBE( g_tSampler, vec );
  69. #if SHOWALPHA
  70. cBase.rgb = cBase.a;
  71. #endif
  72. if ( g_flIsHdrCube )
  73. cBase.rgb *= ENV_MAP_SCALE;
  74. if ( bNoDataForThisPixel == true )
  75. cBase.rgb = float3( 0.9f, 0.4f, 0.15f );
  76. result.rgb = cBase.rgb;
  77. result.a = 1.0f; // - bNoDataForThisPixel;
  78. #endif // ISCUBEMAP
  79. return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_NONE );
  80. }