#Depth Buffer changes when rotating camera

1 messages · Page 1 of 1 (latest)

delicate hound
#

Hi, i'm trying to make my own fog with the depth buffer, but when i rotate the camera (simply rotate, not move) the "transition line" that i make using a clamp and smoothing is rotate along with the camera.

I'm using a shader graph with the basic saturate(SceneDepth - ScreenPos.a/depth) to get a 0-1 value

Scene depth is set to Eye and Screen Position to Raw

#

In the screenshot i simply rotated the camera, and doing so allows me to see much more or less of an object, which is not the desired effect

severe cedar
#

It's expected that the transition line would move if the camera rotates, as the camera plane is moving so the depth changes. The built-in fog should have the same issue iirc.
The usual way to prevent that would be to instead reconstruct the world space positions from the depth and use Distance to camera position.
(If it's a Fullscreen Graph the Position node does the reconstruct calculation for you)

delicate hound
#

it is a fullscreen graph

#

So i should get the Position node, set it to view and use its -z ?

#

oop nvm

#

figured it out !!!

#

thanks !!

#

that's actually easy

#

thanks man

delicate hound
#

Update; I also need it for an object shader (water shader depth), but I can't figure it out

#

This is the original graph, but it has the same issue, and it's not a fullscreen graph

severe cedar
delicate hound
#

thank you

#

its very weird

#

This was the rest of my code that i used to affect the color of the depth

#

and plugging this in instead of my old depth calculation, it breaks in unexpected ways

#

The closer i am to the water, the brighter everything inside it is

severe cedar
#

Try View Vector node instead of View Direction

delicate hound
#

i love you man

#

thank you