- Home /
Question by
cbattisti · Apr 05, 2018 at 12:19 PM ·
shadermaskingdepth-buffer
Creating a depth mask from black and white image
In my project I'm trying to achieve something similar to a depth mask shader by using a black and white image as a mask.
I have a script that generates B&W images representing the areas where I want my 3D objects in the scene to be visible or hidden. I've put the image into a Canvas and applied a shader that for now just turns the black pixels to transparent (through alpha channel).
What I want is for the white pixels in my image to draw in the depth buffer (on top of 3D objects) and for the black ones to just turn transparent and show the objects behind the Canvas.
How can I make this happen? Is it possible through a custom shader?
image.png
(249.0 kB)
Comment
@cbattisti Had you solved it? I need it as well. Just curios.
Your answer
![](https://koobas.hobune.stream/wayback/20220612160124im_/https://answers.unity.com/themes/thub/images/avi.jpg)