I’ve made a material that creates a SphereMask at a location:
I’ve created a Sphere with this material and set the Location parameter as the impact location of a line trace from the player camera, causing the Sphere to “light up” when I look at it:
Next, I want to draw this material to a Render Target with the intent of having the Render Target accumulate SphereMasks when drawn to, resulting in something like this:
This should result in a run-time mesh painting effect.
The problem is that I first need to convert the SphereMask of the first material from World location to UV space before drawing it to the render target. How do I do that?
The same question have been asked here, but left unanswered:
It has this image that perfectly illustrates what I want to accomplish:
To clarify, I want something like the height map painter show here, except adapted to work on a Sphere instead of a Plane:
tracing a ray in blueprint allows you to retrieve UV coordinates from a mesh on hit, and that is what you should be using to get what you are asking for.
Sadly, that’s not enough. While that works for a simple plane, where the UV mapping to the mesh is continuous and uniform, for more complex shapes, such as the cylinder shown in the last image of my post, that won’t work. Using your suggested method to draw a SphereMask on the correct UV coordinate will cause the center of the SphereMask to appear in the right location, but everything aside from the center would be subject to texture stretching and discontinuous surface mapping (Again, look at the last image of the cylinder).
I then render that same sphere mesh on an flattened version of the mesh so it flattens the sphere mask correctly into 2d
Then use a scene capture to take a picture of the flattened mesh as a white mask for my painting operations.
Here is the material function i plug into world position offset to get the flattened effect (for some reason uepastebin didnt like it but heres a picture)