- Home /
Shader working in scene mode, but not in game mode (depth texture issue?)
I am trying to use a shader from (the last one) https://chrismflynn.wordpress.com/2012/09/06/fun-with-shaders-and-the-depth-buffer/ (I put the script on my camera). Unfortunately it is only working in scene mode, but not in a game mode. Any idea what I might be doing wrong? I think there might be some issue with the depth texture. I am new to Unity and also to shaders (I just wanted a simple effect), so I am not exactly sure how to proceed.
Answer by marcozakaria · May 25, 2020 at 09:29 AM
If you are using URP or LWRP make sure to select "Depth Texture" on in render pipline asset settings
Thank you so much! I tried solving this for hours, and this fixed the problem! I can't believe no tutorial mentions this
I'm so glad I stumbled upon your comment. I was literally trying to solution this for hours. Thanks a whole lot!
Answer by csharpislovelife · Nov 24, 2021 at 11:45 AM
I just had this problem and i figured it out! Make sure that your anti-aliasing settings on your camera are set to SMAA. I'm sure there are better ways but this worked ,I just had this problem and i figured it out!! On your camera make sure your anti-aliasing is set to SMAA. I'm sure there are better ways but i found out this worked.
Thank you! This was exactly my issue, as URP settings were set up correctly from the beginning of the project.
Answer by Namey5 · Jan 09, 2019 at 10:05 AM
This post is quite old, and as such the main thing that the Camera script relies on has actually been deprecated (a long time ago too). All you need to do is replace the one line in that script with the following;
GetComponent<Camera>().depthTextureMode |= DepthTextureMode.Depth;
The '|=' (or/equals) isn't necessary - you can just use '=', but if you don't use '|=' it can cause conflict with other scripts/effects (if you use them).
Your answer
![](https://koobas.hobune.stream/wayback/20220612183944im_/https://answers.unity.com/themes/thub/images/avi.jpg)