How to draw a thick line in metal ?

Apple Recommended

Replies

Furthermore is there a plan to add these function to Metal?

”Typically you say?“ In that case I think this should be one of the exceptions. The thing is, SceneKit supports the line primitive and Metal supports the line and the line strip primitives, yet at 1px wide on a retina display it is barely visible. Without a means to set the width, their use is very limited. Since Metal does not include support for a geometry shader, the way to “emulate them with quad in a software layer” for us would be to ditch the line primitive and use trianglestrips or polygon primitive instead, which in turn adds cpu and memory overhead and “renders” the line primitive pointless for anything except 1px wide lines. So adding support for lines should include an option to set line thickness either directly through a property or indirectly through a geometry shader.

Is there any application at all for single pixel lines in real world applications? Why waste any silicon at all on this? Without line thickness to do something like drawing a wireframe over my objects or using the old stencil trick for outlining objects, I have to maintain 2 versions of my geometry, which is inefficient and cumbersome.

+1

This is very frustrating and seems like the sort of basic functionality one would expect from any robust 3D API.

Hardware does not support drawing thick lines and so this functionality has no business in being in a GPU API. Not to mention that there are a lot of choices that have to be done (how to handle line caps, how to handle aliasing etc.). I am surprised that some people think this is basic functionality, it clearly is not. Drawing lines either involves non-trivial shaders that interpolate SDFs or constructing geometry on the fly. This could be a task for an auxiliary library, but definitely not for the core API.