How to make a thin line material for bounding volumes?

Several objects in UE5 like the post-processing volume and trigger boxes have bounding box visualisation in the editor.

How can such a material be created in the material graph? Or how can this same material be applied to user created primitives?

This only has to work for boxes. Doesn’t have to be smooth or antialiased. Thickness should be constant regardless of viewing distance and angle just like the example.

Attempting this in the pixel shader using UVs works somewhat but scaling reduces the line thickness and ruins the effect.

The closest way that I know is to use a post-process material and then enable “Set Render Custom Depth” on the specific mesh you would like to highlight. Attached a video below that goes over how to make the material and apply it via Blueprints

Easiest would be something like: add a box/volume component to your actor, check Hidden In Game, and update the box size in PostEditChangeProperty().

found this there. What are the methods avaiable to draw lines in unreal engine? - #32 by Supremative

this material could help.

the convoluted way is to create the quad wireframe mesh manually using a procedural mesh. there is no line list render mode available, tho. you’d have to build it out of polygons. and those would not scale accordingly to camera depth.