Search Unity

Question Strange offset reflection with any simple water shader graph? (URP)

Discussion in 'Shaders' started by CreepyD, Mar 21, 2023.

  1. CreepyD

    CreepyD

    Joined:
    Jun 9, 2019
    Posts:
    24
    I've been struggling to get any water shader graph working for a while now.
    I have tried my own shader from tutorials and also pre-made unitypackage shaders, they all seem to have the same problem, a weird offset replica of the world in the shader.

    I've tried all the combinations of Scene Depth node option and Screen Position node option but this is the best I get.

    I have a feeling something outside the shader is wrong possibly?
    I'm using URP.
    Any ideas appreciated, this is driving me nuts.

    (It's white as the problem lies before adding colour)
    Problem.png

    Shader.png
     
  2. CreepyD

    CreepyD

    Joined:
    Jun 9, 2019
    Posts:
    24
    Ok it if I move the view about, I noticed that the depth texture and actual world line up perfectly in the very bottom left corner of the view.
    Even if I ONLY have a Scene Depth node and nothing else, the depth is not being calculated behind the actual object, it's all offset to the lower left corner of the screen.
    It's looking almost like the Depth Texture that's being created is only the Lower left quarter of the screen?

    I literally can't find anyone with the problem anywhere, I hope someone has some idea..
     
    Last edited: Mar 23, 2023
  3. CreepyD

    CreepyD

    Joined:
    Jun 9, 2019
    Posts:
    24
    Ok I finally found the answer after days of searching and trial and error.
    I had to have another Screen Position node, split that and multiply the R and G by 0.5, then feed that (along with 0, 0 for B, A) into the Scene Depth UV input!
    There's nothing anywhere that says you have to do this that I could find, but it worked for me.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,336
    Because you shouldn't have to do that. This means there's a bug that should be reported.
     
  5. CreepyD

    CreepyD

    Joined:
    Jun 9, 2019
    Posts:
    24
    I'm thinking you're right, I've just found I have exactly the same problem using a Scene Color node.
    Here's what I have to add to make it actually line up with my geometry.
    Having trouble messing the with UV of Scene Color since I have to do this part as well lol.
    upload_2023-3-24_12-18-21.png

    Annoyingly I can't create a new project with URP and add Shader Graph to test fresh as my VPN is blocking the Package Manager now
     
  6. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    765
    What Unity (or URP) version are you using?

    That sounds like a render scale issue and should be fixed already.
     
  7. CreepyD

    CreepyD

    Joined:
    Jun 9, 2019
    Posts:
    24
    2022.1.18f1 at the moment.
    Ooooh it is caused by my Render Scale being set to 2 in my URP settings! (to eliminate flickering of my background stars).
    Is that a bug then that it doesn't affect things like Scene Color or Scene Depth?
    Should they also change in line with what I set the Render Scale to?
     
    wwWwwwW1 likes this.