patriciogonzalezvivo / glslCanvas

Simple tool to load GLSL shaders on HTML Canvas using WebGL
http://patriciogonzalezvivo.github.io/glslCanvas/
MIT License
1.97k stars 183 forks source link

fix u_mouse and u_resolution #62

Open edap opened 4 years ago

edap commented 4 years ago

I was having a weird issue with the u_mouse uniform while mapping the mouse to the center of the screen using:

vec2 mouse = (2.0 * u_mouse.xy - u_resolution.xy)/ u_resolution.y;

Then I have noticed that the u_mouse and the u_resolution are passed in different scale. The mouse values where multiplied by this.realToCSSPixels, while the mouse no. I have mutliplied also the the resolution by this.realToCSSPixels, and now u_mouse and u_resolution are under the same scale factor.

After changing the glslCanvas file I have also run the build, that's why some changes are also into the dist folder.