Project

General

Profile

« Previous | Next » 

Revision 353f7580

Added by Leszek Koltunski over 5 years ago

Make Distort truly 3D.

View differences:

src/main/java/org/distorted/library/effect/VertexEffectSwirl.java
70 70
    {
71 71
    addEffect(EffectName.SWIRL,
72 72

  
73
        "vec3 center  = vUniforms[effect+1].yzw; \n"
74
      + "vec3 PS = center-v.xyz; \n"
75
      + "vec4 SO = vUniforms[effect+2]; \n"
76
      + "float d1_circle = degree_region(SO,PS); \n"
77
      + "float d1_bitmap = degree_bitmap(center,PS); \n"
78

  
79
      + "float alpha = vUniforms[effect].x; \n"
80
      + "float sinA = sin(alpha); \n"
81
      + "float cosA = cos(alpha); \n"
73
        "vec3 center = vUniforms[effect+1].yzw;                             \n"
74
      + "vec3 PS = center-v.xyz;                                            \n"
75
      + "vec4 SO = vUniforms[effect+2];                                     \n"
76
      + "float d1_circle = degree_region(SO,PS);                            \n"
77
      + "float d1_object = degree_object(center,PS);                        \n"
78
      + "float alpha = vUniforms[effect].x;                                 \n"
79
      + "float sinA = sin(alpha);                                           \n"
80
      + "float cosA = cos(alpha);                                           \n"
82 81

  
83 82
      + "vec3 PS2 = vec3( PS.x*cosA+PS.y*sinA,-PS.x*sinA+PS.y*cosA, PS.z ); \n" // vector PS rotated by A radians clockwise around center.
84
      + "vec4 SG = (1.0-d1_circle)*SO; \n"                                      // coordinates of the dilated circle P is going to get rotated around
85
      + "float d2 = max(0.0,degree(SG,center,PS2)); \n"                         // make it a max(0,deg) because otherwise when center=left edge of the
86
                                                                                // bitmap some points end up with d2<0 and they disappear off view.
87
      + "v.xy += min(d1_circle,d1_bitmap)*(PS.xy - PS2.xy/(1.0-d2)); \n"        // if d2=1 (i.e P=center) we should have P unchanged. How to do it?
83
      + "vec4 SG = (1.0-d1_circle)*SO;                                      \n" // coordinates of the dilated circle P is going to get rotated around
84
      + "float d2 = max(0.0,degree(SG,center,PS2));                         \n" // make it a max(0,deg) because otherwise when center=left edge of the
85
                                                                                // object some points end up with d2<0 and they disappear off view.
86
      + "v.xy += min(d1_circle,d1_object)*(PS.xy - PS2.xy/(1.0-d2));        \n" // if d2=1 (i.e P=center) we should have P unchanged. How to do it?
88 87
      );
89 88
    }
90 89

  

Also available in: Unified diff