Approximate Color Recording
Goal: Estimate how much of the map gets painted for the completion bar.
Problem:
My first thought was to get the color directly from the texture, however the blueprint nodes that “Read Render Target” are far too slow to be used.
Instead of using the texture, I decided to make an approximation of painted colors stored in the blueprint.
What didn’t work:
My first test tried to take advantage of line trace’s Find Collision UV. By creating an array of coordinates and colors based on where uv islands were, I could store approximate colors.
This had a few problems:
-
With bigger brush sizes, I could either choose to let it “paint” less than it actually did, or leak onto other places it didn't paint in 3D but was close to in UV space.
-
I wasn’t actually defining where uv islands were- I was using a very low resolution version of the mesh’s texture, using the Read Render Target node, and creating array items based on which pixels were not black. This had similar issues with my first go with section masks.
Solution
I moved the array of coordinates into 3d space.
The biggest deal was making a tool to dictate where the coordinates were. I decided to place them myself, as the point of approximating this meant there weren’t many to place anyways.
While Unreal has a 3d widget toggle on public location variables, I found it more convenient to place the points on the actor in Maya/Blender. Unreal’s mesh importer accepts locators/empties with the prefix “SOCKET_” as sockets, and I named each socket according to section.
I wrote a function to store the socket and section information, and afterwards the sockets can be safely removed from the mesh.
Outcome
I created a good enough, fast estimate of how much the player had painted the level.