I'm using Stefan Gustavson's GLSL impl. of Simplex noise and animating it using WebGL. Works just fine on desktop, but on my Android device, both Chrome and Firefox, the animation always halts after a fixed period. There's no error/warning, the scripts and WebGL program continue running. Same thing happens with the classic Perlin noise impl. You can see a demo here: https://wix.github.io/kampos Code is here: https://github.com/wix/kampos/blob/master/index.html Turbulence impl. is here: https://github.com/wix/kampos/blob/master/src/effects/turbulence.js
Asked
Active
Viewed 262 times
0
-
Your shader multiplies `u_time` by `0.0001`. What happens if you move this out of GLSL and into JavaScript? – prideout Nov 08 '19 at 18:17
-
change `precision mediump float;` to `precision highp float;` – gman Nov 08 '19 at 19:58
-
@prideout this simply stretches time by a factor, so the animation speed is reasonable. But will try just for the sake of it (: – ydaniv Nov 09 '19 at 08:28
-
@gman I was positively sure I tried that,
, but apparently not, that did the trick, thanks! Another q, should I hard-code it to highp? Or is there a perf concern to keep it configurable? – ydaniv Nov 09 '19 at 09:19 -
From my experience you pretty much always want `highp`. On desktop precision qualifiers have no effect to begin with and on mobile anything but `highp` makes your life a lot harder across the fragmented device landscape without providing a reasonable performance benefit to justify the trouble. – LJᛃ Nov 09 '19 at 23:59
-
In 2019 you probably want to start with `highp` and worry about perf later. Back in 2011 when WebGL shipped there were lots of phones that didn't support `highp` (it's an optional feature) but in 2019 most phones support highp. For example all iPhones since 2013 support highp. There is a perf difference but at least your code will work. Fixing your code to work in mediump is usually not trivial. – gman Nov 10 '19 at 04:18
-
Thanks guys, @gman, @LJᛃ! If you think this information is valuable, please add an answer and I'll accept. Otherwise please we can probably delete it. – ydaniv Nov 10 '19 at 07:24