Counter Strike : Global Offensive Source Code
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.

41 lines
1.2 KiB

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