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.

65 lines
2.1 KiB

  1. #include "common_vs_fxc.h"
  2. const float4x3 cModelView : register(SHADER_SPECIFIC_CONST_0);
  3. const float4x4 cProj : register(SHADER_SPECIFIC_CONST_3);
  4. // derivative of catmull rom spline courtesy of calc
  5. float4 DCatmullRomSpline ( float4 a, float4 b, float4 c, float4 d, float t )
  6. {
  7. return 0.5 *( c - a + t * ( 2 * a - 5 * b + 4 * c - d + t * (3 * b - a - 3 * c + d ) )
  8. + t * ( 2 * a - 5 * b + 4 * c - d + 2 * ( t * ( 3 * b - a - 3 * c + d ) ) ) );
  9. }
  10. float3 DCatmullRomSpline3 ( float3 a, float3 b, float3 c, float3 d, float t )
  11. {
  12. return 0.5 *( c - a + t * ( 2 * a - 5 * b + 4 * c - d + t * (3 * b - a - 3 * c + d ) )
  13. + t * ( 2 * a - 5 * b + 4 * c - d + 2 * ( t * ( 3 * b - a - 3 * c + d ) ) ) );
  14. }
  15. float4 CatmullRomSpline( float4 a, float4 b, float4 c, float4 d, float t )
  16. {
  17. return b + 0.5 * t * ( c - a + t * ( 2 * a - 5 * b + 4 * c - d + t * ( -a + 3 * b -3 * c + d ) ) );
  18. }
  19. struct VS_INPUT
  20. {
  21. // This is all of the stuff that we ever use.
  22. float4 vTint : COLOR;
  23. float4 vParms : POSITION; // T V side_id
  24. float4 vSplinePt0 : TEXCOORD0; // x y z rad
  25. float4 vSplinePt1 : TEXCOORD1; // x y z rad
  26. float4 vSplinePt2 : TEXCOORD2; // x y z rad
  27. float4 vSplinePt3 : TEXCOORD3; // x y z rad
  28. };
  29. struct VS_OUTPUT
  30. {
  31. float4 projPos : POSITION;
  32. float2 texCoord0 : TEXCOORD0;
  33. float2 texCoord1 : TEXCOORD1;
  34. float4 argbcolor : COLOR;
  35. float4 blendfactor0 : TEXCOORD2;
  36. float4 vScreenPos : TEXCOORD7;
  37. };
  38. VS_OUTPUT main( const VS_INPUT v )
  39. {
  40. VS_OUTPUT o;
  41. float4 posrad =
  42. CatmullRomSpline( v.vSplinePt0, v.vSplinePt1, v.vSplinePt2, v.vSplinePt3, v.vParms.x );
  43. float3 v2p = ( posrad.xyz - cEyePos );
  44. float3 tangent=DCatmullRomSpline3( v.vSplinePt0, v.vSplinePt1, v.vSplinePt2, v.vSplinePt3, v.vParms.x );
  45. float3 ofs = normalize( cross(v2p, normalize( tangent) ) );
  46. posrad.xyz += ofs * ( posrad.w * ( v.vParms.z - .5 ) );
  47. o.projPos = mul( float4(posrad.xyz, 1.0f), cViewProj );
  48. o.texCoord0 = o.texCoord1 = float2( (1-v.vParms.z), v.vParms.y);
  49. o.argbcolor = v.vTint;
  50. o.blendfactor0 = float4(0,0,0,0);
  51. o.vScreenPos = float4(0,0,0,0);
  52. return o;
  53. }