MATERIAL : spline with custom points


Im trying to make a material which displays a spline as seen above. I have no idea where to start basically and was hoping for some directions!

Here is what i have in unreal at the moment:

I need to draw the spline along the points.

The points are currently individual widgets in UMG attached at runtime to a canvas panel slot.

Each point has a Longitude and Latitude value, and some math to convert it to canvas panel screen space (which im hoping can be used in a material?).

In the executed version of the game there are only 4 points!!

I hope someone can shed some light on this, many regards

  • Renn

Transferring all those points to the shader might be a bit heavy. I would recommend calculating the curve itself inside the shader to simplify the process (unless the math is somehow super complicated)

If you don’t mind reading some GLSL there are plenty of examples of graphing a line on shadertoy, such as this one or this one that should help you to achieve just that.

Ideally it’d be better to avoid doing it in the Shader at all, what we really want is some kind of 2D Spline Component that lets us draw a material over it.

If anybody has already done it, that’d be useful!

I would use Slate’s built-in spline drawing capability we use in the blueprint editor. Not currently exposed as a blueprint function, so you’ll need to write a paint function for it in C++ that’s exposed to blueprints and do it in a Widget’s OnPaint.

Ah okay, not used Slate in C++ at all yet so that’ll be a learning experience for one or all of us haha.

Could we write a custom ‘Widget Component’ (Not sure what the real terminology is, like the Text Box, Border etc. that just takes in a bunch of points and draws the spline between them? Essentially that’d be the most modular/reuseable option.

Hey Nick! Thanks for the advice, i had a cheeky google and couldnt find a starting place for spline and slate ui in UE4. Are there any resources that directly reference it use that you know of, time for me to upgrade from C# :wink: