anim_sp.shader 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. shader_type particles;
  2. render_mode keep_data,disable_velocity;
  3. uniform float iTime;
  4. vec3 mlpos(float index, inout float angx, inout float angy){
  5. float px=index/31.;
  6. float pi=3.1415926;
  7. angx=pi/2.+atan(2.*sin(2.*px*pi),2.*cos(2.*px*pi));
  8. angx=mod(angx,2.*pi);
  9. float time=mod(10.*iTime,31.);
  10. float tt=smoothstep(index-8.,index,time);
  11. tt+=smoothstep(index+31.-8.,index+31.,time);
  12. time=mod(10.*iTime+4.,31.);
  13. float tt2=smoothstep(index-8.,index,time)*smoothstep(index+8.,index,time);
  14. tt2+=smoothstep(index+31.-8.,index+31.,time)+smoothstep(index+8.,index,time)*smoothstep(index-31.+8.,index-31.,time);
  15. angy=pi*tt;
  16. angy=-pi/2.+mod(angy,2.*pi);
  17. return .5*vec3(2.*sin(2.*px*pi),0.*tt2,2.*cos(2.*px*pi));
  18. }
  19. void vertex() {
  20. float pi = 3.14159;
  21. float degree_to_rad = pi / 180.0;
  22. //if(RESTART)
  23. if (CUSTOM.w<100.) {
  24. CUSTOM=vec4(vec3(0),110.);
  25. VELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY, 0.0)).xyz;
  26. //TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;
  27. TRANSFORM = EMISSION_TRANSFORM;
  28. TRANSFORM[3].xyz=mlpos(float(INDEX),CUSTOM.x,CUSTOM.y);
  29. TRANSFORM[0].xyz *= 1.;
  30. TRANSFORM[1].xyz *= 1.;
  31. TRANSFORM[2].xyz *= 1.;
  32. TRANSFORM = TRANSFORM * mat4(vec4(cos(CUSTOM.x), 0.0, -sin(CUSTOM.x), 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(sin(CUSTOM.x), 0.0, cos(CUSTOM.x), 0.0), vec4(0.0, 0.0, 0.0, 1.0));
  33. TRANSFORM = TRANSFORM * mat4(vec4(cos(CUSTOM.y), 0.0, -sin(CUSTOM.y), 0.0).zxyw,
  34. vec4(0.0, 1.0, 0.0, 0.0).zxyw,
  35. vec4(sin(CUSTOM.y), 0.0, cos(CUSTOM.y), 0.0).zxyw,
  36. vec4(0.0, 0.0, 0.0, 1.0).zxyw
  37. );
  38. } else {
  39. TRANSFORM = EMISSION_TRANSFORM;
  40. TRANSFORM[3].xyz=mlpos(float(INDEX),CUSTOM.x,CUSTOM.y);
  41. TRANSFORM = TRANSFORM * mat4(vec4(cos(CUSTOM.x), 0.0, -sin(CUSTOM.x), 0.0),
  42. vec4(0.0, 1.0, 0.0, 0.0),
  43. vec4(sin(CUSTOM.x), 0.0, cos(CUSTOM.x),
  44. 0.0), vec4(0.0, 0.0, 0.0, 1.0)
  45. );
  46. TRANSFORM = TRANSFORM * mat4(vec4(cos(CUSTOM.y), 0.0, -sin(CUSTOM.y), 0.0).zxyw,
  47. vec4(0.0, 1.0, 0.0, 0.0).zxyw,
  48. vec4(sin(CUSTOM.y), 0.0, cos(CUSTOM.y), 0.0).zxyw,
  49. vec4(0.0, 0.0, 0.0, 1.0).zxyw
  50. );
  51. }
  52. TRANSFORM[0].xyz = normalize(TRANSFORM[0].xyz);
  53. TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz);
  54. TRANSFORM[2].xyz = normalize(TRANSFORM[2].xyz);
  55. }