java - Fast partial image bulge effect -


i'm writing small libgdx application may able distort face simulating hits (something similar facesmash), can't find kind of filter should apply, neither info math algorithms achieve bulge effect.

i've started spherefilter on

http://www.jhlabs.com/

but effect not i'm looking for.

i'm aware of

image warping - bulge effect algorithm

and

how warp images in android?

i've achieved 'translate' bulge effect mentioned on first thread, relatively slow, , can't find way create bulges in region, not whole image.

the warp sample on api demos (2nd thread) fast, , changes part of image, not bulge effect, , image processing maths far understanding how modify algorithm change effect.

i can feel i'm in right direction, i'm totally stuck. idea of how of these algorithms modified in order 'local' bulges inside image?

edit

just found thread.-

how can apply distortions uiimage using opengl es?

not android, looks promising. i'll give try opengl shaders , share (hopefully) solution scenario.

answering own question, managed find solution using opengl shaders based on gpuimage framework

the resulting fragment shader looks this.-

#ifdef gl_es     precision mediump float; #endif  varying vec4 v_color; varying vec2 v_texcoords; uniform sampler2d u_texture; uniform float aspectratio; uniform vec2 center; uniform float radius; uniform float scale;  void main()  {       vec2 texturecoordinatetouse = vec2(v_texcoords.x, (v_texcoords.y * aspectratio + center.y - center.y * aspectratio));     float dist = distance(center, texturecoordinatetouse);     texturecoordinatetouse = v_texcoords;     if (dist < radius)     {         texturecoordinatetouse -= center;         float percent = 1.0 - ((radius - dist) / radius) * scale;         percent = percent * percent;         texturecoordinatetouse = texturecoordinatetouse * percent;         texturecoordinatetouse += center;     }     gl_fragcolor = texture2d(u_texture, texturecoordinatetouse); } 

hope find helpful.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -