Workflow to create and render a line on the GPU

For about 200 hours I’m trying to draw a textured line (mesh in world space) at runtime.

The Procedural mesh component (and any other CPU mesh creator) turned out to be useless. You can make the line with them but texturing it (without distortion) is impossible as they rely on triangles and undistorted texturing requires quads.

So, a workflow entirely on the GPU seems unavoidable.

But there’s little to none information available how to do this, as 99% consider only vertex manipulation or pixel shading.

250

Hey there,

Just wanted to ask, are you trying to do this on shader level? or you just want a line rendered on gpu with textures (not distorted)? Are you trying to do something specific or just drawing a line?

Cause niagara can easy do that with ribbon quads without distortion. If you are trying to to do a custom shader to draw a line existing mesh vertices then you run into the limitation that shaders can’t generate new geometry by themselves.

Also, if your use case is screen space lines rather than world-space geometry, you can draw textured lines directly in UMG. UMG supports custom lines (tangent or custom ones) with additional textures if you want also possible to position correctly on world space, so you can render a textured line in the UI without touching mesh rendering at all.

Thanks, good ideas. Niagra provides only unconnected quads. Although my lines are given by a set of quads, these are connected, have fixed positions and the texture has to be applied to them as a whole.

The reasons I would prefer world-space are:

  • reduction of overdraw, since the lines are thin
  • easy to make them hover and clickable
  • easy to put other objects in front
  • I have code to adjust the segment thickness such that the line appears to have constant thickness in the camera at any time

In general shaders can also create new mesh but that seems not easy to do in UE.

Yes think its called something like vertexfactory i saw one time never tried though have limited knowledge around those still should be doable, i would check the function of the DrawDebugLine which engine uses since it does something over there, a simple one though not sure similar can be textured. Did you check that one ? (possibly you did :slight_smile: and with their own comments they say its not very good idea to use in production)

Also wondering can be something in NiagaraRibbonVertexFactory related