Real time vertex paint (or similar solution) possible?

Is it possible to draw onto textures in real time (while playing) and get a good result? This is something that has boggled my mind a bit lately. The thing is I would like to be able to do it for instance with a collisions hit point, preferably with a second texture layer on top of the underlaying layer(s).

This could for instance be used for scratching the paint job of a car inside a OnCollisionStay(). Is vertex paint the thing I’m looking for here or could perhaps another technique be more suited? Perhaps if Texture2D.SetPixels takes alpha procedurally from another texture?

By the looks of it the question is a bit vague, I was meant to ask how you would solve a task such as drawing procedurally onto a textured mesh in theory. :slight_smile:

Scratched paint

You can use SetPixels (or SetPixel), which do take alpha (part of Color). If it’s freehand drawing you want, this is probably it. I’m guessing using a raycast from a screen-to-world conversion to get the hit point and texture coordinates.

If you’re wanting to put scratches per se on stuff, like also bullet holes etc, it’s probably ‘decals’ you want.

The problem with doing this is that you have to upload the texture whenever you make any changes, by using Apply(). The entire texture has to be uploaded even if you just change one pixel, so using Apply() with a large texture can cause a slight but visible hiccup in the framerate. It’s also somewhat memory-intensive, since you have to read the texture into a Color array, which uses 16 bytes per pixel (4 floats).