Unity Products:Amplify Shader Editor/Screen Depth

From Amplify Creations Wiki
Revision as of 00:06, 2 December 2023 by AmplifyWiki (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Back to Node List

Screen Depth Node

The Screen Depth node outputs the screen depth by reading the Depth Buffer at the current Screen Position or at a custom screen position if connected to the Pos input port. The result can be either presented on a linear [0,1] range or in its unscaled real distance value in View Space coordinates by selecting the View Space accordingly.
NOTE 1: If the shader needs to access the depth buffer contents behind the object it is assigned then it should not be written into the depth buffer. For that a Render Queue must be set to be greater or equal to Transparent.
Please check Unity official documentation on Render Queues and Depth Textures for further information.
NOTE 2: Convert To Linear toggle must be turned off if working with an orthographic camera, as the values written/read on the depth buffer are already on a linear scale.

Nodes used: Screen Depth

Node Parameter Description Default Value
View Space Defines how the screen depth value is to be presented
  • Eye Space: Real distance value in View Space
  • 0-1 Space: Distance value in a linear [0,1] range where 0 is near and 1 is far.
Eye Space
Convert To Linear If toggled on, converts fetched depth value from a logarithmic to a linear scale. Should only be active on Perspective projection type. True


Input Port Description Type
Pos Screen space position to fetch depth value. Current screen position is used by default if this port is left unconnected. Float4


Back to Node List