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.

42 lines
1.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #include "common_vs_fxc.h"
  3. float Sine( float min, float max, float t )
  4. {
  5. return ( sin( t ) * 0.5f + 0.5f ) * ( max - min ) + min;
  6. }
  7. float3 QuadraticBezier( float3 A, float3 B, float3 C, float t )
  8. {
  9. return lerp( lerp( A, B, t ), lerp( B, C, t ), t );
  10. }
  11. float3 CubicBezier( float3 A, float3 B, float3 C, float3 D, float t )
  12. {
  13. return QuadraticBezier( lerp( A, B, t ), lerp( B, C, t ), lerp( C, D, t ), t );
  14. }
  15. void WorldSpaceVertexProcess( in float time, in float3 modelOrigin, inout float3 worldPos, inout float3 worldNormal, inout float3 worldTangentS, inout float3 worldTangentT )
  16. {
  17. float myTime = time;
  18. myTime = saturate( 1.0f - myTime );
  19. myTime *= myTime;
  20. myTime *= myTime;
  21. myTime *= myTime;
  22. // worldPos.z += 72.0f * myTime;
  23. // end
  24. float3 A = float3( 0.0f, 0.0f, 1.0f );
  25. float3 B = float3( 1.0f, 1.0f, 1.0f );
  26. float3 C = float3( 0.0f, 0.0f, 1.0f );
  27. float3 D = float3( 0.0f, 0.0f, 1.0f );
  28. // start
  29. // float3 modelOrigin = float3( 70.0f, -14.0f, 0.0f );
  30. float t = worldPos.z * ( 1.0f / ( 72.0f ) ); // about 72 inches tall
  31. t = saturate( t );
  32. float3 worldPosDelta = ( worldPos - modelOrigin ) * CubicBezier( A, B, C, D, t );
  33. worldPosDelta.z += Sine( 0.0f, 10.0, worldPos.z );
  34. worldPos = lerp( worldPos, worldPosDelta + modelOrigin, myTime );
  35. }