- Home /
Shader help - 2d black and white polygons where black shows one background image and white shows another
I'm really stuck on this and I've tried numerous things which haven't been working very well. I am new to shader programming so I don't really have a clue what to do. I tried looking into the DepthMask shader but it didn't accomplish what I needed. Basically I have a game like this that is black and white and I am trying to make the black show an image and the white to show another image like these examples:
Example 1 (the subtle textures on each colour is different)
Example 2 (a clear example of the kind of thing I would do except for both colours)
I have tried setting the polygons to textures manually but the problem is that the textures don't line up obviously so it doesn't look like a mask over a big entire image.
My ideal solution would be a post-process effect that just finds either black or white pixels and replaces it with the appropriate pixel of each one of the two textures (the one for the black and the one for the white). I don't have Unity Pro though so that may not even be possible (if it is even possible with Unity Pro??).
I found in the Unity manual something that is getting closer to what I need. At the Surface Shader Examples page if you scroll down to "Detail Texture in Screen Space" it seems to provide a functionality close to what I need.
I guess I'll try fooling around with that and see what I can do. Would anyone be able to explain the shader code there a bit to me? I understand UV mappings but I don't know where the 8,6 comes from (unless it's just an arbitrary number).