Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Shader displayed as expected in Scene view but different in Game view

Discussion in 'Shaders' started by cado82, Aug 20, 2020.

  1. cado82

    cado82

    Joined:
    Jul 29, 2020
    Posts:
    25


    Scene view on the left. Game view on the right.

    I am using https://alexanderameye.github.io/simple-water in my project. I have it looking as I want in Scene view but when I play the game or view it in Game view it looks like the right image.

    One thing I observed was that if I change the Render Queue on the material to anything in the 2001-2500 range, I get the exact same result in the Scene view as I have in the Game view (mostly white with blue speckles). I know very little about the Render Queue but is there some setting that could be overriding this on the global scale? Maybe you have some other ideas on how to troubleshoot this?
     
  2. cado82

    cado82

    Joined:
    Jul 29, 2020
    Posts:
    25


    It seems to be some weird reflection issue. Does anyone know what's causing the reflections of the models in the background to show on the water? I think the white water is the reflection of the bottom of the terrain plane.
     
  3. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    121
    That looks like an issue with the depth texture (that's what you see on the last screenshot, not reflection). That's why you got this result when you set Render Queue to 2500 or less - at that point the depth texture does not exists. As I understand from the link, you are using URP, so for the effect to work correctly, make sure that Depth Texture is enabled in your pipeline asset, and that it is also enabled in the settings of your camera. Though the last screenshot looks like something else may be wrong too, did you change anything in the shader?
     
  4. cado82

    cado82

    Joined:
    Jul 29, 2020
    Posts:
    25
    @Oxeren That was it, thank you. I enabled Depth Texture in my pipeline asset and it works as expected.
     
  5. Rispat-Momit

    Rispat-Momit

    Joined:
    Feb 14, 2013
    Posts:
    267
    I am having the same issue but I am using the Standard rending pipeline. Any solutions for that?
     
  6. jHofer66

    jHofer66

    Joined:
    Dec 20, 2022
    Posts:
    2
    @Rispat-Momit I'm using the Built-in render pipeline, not sure if that's what you mean by Standard in your post but the following ended up solving the same issue for me.

    My script attached to my main camera and was calling a simple SetCameraTextureMode() method in OnValidate() and Awake() that used:

    GetComponent<Camera>().depthTextureMode = depthTextureMode;​

    Another post somewhere mentioned getting at it this way instead and that solved the issue.

    Camera.main.depthTextureMode = depthTextureMode;​