首先,Render CustomDepth Pass選項位於Rendering模塊中。
準備
新建材質,更改Material Domain爲Post Process。
在關卡中放入後期處理盒子(Post Process Volume),勾選Unbound,設置處理範圍關卡中的所有內容。
添加剛纔新建的材質到Post Process Materials數組中。
關鍵
在選項未勾選時,Custom Depth爲默認值10^8,當勾選選項後值更新爲Scene Depth。
因此,用Custom Depth減去Scene Depth,若值大於0——未勾選,值小於等於0——勾選。
隨便拖入兩個網格體,勾選立方體的Custom Depth Pass後可以看到顏色變成了紅色。