Spray Paint System

Godot Version

4.5

Question

Hi! I’m creating an aerosol painting system for my game.

I’ve finished painting the vertices. Everything works fine, but I’m experiencing low fps on large meshes.

Do you have any suggestions? Is there a different approach?

I remember there is a youtube video about this. The author switched to using compute shader.

Vertex painting is going to involve pushing the model across the CPU/GPU boundary every time you modify it, unless you’re somehow doing the vertex painting on-GPU.

What might be faster would be to “vertex paint” with multitexturing; assign each vertex a texel on a texture, then just update the appropriate texel to paint a vertex.

This would potentially be a bit fiddly; you’d need a vertex to texel lookup, and you’d also want your aerosol vertex UVs to be properly adjacent so the blending works right. You’d probably be able to do it with unwrapping?

There are two potential advantages to a scheme like this:

  • the texture is more compact, so it’s cheaper to upload changes to the gpu
  • you have the option of higher detail airbrushing by increasing the size of your texture
1 Like

Why do you need vertex paining? You can just paint the texture.

I need to be able draw in 3d space by mouse, on any mesh, like graffiti spray paint

Can’t find any(
Only plugins for mesh painting

i’v done with this

And i like how its done in Duke Nukem Forever when player draw on board

Seems good.
And how can i achieve this?

If that video is the effect you’re trying to achieve, draw-to-texture seems to me to be the better option; your meshes can be a lot simpler. As an extreme example, your cube there could be an 8 vertex, 24 triangle indexed mesh (fewer if you don’t need the backfaces…), and even with a fairly low res texture you’d get better resolution on the graffiti.

If I was doing it, I’d suggest a second texture and using multitexturing; you can have whatever your default texture is on the model, plus a second graffiti texture that starts out all transparent. Add graffiti pixels by writing to the texture, then use a shader that blends the two textures based on the alpha of the graffiti texels.

Your graffiti texture would be another sampler uniform in the shader. You can definitely edit it on the CPU side, but you may also actually be able to update it on the GPU side; I’m not sure?

Assuming CPU, all you really need is a way to map the your spray/mesh collision (which I assume you have now, to make your current scheme work) on to the unwrapped texture.

1 Like

UV seams are the main problem with this.