Nope... it seems that this issue still persists. I have changed my code to use the above line. However changing resolutions still give me an offset problem.
I used the following shader code to test out my code at 800x600 and 1600x1200. Only the 800x600 code gets the mouse position ALMOST correct, while 1600x1200 is way off.
Reference:
shadertoy.com/view/lssGzH
HIGHLIGHT MOUSE POSITION SHADER CODE
precision mediump float;
varying mediump vec2 vTex;
uniform lowp sampler2D samplerFront;
uniform mediump float seconds;
uniform mediump float pixelWidth;
uniform mediump float pixelHeight;
uniform mediump float layerScale;
uniform float mseX;
uniform float mseY;
uniform float distancebetweencircles;
uniform float zoomfactor;
mediump vec2 iResolution = vec2(1./pixelWidth, 1./pixelHeight);
mediump vec2 iMouse = vec2(mseX, mseY);
float smoothbump(float center, float width, float x) {
float w2 = width/2.0;
float cp = center+w2;
float cm = center-w2;
float c = smoothstep(cm, center, x) * (1.0-smoothstep(center, cp, x));
return c;
}
void main(void) {
vec2 uv = (gl_FragCoord.xy / iResolution.xy);
vec2 m = iMouse / iResolution.xy;
float m1 = smoothbump(m.x,0.05,uv.x) *
smoothbump(m.y,0.05,uv.y);
gl_FragColor = vec4(m1,0,0,1.0);
}
Did I miss something out?
Or is it a bug? Or maybe a missing feature?