Project

General

Profile

« Previous | Next » 

Revision 4aa38649

Added by Leszek Koltunski over 5 years ago

Redefine the Vertex Region from (x,y,r,unused) to (x,y,z,r). This takes into account the 'Z', which makes it possible to warp only one side of a 3D Mesh like Sphere.

Also corresponding changes in applications.

View differences:

src/main/java/org/distorted/library/effect/VertexEffectSwirl.java
66 66
    {
67 67
    addEffect(EffectName.SWIRL,
68 68

  
69
        "vec2 center  = vUniforms[effect+1].yz; \n"
70
      + "vec2 PS = center-v.xy; \n"
69
        "vec3 center  = vUniforms[effect+1].yzw; \n"
70
      + "vec3 PS = center-v.xyz; \n"
71 71
      + "vec4 SO = vUniforms[effect+2]; \n"
72 72
      + "float d1_circle = degree_region(SO,PS); \n"
73 73
      + "float d1_bitmap = degree_bitmap(center,PS); \n"
......
76 76
      + "float sinA = sin(alpha); \n"
77 77
      + "float cosA = cos(alpha); \n"
78 78

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

  
......
112 112
    super(EffectName.SWIRL);
113 113
    mSwirl  = swirl;
114 114
    mCenter = center;
115
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
115
    mRegion = new Static4D(0,0,0, Float.MAX_VALUE);
116 116
    }
117 117
  }
118 118

  

Also available in: Unified diff