For some background information, I am working on a game where the world is black-and-white and it gets colored in through the player’s actions. This is achieved using Sprite Masks to show the color or black-and-white version of the background. I use Graphics.Blit with a set of shaders to copy different shapes/effects onto the textures used by the Sprite Masks.
This can be seen in the first half of this video:
Currently, there is a path that follows the players with circles that travel downward as if it was paint dripping down a canvas. This looks ok, but I don’t like how bumpy the bottom edge looks.
To address this shortcoming, I have been experimenting with using a Sprite Shape to make a smoother effect behind the player. This is shown in the second half of the video above.
Before I go any further with this experiment, does anyone know if there is a way I can somehow copy a Sprite Shape to a texture so that I can then copy it to the Sprite Mask’s texture? Would I need to somehow use another camera and direct the camera to output to a Render Texture?
Also, is Sprite Shape the only way to render an enclosed spline?
In case anyone is curious, I was able to hack something together with a second camera. I pushed the Sprite Shape back to a larger Z value and placed a secondary camera behind the main sprites and in front of the Sprite Shape.This way, the secondary camera only sees the Sprite Shape and nothing else.
I had this secondary camera render to a texture. I created a copy of my “copy sprite to the mask” shader to only copy the non-black pixels of this render texture to the mask.
At present, this requires copying a full-screen (lower res) texture every frame, so I’m not sure if I’ll run into performance issues later, but at least it is functional.