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.

44 lines
820 B

  1. // STATIC: "COLOR_DEPTH" "0..1"
  2. // DYNAMIC: "ALPHACLIP" "0..1"
  3. const float g_AlphaThreshold : register( c0 );
  4. const float2 g_vNearFarPlanes : register( c1 );
  5. #define g_flNearPlane g_vNearFarPlanes.x
  6. #define g_flFarPlane g_vNearFarPlanes.y
  7. struct PS_INPUT
  8. {
  9. #if ALPHACLIP
  10. float2 texCoord0 : TEXCOORD0;
  11. #endif
  12. #if COLOR_DEPTH
  13. float4 vWorldPos_projPosZ : TEXCOORD1;
  14. #endif
  15. };
  16. sampler BaseTextureSampler : register( s0 );
  17. float4 main( PS_INPUT i ) : COLOR
  18. {
  19. float4 color = float4( 1, 0, 0, 1 ); // opaque alpha....the color doesn't matter for this shader
  20. #if ALPHACLIP
  21. color = tex2D( BaseTextureSampler, i.texCoord0 );
  22. clip( color.a - g_AlphaThreshold );
  23. #endif
  24. #if ( COLOR_DEPTH == 1 )
  25. return float4( i.vWorldPos_projPosZ.w / g_flFarPlane, 0.0, 0.0, 1.0 );
  26. #else
  27. return color;
  28. #endif
  29. }