🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Venting: dashed lines and curves in nanoVG

Started by
0 comments, last by JB3DG 2 years, 12 months ago

So a while back I wrote my own dx11 shader based 2D vector graphics library as a GDI+ replacement. Can’t share it as its proprietary but sharing this tip for those who use nanoVG and don’t want to go through all the trouble of doing their own lib.

NanoVG renders arcs as Bézier curves, and when dashed it splits up each dash into its own draw call which is highly inefficient. If it stuck to a single draw call but placed the distance of each point in the curve from the starting point into a texture coordinate, and the dash pattern in a structured buffer or 1D texture, the pixel shader would automatically interpolate the length between points and a simple fmod could be used to determine whether you draw the pixel or discard it.

This topic is closed to new replies.

Advertisement