Triangulation of a polygon in HLSL

Started by
2 comments, last by JB3DG 5 years, 3 months ago

Hi guys

So back in the day, GDI+ had the option of filling a polygon shape where the polygon points were specified in a sequential order, rather than in triangle index order.

I am writing my own 2D rendering library using DX11, and I am mimicking the GDI+ function signature mostly. So now my question is, has anyone ever tried to triangulate a GDI+ polygon in an HLSL shader?

Thanks

JB

Advertisement

Look here. This link explains an algorithm in OpenGL, but the principle is exactly the same in DX11. It uses the Even-Odd Rule. I find the Non-Zero Winding Rule to be more intuitive (visually, not for implementation). This is the wikipedia link and in the final comment in this thread you can find some more details on how to implement it.

edit: to be clear: this technique does not triangulate the polygon, but it gives a pixel-perfect result, without any of the numerical issues you'd have with an actual triangulation.

Thanks. Now the next challenge is to handle complex path rendering. Eg I need to be able to connect 2 vertical lines with an arc above and below and fill it. Any ideas on how to do that?

This topic is closed to new replies.

Advertisement