Jump to content
  • Advertisement
Sign in to follow this  
ryoshirou

OpenGL Polyline stroke animation

This topic is 611 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I am drawing a bunch of polylines with OpenGL. For every line segment I pass 4 vertices to a vertex shader which expands them pairwise in two different directions along the line normal according to the stroke thickness given as an uniform (picture below). I want to animate different colors passing through the polylines as if the polylines were progress bars (picture below). What would be the most efficient way to do this? 
 

[attachment=33970:2.png][attachment=33969:animate-stroke.gif]

 

Share this post


Link to post
Share on other sites
Advertisement

You can add one texture coordinate to each vertex (same coordinate for pair at Pn), with value increasing along entire curve.

Then you pass current time (reminder from dividing current time by some value, progress %% maybe, or curve length) as uniform to fragment shader. Fragment shader then can map current fragment's position on curve (interpolated between verts of segment), shifted by current time, into small 1D texture with desired colormap. Texture will define colors of stroke and gap between strokes. And texture might describe either single stroke with gap, repeated along curve, or even group of strokes with different color.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!