So am trying to create a make-up game and i need to have a basic drawing solution,
and so far i have made a good progress with the help of the DepthMask solution
My approach was like this :
suppose we want to edit the eyelash color (texture)
1-in the beginning there is an eyelash object at a layer named old 2-after choosing the new color that we will draw with, a new game object is created under the first eyelash, which mean it's invisible for the moment 3-then when we start drawing, we are actually creating little circles above the old eye lash, these circles contain the depthMask shader which effect the old eyeLash and give the impression that we are drawing with the new color
So far, everything is going great, my problem is that i cannot use this approach to use a 3rd color, suppose the player want to create an eyelash with mixed color, how can i do that with the previous solution ? or is it impossible to do ?
EDIT: I already thought about adding new layers with each new color, and it works, but since unity is limited to 31 layers, this solution can never be a good one.
I really hope someone can answer this, and if you know a better way to do it then please don't hesitate to tell me.
EDIT2: After a couple of hours, i've reached a pretty cool result, and i think that this can be the good way to reach my goal, this script allow to replace a specific pixel in a material texture with another chosen texture (target texture must be in the same size, and readable)
// the texture that i will paint with
public Texture2D targetTexture ;
//temporary texture
Texture2D tmpTexture;
void Start ()
{
//setting temp texture width and height
tmpTexture = new Texture2D (targetTexture.width, targetTexture.height);
for (int y =0; y<tmpTexture.height; y++) {
for (int x = 0; x<tmpTexture.width; x++) {
//filling the temporary texture with the target texture
tmpTexture.SetPixel (x, y, targetTexture.GetPixel (x, y));
}
}
//Apply
tmpTexture.Apply ();
//change the object main texture
renderer.material.mainTexture = tmpTexture;
}
Now i think that the problem will only be, "how to know which pixel i should replace based on mouse position over the object ?"
Thank you very much and have a great day.