- Home /
How can I efficiently determine that certain parts of a texture have a specific color?
I'm working on a mobile game where one of the mechanics involves players swiping their finger on an object to "paint" it. I do this by assigning the object a shader with the option to add in a render texture. The camera that is drawing to the render texture is looking at an all-white quad. When a player swipes, sprites are placed in front of the quad, which the camera picks up and draws to the render texture. The shader uses the render texture to make it look like the object is being painted. When the player is finished, the render texture's image is stored onto a Texture2D, which I use to determine if the entire object was painted. The issue is that the process is really slow, especially on a mobile device since my current solution involves reading all of the pixels on the Texture2D that correspond to the object's UVs and checking if that pixel's color matches the expected color. I was wondering if there was a more efficient way of reading a texture to determine if the pixels that correspond to the object's UVs are the color that I need them to be?