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.

63 lines
1.5 KiB

  1. //========= Copyright � 1996-2006, Valve Corporation, All rights reserved. ============//
  2. // STATIC: "STAGE" "0..2"
  3. // Includes
  4. #include "common_vs_fxc.h"
  5. // Globals
  6. //const float g_flTime : register( SHADER_SPECIFIC_CONST_0 );
  7. const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_1 );
  8. const float2 g_vConst3 : register( SHADER_SPECIFIC_CONST_3 );
  9. #define g_flPortalOpenAmount g_vConst3.x
  10. #define g_flPortalStaticAmount g_vConst3.y
  11. // Structs
  12. struct VS_INPUT
  13. {
  14. float4 vPos : POSITION; // Position
  15. float4 vTexCoord0 : TEXCOORD0; // Base texture coordinates
  16. };
  17. struct VS_OUTPUT
  18. {
  19. float4 vProjPosition : POSITION; // Projection-space position
  20. float2 vUv0 : TEXCOORD0;
  21. float2 vUv1 : TEXCOORD1;
  22. #ifndef _X360
  23. float fog : FOG;
  24. #endif
  25. };
  26. // Main
  27. VS_OUTPUT main( const VS_INPUT i )
  28. {
  29. float kFlPortalOuterBorder = 0.075f; // Must match PS!
  30. VS_OUTPUT o;
  31. // Transform the position
  32. o.vProjPosition.xyzw = mul( i.vPos, cModelViewProj );
  33. // Portal open time
  34. float flPortalOpenAmount = saturate( g_flPortalOpenAmount + 0.001f ); // 0.001f to avoid divide by zero
  35. // Texture coordinates
  36. float2 vBaseUv;
  37. vBaseUv.x = dot( i.vTexCoord0.xy, cBaseTexCoordTransform[0] );
  38. vBaseUv.y = dot( i.vTexCoord0.xy, cBaseTexCoordTransform[1] );
  39. o.vUv0.xy = ( ( vBaseUv.xy - 0.5f ) / ( flPortalOpenAmount * flPortalOpenAmount ) ) + 0.5f;
  40. o.vUv1.xy = o.vUv0.xy;
  41. // Fog
  42. #ifndef _X360
  43. {
  44. float3 vWorldPos = mul( i.vPos, cModel[0] );
  45. o.fog = CalcFog( vWorldPos.xyz, o.vProjPosition, FOGTYPE_RANGE );
  46. }
  47. #endif
  48. return o;
  49. }