Use Depth Mask to Hide Objects in Unity - URP & Built-in

preview_player
Показать описание
How can you safely place your boats in the water without allowing any water to seep in? Watch this video!

This shader draws faces that are invisible, but which still appear in the depth buffer. This allows you to prevent objects from being drawn where they are occluded by the mask.

• Don't Forget to Subscribe:

If you have any questions post them in the comments and I'll do my best to answer them 🙌

#gamedevbox #Unity #gamedevelopment
Рекомендации по теме
Комментарии
Автор

Hey guys sorry the video is a little fast didn't realize it until now :), you can change the Playback Speed.


Shader "Masked/Mask" {

SubShader {
// Render the mask after regular geometry, but before masked geometry and
// transparent things.

Tags {"Queue" = "Geometry+10" }

// Don't draw in the RGBA channels; just the depth buffer

ColorMask 0
ZWrite On

// Do nothing specific in the pass:

Pass {}
}
}


GameDevBox
Автор

Clever & Succinct! Can't wait for more!

Soundy
Автор

I get a shimmering ghosting effect in URP? I think it was caused by the camera render setting from dither to forward. But the problem still exist. Any idea?

tongzhouyu