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/VertexEffectDistort.java
112 112
    {
113 113
    addEffect(EffectName.DISTORT,
114 114

  
115
        "vec2 center = vUniforms[effect+1].yz; \n"
116
      + "vec2 ps = center-v.xy; \n"
115
        "vec3 center = vUniforms[effect+1].yzw; \n"
116
      + "vec3 ps = center-v.xyz; \n"
117 117
      + "vec3 force = vUniforms[effect].xyz; \n"
118 118
      + "float d = degree(vUniforms[effect+2],center,ps); \n"
119
      + "float denom = dot(ps+(1.0-d)*force.xy,ps); \n"
119
      + "float denom = dot(ps+(1.0-d)*force,ps); \n"
120 120
      + "float one_over_denom = 1.0/(denom-0.001*(sign(denom)-1.0)); \n"          // = denom==0 ? 1000:1/denom;
121 121

  
122 122
       //v.z += force.z*d;                                                        // cone
......
129 129
      + "float b = -(12.0*force.z*d*(1.0-d)*(1.0-d)*(1.0-d))*one_over_denom; \n"  //
130 130

  
131 131
      + "v.xy += d*force.xy; \n"
132
      + "n.xy += n.z*b*ps;"
132
      + "n.xy += n.z*b*ps.xy;"
133 133
      );
134 134
    }
135 135

  
......
161 161
    super(EffectName.DISTORT);
162 162
    mVector = vector;
163 163
    mCenter = center;
164
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
164
    mRegion = new Static4D(0,0,0, Float.MAX_VALUE);
165 165
    }
166 166
  }
167 167

  

Also available in: Unified diff