After seeing Shirley Wu’s observable for playing with fragment shaders, I really wanted to make my own, sort of like a diary mixing text and fragment shader samples, though I’m still a newbie at shaders. I wanted to show shader samples like the editor in the Book of Shaders.
The only in/out constants in Shirley’s fragment shaders is
varying vec2 vUv;.
I wanted to add
u_time (time in seconds since start) and
u_mouse (pixel mouse pos within the shader) like in the Book of Shaders.
I got it to work here but:
- the timer (for
uniform float _time;) seems to be lagging the page. I read some Generator tutorials but I wasn’t able to create a single timer for the whole page that smoothly runs at 30 or 60fps, returning seconds (10.63242394 secs)
- the strategy for tracking mouse position doesn’t seem great either, since using one of the last 2 shader examples on the page does indeed track the mouse, but it’s really slow.
Any tips on how to improve the timer or mouse tracking?
Thanks a million,