- Home /
Replace parts of one sprite with parts of another sprite?
Hi all, I would like to create a system to replace parts of one sprite with parts of another sprite based on a mask-like texture. A system similar to the face generation in the game Papers, Please.
I found a forum where the developer briefly explains how he achieved it: https://forums.tigsource.com/index.php?topic=29750.msg820306#msg820306
How would I go about doing so?
Answer by Bunny83 · Nov 08, 2017 at 01:27 PM
Some time ago i've written a simple CPU based alpha blend method which allows you to "merge" two textures into one based on the alpha channel of the "top" texture. However it should be clear this shouldn't be used frequently. It can be used to setup / compose textures in start.
The textures need to have the same resolution so the different textures should fit on top of each other.
Thanks for your answer. This information is very helpful. I probably won't be using it in this case since I will need to fiddle with the sprites often. But I definitely will need to use it somewhere else. Thanks again.
Answer by FlaSh-G · Nov 08, 2017 at 10:33 AM
Why not just use multiple sprites/sprie renderers? 2D games generally don't tend to have any performance issues you would have to worry about - and even if you'd want to achieve perfect performance, Sprites can be very easily batch rendered when they're on the same atlas.
Thanks for your answer. I was thinking to do something similar, but I am just curious whether the method mentioned in the question is possible in Unity. Its possibility may be obvious, but it isn't to me as I am not good with graphics, shaders and such.