Is it possible to draw line thickness in a fragment shader?

后端 未结 4 1560
感情败类
感情败类 2020-12-08 01:28

Is it possible for me to add line thickness in the fragment shader considering that I draw the line with GL_LINES? Most of the examples I saw seem to access only the texels

4条回答
  •  臣服心动
    2020-12-08 01:43

    No, it is not possible in the fragment shader using only GL_LINES. This is because GL restricts you to draw only on the geometry you submit to the rasterizer, so you need to use geometry that encompasses the jagged original line plus any smoothing vertices. E.g., you can use a geometry shader to expand your line to a quad around the ideal line (or, actually two triangles) which can pose as a thick line.

    In general, if you generate bigger geometry (including a full screen quad), you can use the fragment shader to draw smooth lines.

    Here's a nice discussion on that subject (with code samples).

提交回复
热议问题