Decal removal

Hi All,

As part of a project I’m looking into a way to erase a decal from an object.

So if you imagine a wall with graffiti on it (or better still a sphere) and the player has to scrub at the graffiti to remove it using touch (iOS).
The object I am removing the graffiti from is not flat and is quite detailed as is the texture decal applied to it.
And you can view the object from any angle.

My first (and only) solution was to use a Decal shader and detect where on the texture the player is touching and gradually make it more transparent the more they rub that area.

It all works well but but because I’m having to get, set apply the pixels in the Texture2D i’m getting a frame rate drop from 44fps to 20fps. I can live with it but I was wondering if anyone else had any thoughts on how I could achieve it.

Probably faster to make a control texture of much lower resolution (like 32x32 or 64x64), and then modify that texture. Then modify your decal shader to use the control texture - ie, modulate the alpha of the decal by control pixel .r value. Also, probably way faster to use a rendertarget to draw the “empty” areas to the control texture. If you can’t do that, be sure you’re using the GetPixels32 and SetPixels32 functions to read/write the texture.

Hey Jaimi, thanks for the reply.

I never thought about using a control texture.
I guess the trade off with this approach is that I would be removing a larger area of the decal each time a pixel is removed from the control texture but I’m currently removing an 8x8 block for every touch anyway so if the control texture was 8 time smaller than the decal texture then I’m getting the same effect and writing back a texture thats much smaller.

I’ll look into rendertarget too and see if it helps with performance.

Also thanks for the heads up on Get/SetPixels32, you made me look at the docs a little closer :sweat_smile: