Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Architecture choice for rending a bezier curve (for UI purposes)

  1. #1
    Intern Newbie
    Join Date
    Nov 2011
    Location
    Surrey
    Posts
    31

    Architecture choice for rending a bezier curve (for UI purposes)

    Hi

    I have another architecture question, I'm building a mini vector graphics library so I can draw some nice ui components (such as a curved rectangle panel). I'm currently building the points manually in my code during initialization and then drawing them via a line loop. I have seen in some places that an alternative method is to pass the points and control points to a shader (as they form triangle/s) and to let the shader choose whether to draw the point or not (via some sort of test such as u^2 -v > 0 for fill or =0 for line, for a quadratic bezier). Is there a better choice here? The 1st has more work to do upfront but makes it harder to do things such as anti aliasing (unless there is a good way to incorporate it here) and the 2nd has more work to do but allows so extra logic to anti alias.

    There is the tessalation shader too but I can't see it being any better here than the 1st method (could be wrong here again )

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,008
    Using the implicit form directly in a fragment shader is more accurate, but it's awkward for arbitrary piecewise curves. You typically need additional data to determine which segment(s) need to be considered at any point.

    With the parametric form, a tessellation shader allows most of the work to be moved to the GPU. It also avoids the need to calculate and upload new data if the sample spacing changes. The latter point is more relevant if you need to be able to vary the level of detail dynamically, e.g. for a first-person perspective view where it would vary with distance from the viewpoint.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •