Ah, the number thing has been biting me A LOT. I wonder if there’s a #pragma or something to suppress it.
I’ll check the APK when I’m home. The playground version looks really nice! All the little tuning factors really bring some life to it.
If I had to guess, I’d say it’s something like this:
(1 - After CoronaTotalTime gets large enough, your numbers are overflowing the representable value of a mediump. If these are IEEE-style floats, they may start spacing differently once they pass 1023: 1024, 1026, …, then later by 4, 8, etc. until they 2^14 and then becoming… something. Modded by 1024? Junk? (Junk would probably be fairly obvious.) I’m not sure.
If you do have a fancier device on hand, you could change that earlier snippet to
#ifdef GL\_ES #ifdef GL\_FRAGMENT\_PRECISION\_HIGH precision highp float; #else precision mediump float; #endif #endif
and see if the issue disappears.
(2 - Along those same lines, if your scale factors are close to, but not identical with one another, some of them may overflow while others don’t, and give you weird boundary effects in your graphics. This happens in all my noise shaders. (And is behind certain of Corona’s built-in effects’ requirements for high precision, I assume.)
I’m not sure there is a general solution to this problem.
However!
In this case you may actually be in luck, since the trigonometric functions are all periodic. So now that you’ve worked it all out on the fragment side, you could move the angle computations over into the vertex kernel. This already gives you back high precision availability. But more relevant to the problem at hand, you could sanitize the angles by modding them by some multiple of 2 * pi and passing those, through varyings, on to the fragment side. (If you cross a 2 * pi -> 0 branch you’ll need to correct for that, of course.)