Advertisement
Mux213

Altered aim shader

Sep 16th, 2020
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. shader_type spatial;
  2. render_mode cull_disabled, unshaded;
  3.  
  4. uniform vec3 velocity = vec3(0.0, 10.0, -15.0);
  5. uniform float gravity = 9.8;
  6.  
  7. uniform float slices = 20.0;
  8. uniform float scale = 5.0;
  9. uniform float duration = 2.0;
  10.  
  11. void vertex() {
  12. // we'll be calculating our own vertex
  13. VERTEX.x = 0.0;
  14. VERTEX.y = VERTEX.z;
  15. VERTEX.z = 0.0;
  16.  
  17. // use UV.x to determine time
  18. float t = UV.x * duration;
  19.  
  20. // apply our velocity
  21. VERTEX += velocity * t;
  22.  
  23. // apply our gravity
  24. VERTEX.y -= 0.5 * gravity * t * t;
  25. }
  26.  
  27. void fragment() {
  28. // discard our fragment at intervals
  29. if (mod(UV.x * slices - TIME * scale, 1.0) > 0.5) {
  30. discard;
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement