patriciogonzalezvivo / glslViewer

Console-based GLSL Sandbox for 2D/3D shaders
BSD 3-Clause "New" or "Revised" License
4.62k stars 350 forks source link

Loops with glslViewer #309

Open marioecg opened 1 year ago

marioecg commented 1 year ago

I love making sketches that loop, and that's a reason why I also like other creative tools like canvas-sketch and fragment. They help you set a duration for the sketch and provide a playhead variable that goes from 0 to 1 in its time span, so then you can use that value and multiply it by TWO_PI to make a complete phase of sine and cosine.

Typically inside the shader I could make something like:

float duration = 10.0;
float wrappedTime = mod(u_time, duration);
float playhead = (wrappedTime / duration) * TWO_PI;

// and then use it, for instance
float pulse = cos(playhead) * 0.5 + 0.5; 

Is there a way in glslViewer to create and export loops at a specific duration? I'm guessing that the defined duration should match with the command to export a sketch to mp4? I'll appreciate any insight 🙂