I want to draw thin lines

Hi All,

I’m looking for a way to create simple box like geometry with just colored lines.
Like how the editor shows collision boxes.

I don’t want to model them with thin tubes as I need to be able to scale them non-uniformly.
They are going to be added as components to blueprints for the GUI system I am building.

Someone mentioned a particle effect but that sounds a little fiddly to me. Is there another way?

Cheers

You can set “wireframe” in material properties to render it as wireframe.
Or you can get picture of UVs for this objects from max/maya/etc and use them as opacity mask in some translucent material

Yes but I think the wireframe rendering does tri’s right? So a box would get a diagonal across each face, which I don’t want.
Texture map also has the problem that if I scale the box non uniformly then the lines will not be of equal thickness.
EDIT: I suppose I could build the box with ‘little sticks’ at creation time when I know what measurements the box will have. I was hoping for something easier/faster since I will be doing loads of these but maybe thats would be the best way.

Did you tried to use outlines? Is this good solution for you?

or maybe this would be helpful

Hi Redbox and thanks for your persistence! :slight_smile: It made me try a little harder and actually come up with a solution.
I think. I haven’t tried to make the really thin lines but I think it should work. My main concern was to make it work with non-uniform scaling.
Noughty me I should be doing my taxes today and not play with shaders.

All these objects have the same shader with no parameter changes. The lines stay with the same visual thickness.
Works with meshes and static mesh components.
scaled_lines.png

Here’s the material snippet
scaled_lines.png
EDIT: Maybe that divide by scale can be simpler. I’ll check later.

Cheers

Thought I’d reply with the material I made in the end…

Same shader, different box scales. Uniform line widths.
scalable_lines.png

The Graph

I’ll probably try to add some filtering as fragments get small in screen. Maybe using DDX and DDY. Doas anyone have any suggestions?
Also I’ll probably end up making this into a UV based variant so that I can have skewed boxes.

Cheers

Looks great! :slight_smile:

I see that it uses local position, so it can work only with single meshes.
I’m not sure how it will behaves when becomes part of other actor. In case of using in BP I think it will take position of BP itself. In case of widget… ¯_(ツ)_/¯

Oh it does work if the box is a component inside a BP, that’s what I tested with the zebra striped sine shader in the picture above.
You see the right two meshes have hemisphere component icons inside them and I scaled the actual component and not the actor.

I’m spending way too long time on this it has to stop now. I did make a UV variant so that I can have skewed boxes and might be a bit more flexible.
It was just meant for the boxes in my 3D vr gui so enough already! :slight_smile:

The new one is a bit too confusing to post here but it uses the same principle as the above one just UV coords instead of local position. Also I had to do some custom UV layout so that I could have three planes to be scaled correctly.

UVs: three sets of quarter size areas.

same shader but now uv based
skewed.png
Actually, I should add a ‘skewfactor’ var probably as the end sides get longer than the ObjectScale indicates.

Cheers