Figured I’d throw this out there: does anyone know the fastest way to *conservatively* rasterize lines on GPU? I’ve tried: (1) drawing instanced thin quads; (2) drawing thin quads w/o instancing (~15% faster); (3) glLineWidth(2.0) (fastest on NVIDIA, but deprecated)
-
Show this thread
-
Other things I can think of but haven’t tried: (4) quads in geometry shader (5) quads in tess shader (6) two adjacent lines (7) conservative rasterization of line prims (NVIDIA only) (8) ditto w/ sliver triangles instead (NVIDIA+Intel) (9) (╯°□°)╯︵ ┻━┻ compute shader time
2 replies 0 retweets 8 likesShow this thread -
Replying to @pcwalton
Unlikely to be the best option but, for completeness: non-conservative rasterization + pixel dilation (e.g. in compute shader).
1 reply 0 retweets 0 likes -
Replying to @ssylvan
Do you mean doing everything in compute shader or rasterizing with line primitives and expanding in compute? The latter doesn’t work because the line could be too short to hit the diamond, unless you’re extending the lines in vertex shading somehow
1 reply 0 retweets 0 likes -
Replying to @pcwalton
I meant the latter. Not sure I understand the diamond comment. You saying there are cases where rasterizer will "hit" >1px away from a pixel that was actually touched by the line?
1 reply 0 retweets 0 likes -
Replying to @ssylvan
Yeah. Consider a tiny line whose endpoints are infinitesimally close to a pixel corner. Never touches the pixel diamond so nothing will be lit.
1 reply 0 retweets 0 likes -
Replying to @pcwalton
Oh I see.. Yeah if the line is so short it doesn't "exit" through one of the neighboring diamonds you'd have to extend it or something.
1 reply 0 retweets 1 like -
Replying to @ssylvan
I feel like at that point you might as well rasterize all lines as axis aligned lines along their major axis. In each fragment shader invocation calculate the 2 minor-axis positions and use image load/store or whatever to write to the appropriate spot.
1 reply 0 retweets 0 likes
You could even abuse helper threads and fragment derivatives to calculate the two positions simultaneously. But ugh, what a hack!
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.