You’re now watching this thread and will receive emails when there’s activity. Click again to stop watching or visit your profile/homepage to manage your watched threads.
You’ve stopped watching this thread and will no longer receive emails when there’s activity. Click again to start watching.
How can I create a dashed line using a Metal shader? I'm thinking something similar to the CoreGraphics "lineDash" property.
I think the easiest way would be to use a 1DTexture with an alternating white and transparent pattern. You could create a sampler with the sAddressMode of the MTLSamplerStateDescriptor set to MTLSamplerAddressModeRepeat mode to (or set the address mode of a sampler in your fragment shader). You would need to calculate texture coordinates in the vertex shader based upon the distance between the two vertices of the line so that the pattern isn't "stretched" for longer lines.