markusfisch / ShaderEditor

Android app to create GLSL shaders and use them as live wallpaper
https://play.google.com/store/apps/details?id=de.markusfisch.android.shadereditor
MIT License
923 stars 137 forks source link

Rendering only one frame #58

Closed fekga closed 5 years ago

fekga commented 7 years ago

I created some shaders with heavy raymarching computations which are rendering with less than 10 fps. I then tried to render only one frame but I had to hack it in GLSL like this:

//main...
if (time < 1./60.)
    render();
else
    renderBackbuffer();

I understand that it can't be used as wallpaper with rendering speeds as low as this, but it would be a nice feature to create a still image. Also saving the rendered frame as an image would be a nice thing (instead of screenshotting and cropping)

markusfisch commented 7 years ago

Yes, I see. Maybe I should add a special action menu item for that. Put it on the list.

fekga commented 6 years ago

Adding the actual frame's index as a uniform integer can work too like Shadertoy does it.

Robert-K commented 5 years ago

@fekga I would really like to see that feature. Should be rather easy to implement and would enable stuff like this (https://blog.demofox.org/2016/02/29/fast-voronoi-diagrams-and-distance-dield-textures-on-the-gpu-with-the-jump-flooding-algorithm/) (Jump Flood Algorithm requires several iterations and the current index). I implemented this shader anyway, but it is unreliable, as it depends on a constant framerate.

Robert-K commented 5 years ago

@markusfisch It just appeared to me that you recently added this exact feature 😄 Thanks! I really love your project; keep up the great work! I suggest closing this issue.

markusfisch commented 5 years ago

@fekga @Robert-K Yes, it's in 2.15.0 now and I've got to say I'm a bit ashamed I kept this issue for such a long time since it was a really small thing to add 🙈

The new frame counting uniform is int frame and it starts with 0.

Please note, a signed integer in medium precision has only a guaranteed minimum range of 2^15. Rendering at 60 frames per second, the counter may wrap after 32768 / 60 = ~546 seconds or ~9 minutes. I couldn't use an unsigned integer (2^16) because many GLSL ES 2 doesn't support uint unfortunately.