Hi, I want to implement painting in my game, pretty much like painting in Portal 2 or Splatoon.
I’ve thought about doing it with decals, but then hundreds or even thousands (maybe) of decals might create a performance problem, no?
After that I’ve tried implementing a second texture that exists over the normal texture in paintable objects, and when you hit it with the paint gun it finds the UV coordinates of the hit location, and dynamically paints the texture at the location (requiring me to change engine source code, and keep vertex data accessible, not to mention this painting is a big for loop that runs on the CPU). It more or less worked, but I have had a few problems with that.
First of all, I rather have an implementation that does not require an extra texture for every paintable object, and I don’t want to change every single material in the game that is paintable to contain a dynamic texture.
Then a problem I had is painting two objects that are near each other. I can only paint one at a time even if the paint hits both of them, and I’ve come up with very convoluted ways of overcoming that, but its still not as good as I’d like it. The problem is the only way I found to determine the UV coordinates is a raycast, a sphere sweep will tell you nothing.
Another problem I have is that if the paint is big enough, and painted on the edge of the model then it will overlap over the UV coords enough to paint a different side of the model as well.
The last problem I have had is more complex models, often the UV coordinates do not translate directly into the location on the model. By that I mean a place 10cm to the right on a model might be on the other side of the UV map.
Deferred Decals should solve all those problems and be much more simple in every way than what I’ve tried to do, but its performance in big numbers worries me.
Anyone have a good idea on how to implement this? Thank you very much