This project is an easy to use mesh painter for the Unreal Engine.
You can use it for in-game painting or as a damage system. There are two modes Dynamic or Baked.
You can define textures (RenderTargets) and then use it in the material.
Inspired by Ryan Brucks and Tom Looman
You can find the project here: https://github.com/DimaChaichan/UnrealPainter


Dynamic or Baked Mode
There is a dynamic and a baked mode.
In dynamic mode, a new unwrap is always created based on the current location position. In baked mode, you create your own unwrap based on the pre-skinned data.
You can use the Baker for this. Dynamic mode requires a SceneCaptureCamera and is therefore more precise. But it is also more expensive in performance.
How it works
To create the texture we need the UVs. Here we use the idea from Ryan Brucks and create an unwrap which we then capture with a SceneCamera. Now, as described in Ryan Brucks article, we perform a UV dilation and create a new texture. This texture can now be used as UVs in a new material and painted onto a render target with “Draw Material to Render Target”. Since we have everything in 3D space, we can use Sphere Masks or DrawLine-3D to create a mask. This is then correctly transferred to the Uvs.


As you can see, the whole thing is quite performance intensive. To avoid capturing, you can also use a baked UV based on the preskinned data. Tom Looman has already explained this quite well. If you now have a skeletal mesh on which you want to paint, the hit is calculated back to the preskinned position. Baked mode is the best for static meshes, as the LocalPosition values do not change here. In the case of a skeletal mesh, this procedure will result in visual artifacts. Since we always paint on the T-Pose. If the character does a splits and you use a large brush and paint on one leg, the other leg will probably be painted as well. Because the legs are quite consecutive in the T-pose. In the end it depends on what kind of game you are making, if you want to be as accurate as possible you have to use the Dynamic mode. Also make sure that the performance doesn’t drop. If, on the other hand, you “only” want to show damage, I advise you to use Baked mode.

The whole project has been implemented with Blueprints. I think that the capture process can be completely outsourced to C++ and the camera removed. In the end we just want to have a texture with the UVs. This should all be packed into one function. Since C++ is not my favorite language, I will do this at some point.
How to Use
Simply add the BC_PaintSystem component to your Actor.

Now the meshes and the maps to be used must be set. The SetupMeshes function is used for this.
The function requires a Meshes array as BST_PaintSetupData. Struct BST_PaintSetupData:
- Mesh: On which mesh to paint
- Material Index: Which material index should be used
- Unwrap: Is used when the PaintSystem is bundled. See here: Baker
- UVsOffset: If your UVs are outside the normal 0-1 range. e.g. MetaHumen Body
- Maps: BST_PaintMapData, Which maps should be used
Struct BST_PaintMapData:
- Name: Map name
- Type: Color or Normal
- Size: RenderTarget Size
Paint
To paint, you only need to call the function Paint with Direction.

- Map: Name of the Map. All maps with the same name are used. No matter which mesh the map has.
- Location: World Location
- Normal: The direction in which you want to project.
- Bone Name: Is only used for SkeletonMesh that are baked. The hit location is calculated back to the preskinned location.
- Rotation: Project Rotation
- Size: Size in World Units
- Opacity: Opacity
- Brush: Project texture
- Bush Shape: You can project with a box or a capsule Shape.
- Brush Length: How long the bush should be. So you can also paint the back of meshes.
The output forwards all inputs, making it easier to build chains of nodes.
You also get the painted render targets.
The goal of the project was to create a very simple system to paint on textures and not be limited to a pure “damage system”.

