How to hide objects inside of- or behind another transparent object?
I need 3D objects to be invisible if they're behind or inside an invisible cube, without having to apply a custom shader to the objects. I can apply a custom shader to the invisible cube. I've experimented with stencil masks and depth buffers, but haven't achieved both a transparent cube and the objects behind it to be hidden. I know very very little about shaders. Any help would be greatly appreciated!
Answer by joepeijkemans · Jun 25, 2020 at 11:55 AM
I fixed it with a depth buffer: https://github.com/doomlaser/DepthMask-Unity-Shader/blob/master/DepthMask.shader
I then added an extra layer to ignore with the camera so that the clear flags of the camera are updated through the object
Answer by louiselessel · Nov 13, 2020 at 08:22 PM
Hi!
This seems like a very good solution, I too have been chasing the stencil masks for a while now.
How are you doing the second part with the clear flags though? Can you provide an image of your settings?
I'm getting a black shader in my camera view. (I'm trying to hid eat butt of the turtle)
[1]: /storage/temp/170978-screen-shot-2020-11-13-at-31730-pm.png
Hi, this problem also made me crazy. Then I found this subpost http://answers.unity.com/comments/1463692/view.html
You have to change { "Queue"="Geometry+1" } to { "Queue"="Transparent+1" }
@LeoThePhoenix thank you!
It truly did drive me crazy. So I actually ended up using this solution as can be seen here: https://www.instagram.com/p/CJzIYh6lvZY/
“Per-Object Clipping Planes Shader in Unity3D 5” tutorial by toxicFork / Firtina Ozbalikci. http://www.toxicfork.com/194/per-object-clipping-planes-shader-in-unity3d-5
There is a unity project in the bottom of the tutorial. Saved me heaps of time. I think it has limitations perhaps for the never render pipelines, but have not tested.
Thank you, I will have a look at your solution. It seems to provide some additional possibilities =) My initial problem was Unity's URP btw. And the solution I've found finally works there.
Your answer
Follow this Question
Related Questions
Modifying shader requires restarting application 0 Answers
See-Through effect for top-down game (Performance issues) 0 Answers
Material.SetFloat not working 0 Answers
Custom Urp shader weird problem 0 Answers
Shadows on Custom Lit Surface Shader 1 Answer