Vertex color painting at runtime

It would be awesome if we could manipulate vertex colors at runtime that would make a whole lot of things possible and from what I understand it wouldn’t be that hard to implement in the engine.

As for how it could be setup in blueprint, it could be similar to the Radial Damage with Falloff node, instead of damage it is then vertex color and the input is a color vector. Additionally there could be a setting for painting additive or overwrite.

I have here a specific thing I need this for, my game is made around painting:

That is just made with GPU particles and they need to have a lifetime, I would love to be able to let particles paint dry into vertex colors so the paint can actually stick on the walls for always.

That is obviously a very specific case but here are some more ideas that have a wide use, important to note is that vertex colors can be used as mask where the transition uses a texture similar to a dissolve material:

  • Dirt/Mud that can splash and stick to surfaces (think racing games)
  • Gore/Blood, painted on skeletal meshes it can mask in gore or blood where the pawn is hit
  • Painting terrain at runtime, RGB can control different texture masks and Alpha adds world offset like a heightmap (Think god games)
  • Deformation painting, RGB can be used as world position offset and Alpha as the texture mask (I did something like that in my UDK game Last Knight but with spherical world position masks which made it very limited:
  • Masking wetness or snow, think of the Uncharted character that can get wet exactly where he was underwater.
  • Trails, like trails of tires in the mud (can use world position offset for depth and texture mask)

I’m pretty sure other people will come up with more cool ideas. :slight_smile:

Would love to have this feature! In our game, we have a feature in which the player can paint. This looks promising for that feature!

Niagara seems to be far more advance in terms of scripting, so it might make what you show in gif more possible

Hi everyone,

I spoke with Eric Ketchum about the possibility of vertex painting at runtime. It does not seem this is going to be a possibility, here is what he said about it, for clarification:

“Vertex Colors are a component of the Vertex Information that is rendered at the time of the Vertex Pass. If you were to alter the vertex information at runtime then the whole sequence after the vertex pass would have to be re-rendered every frame that the vertex is changing color. This would yield extremely bad performance. The way around this is to use individual vertex colors to control the look of a mesh at runtime, so red yields a texture of the paint in place, green maybe has a dripping texture mask/motif that can be used to lerp into the red channel. And blue can be something entirely different as needed for what you are doing, but the runtime changes are not the vertex colors themselves but how the material is using the vertex color information which never changes.”

I made a test in the editor and that is not the case, in fact I can’t see any frame drop while painting vertex color and the shader I used is pretty complex. Works like a charme just that there isn’t anything that let me do it at runtime:

Even if performance would be bad for gameplay it would be still nice for stuff like customization, for players being able to paint their cars, characters etc.

Yea this is something I would love to see. Doesn’t even have to be full vertex paint, just being able to paint on a texture in real time. But vertex paint would be really nice too. There are so many nice uses for it. Like in The Unfinished Swan where its the whole game play mechanic. And yea in the editor you paint in real time and it doesn’t seem to be affecting much.

ppl are using the term vertex colors with is false and implies a wrong picture in the head of your engine man… can we paint onto textures? like a dynamic alpha map 256 colors black white, where we can apply information to at runtime. that would solve everything… If this is allready doable, point me in the direction, pls ^^

Yeah but does it work in a shipping build? We have this exact issue, where it crashes in the shipping build, but works fine in the editor/

That’s what Eric was trying to explain. The vertex pass happens at a point in the render pipeline that makes it impossible to use at runtime.

it is completely possible to do this since Unreal Engine 4.13 using render targets and mesh painting.

I know this is an old thread - but I recently did something similar - I used a component to source the properly tagged mesh components under it’s actor’s root (traces down all of the roots’ mesh components - and uses procedural mesh to duplicate them and the hide them from sight). then as mesh sections - vertex color can be changed multiple times (this is done quite quickly by calculating each vertex color and using UpdateMeshSection to edit it. I apply a dynamic material instance to the procmesh and it paints quite quickly and is easily controllable.
just make sure you do it the right way so you don’t keep regenerating the proc-meshes - only update the sections of the procmesh when vertex color needs to be changed.

You can also use this technique to modify normals, UVs and tangents.

If anyone is interested in a walkthrough tutorial on this I can make it - just let me know there’s interest in it and I will take the time to create a demo project and walkthrough

I would be very grateful if you posted this.

I’m not entirely sure that i understand what you meant - but if (as I think) you mean to substitute the normal mesh-material for a procedural run-time mesh (where you can change the vertex colours), from my experience this is not fast enough for real-world (complex) meshes. Even for relatively simple (mannequin) mesh, once you create a procedural mesh, it becomes a grind to manually cycle through all the vertices, calculate a colour value, and set it. I’d really be interested to see what can be done (as I had to cheat by doing piece-wise randomly-generated vertex list to update of the mesh colours and it was slow - in blueprints).