Scene depth texture texel size in shadergraph / URP?

Hi !
For my URP project, I need to access the texel size of the camera’s depth texture in shadergraph.

Given access to the textures themselves, using the “Texture size” node would seem to be a straightforward solution.

However, since both the scene Depth and Color textures are hidden behind nodes that handle the sampling internally, and output only the data itself… I’m not sure how I should go about accessing the information I need.

Any pointer would be greatly appreciated !

Monday morning bump :slight_smile:
Has no one had any issue with distorted refractions in URP / Shadergraph ? I’ve been trying to adjust distorted UVs by aligning texel samples the way Jasper Flick describes in section 3.3 of his excellent article about water shaders, Looking Through Water
This was easy to achieve using Amplify Shader Editor - not so much with Shadergraph.

Hi, to get the scene color/depth texel size, you can use a custom function node.

First you need to declare a global vector4 property named _TextureReferenceName_TexelSize:

Then the custom function node:

Width = _CameraDepthTexture_TexelSize.z;

Height = _CameraDepthTexture_TexelSize.w;

OneOverWidth = _CameraDepthTexture_TexelSize.x;

OneOverHeight = _CameraDepthTexture_TexelSize.y;

For scene color, the texture reference name is _CameraOpaqueTexture.

1 Like

Oooh lovely, thank you so much !

1 Like