- Home /
Procedural Surface Painting
Procedural Surface Painting~ You can most easily picture this by imagining a paintball gun. Shoot at a wall, it leaves a paint splatter against the wall. Shoot it at the floor, leaves one at the floor. Shoot it at an object- it splatters across the object, around the corners and etc.
Anyone know how to achieve this? I know I'm not the only one that has/will want to achieve something like this, rather for blood splatters or actual paintball simulators~ whichever.
After a lot of researching I have found two things however. One, an asset on the store called 'TexturePaint'. I purchased it and gave it a look, but it is fairly glitchy and does not purpose the usefulness of something like this out of the box. It'd be much easier and less buggy to simply start from scratch.
I also found a guide here, by Morgan Davidson on exactly how to do this. It was posted about two years ago, with no follow-up. You can see exactly what is meant to be achieved by the demo project attached. As said however, unless he posted the full guide somewhere else I couldn't find; the actual implementation of this is lost. I've even tried contacting him, it's been about three weeks now with no response- So I come to Unity Answers.
Any sources/ideas?
Better than procedurally 'painting' would be to apply decals. You'd have prefabs that have a texture applied to a plane of what you want to 'paint' that would be instantiated and applied to the point on which the impact occurred. That would be this simplest approach, but wouldn't handle corners very well, for instance.
Another approach is to take the same texture, without creating a prefab or applying it to a plane, and actually modifying the pixels of the texture at runtime. This is very expensive and should only be contemplated on a pc or console (or, in other words, not mobile). The reason it is expensive is two fold. A, you'd need your textures to be read-write enabled, so they'd require at least twice the memory footprint that the texture would actually need (one original, and reserved memory for instancing it, then instances of it). B, you'd need to actually do the setting of pixel colors based on the texel coordinates, which takes time.
Long and short of it is that you'd probably want to go with the first approach, but possibly add in some geometry clipping so as to remove parts of the prefabbed plane that would just be sticking out into the world. However it would be super fast to implement placement of those decals without any fanciness to deal with corners. Depending on the size of your 'splat', you might actually be able to get away with not doing any geometry manipulation.
Your answer