top of page

Spline to Texture Tool

Summary

This plugin converts a spline into a texture asset, applies that texture to a material, and places the material onto a mesh for visualization. My goal with the project was to accomplish three things: make the texture generation process as easy as possible for designers, provide a strong set of customization options, and optimize the generation process.

First Steps

The first step was building an Editor Utility Widget to act as the designer-facing interface. Since the plugin is editor-only, this was the ideal choice. The customization options were largely the same as the final version, although the widget itself looked very different at first. I initially assembled the interface directly in the editor, with all of the technical functionality living inside the widget.

S2T - Old UI.png

Setting Up the Functionality

For the original texture generation method, I started by creating a dynamic material instance of my custom line material, which I used to draw the spline path. I then calculated the world origin and bounds from a referenced plane mesh, which allowed the final material to correctly project the generated texture onto the mesh. After that, I sampled points along the spline every 100 units and stored them in a vector array.

 

From there, I looped through the array and grabbed each path point along with the next point in the sequence. These two world-space positions were passed into the line material through material instance parameters, where they were converted into UV space. I also passed in the path width and feather settings. Each segment was then drawn onto a canvas render target, and the process repeated until the full spline path had been drawn. Once the render target was complete, I saved it as a texture asset and passed it into the final viewing material.

S2T - Old code.png

The Problem

This method got the job done, but it had two major limitations. First, I couldn't save the generated texture to a custom folder. Second, the generation process was extremely slow and unoptimized, especially at higher texture resolutions. To solve both problems, I decided to port the functionality to C++, including the Editor Utility Widget design.

S2T - Code.png

A New Look

Since I was already expanding the plugin through C++, I also used the opportunity to improve the widget interface with Slate. I started with the color picker, because I wanted designers to have a familiar and flexible way to customize the viewing material that displays the generated spline texture. The color picker allows the designer to choose both the color and glow amount for that material, making it easier to preview and style the spline path.

For the picker itself, I used Unreal’s own Slate-based color picker. It works out of the box and includes useful features such as an eyedropper and color themes. To expose it to Blueprints, I used open-source code from developer Rohan Singh as a starting point. I also added a glow amount slider and a checkbox that allows the viewing material to render through objects.

S2T - NewColorPicker.png

Upgrading the Tech

After I finished converting the generation system into C++, I focused on optimization. The main issue was the number of GPU draw calls. In the original version, the plugin could potentially make hundreds or even thousands of draw calls because a new line draw operation was performed for every spline segment.

To fix this, I reworked how the line material received spline data. I still sampled path points, but this time I converted them into UV space before storing them. I then used those points to create a spline data texture. As the name suggests, this is essentially a texture that stores the spline’s path data.

 

I passed that data texture into a heavily restructured line material, allowing the material to read the full path from the texture. Instead of drawing each segment one by one, the plugin could now draw the entire path in a single pass. This reduced the number of draw calls dramatically, and it also meant that path settings such as width and feather only had to be passed into the material once.
 

Finally, I exposed Unreal’s Content Browser folder picker to Blueprints, allowing designers to save the generated texture asset to a custom folder location.

S2T - New Texture Settings.png

The Final Result

Thanks to C++, Slate, and the new spline data texture workflow, the final plugin has a more versatile and familiar editor interface, faster texture generation, customizable save paths, a see-through material option, and improved control over how the generated spline texture is displayed. You can check out the plugin on the fab marketplace here.

bottom of page