How to draw a thick line in metal ?

Is there any high efficiency way to do these? I mean, dont't change the structure of the line vertex.

Why doesn't Apple offer line width control?

It's too inconvenient.

Answered by Graphics and Games Engineer in 262788022

Metal, being a low-level API, only offers what GPUs are directly capable of. OpenGL offers wide lines by emulating them with quad in a software layer. Such software emulation is beyond the scope of what Metal typically provides.

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

Metal, being a low-level API, only offers what GPUs are directly capable of. OpenGL offers wide lines by emulating them with quad in a software layer. Such software emulation is beyond the scope of what Metal typically provides.

”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.

How to draw a thick line in metal ?
 
 
Q