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.

64 lines
1.8 KiB

  1. #include "common_vs_fxc.h"
  2. const float4 g_vTextureSizeInfo : register( SHADER_SPECIFIC_CONST_0 );
  3. const float4 g_mBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_1 );
  4. //SHADER_SPECIFIC_CONST_2
  5. #define TEXEL_XINCR (g_vTextureSizeInfo.x)
  6. #define TEXEL_YINCR (g_vTextureSizeInfo.y)
  7. #define U_TO_PIXEL_COORD_SCALE (g_vTextureSizeInfo.z)
  8. #define V_TO_PIXEL_COORD_SCALE (g_vTextureSizeInfo.w)
  9. struct VS_INPUT
  10. {
  11. float4 vPos : POSITION;
  12. float2 vTexCoord0 : TEXCOORD0;
  13. };
  14. struct VS_OUTPUT
  15. {
  16. float4 projPos : POSITION;
  17. //#if defined( _X360 )
  18. // float2 baseTexCoord : TEXCOORD0;
  19. //#else
  20. float2 baseTexCoord00 : TEXCOORD0;
  21. float2 baseTexCoord01 : TEXCOORD1;
  22. float2 baseTexCoord10 : TEXCOORD2;
  23. float2 baseTexCoord11 : TEXCOORD3;
  24. float2 baseTexCoord_In_Pixels: TEXCOORD4;
  25. //#endif
  26. };
  27. VS_OUTPUT main( const VS_INPUT v )
  28. {
  29. VS_OUTPUT o = ( VS_OUTPUT )0;
  30. o.projPos = mul( v.vPos, cModelViewProj );
  31. float4 vTexCoordInput = { v.vTexCoord0.x, v.vTexCoord0.y, 0.0f, 1.0f };
  32. float2 vTexCoord;
  33. vTexCoord.x = dot( vTexCoordInput.xyzw, g_mBaseTexCoordTransform[0] );
  34. vTexCoord.y = dot( vTexCoordInput.xyzw, g_mBaseTexCoordTransform[1] );
  35. //#if defined( _X360 )
  36. // o.baseTexCoord.xy = vTexCoord.xy;
  37. //#else
  38. // Compute quantities needed for pixel shader texture lerping
  39. o.baseTexCoord00.x = vTexCoord.x - TEXEL_XINCR;
  40. o.baseTexCoord00.y = vTexCoord.y - TEXEL_YINCR;
  41. o.baseTexCoord10.x = vTexCoord.x + TEXEL_XINCR;
  42. o.baseTexCoord10.y = vTexCoord.y - TEXEL_YINCR;
  43. o.baseTexCoord01.x = vTexCoord.x - TEXEL_XINCR;
  44. o.baseTexCoord01.y = vTexCoord.y + TEXEL_YINCR;
  45. o.baseTexCoord11.x = vTexCoord.x + TEXEL_XINCR;
  46. o.baseTexCoord11.y = vTexCoord.y + TEXEL_YINCR;
  47. o.baseTexCoord_In_Pixels.xy = o.baseTexCoord00.xy;
  48. o.baseTexCoord_In_Pixels.x *= U_TO_PIXEL_COORD_SCALE;
  49. o.baseTexCoord_In_Pixels.y *= V_TO_PIXEL_COORD_SCALE;
  50. //#endif
  51. return o;
  52. }