Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've managed to fix this issue. The problem is in Mali gpu. Mali doesn't support high precision float calculations in fragment shader. When distance from center to point was near zero - r variable became zero.</p> <p>So I've added constant coefficient to my calculations and this did the trick. </p> <p>Here is working fragment shader:</p> <pre><code>precision mediump float; varying lowp vec4 v_color; varying vec2 v_texCoords; uniform sampler2D u_texture; const float PI = 3.14159; const float koef = 10.0; void main() { vec2 uv; vec2 m = vec2(0.622 , 0.4985); // lens center point, note that in live wallpaper center of texture is (0.5,0.5) float lensSize = 0.045; //radius of lens float lensCut = 0.0342; //height of cut float cuttop = m.y + lensCut; float cutbottom = m.y - lensCut; float cutleft = m.x-lensSize; float cutright = m.x+lensSize; //don't transform pixels, that aren't in lens area if ( v_texCoords.y &gt;= cuttop) { uv = v_texCoords; } else if (v_texCoords.y &lt;= cutbottom) { uv = v_texCoords; } else if (v_texCoords.x &lt;= cutleft) { uv = v_texCoords; } else if (v_texCoords.x &gt;= cutright) { uv = v_texCoords; } else { vec2 p = v_texCoords*koef; //current point vec2 d = p - m*koef; //vector differnce between current point and center point float r = distance(m*koef,p); // distance of pixel from center if (r/koef &gt;= lensSize) { uv = v_texCoords; } else { uv =m + normalize(d) * asin(r) / (PI*0.37*koef); } } gl_FragColor = texture2D(u_texture, uv); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload