Depth output for shader graph -> PDO(Pixel Depth Offset) -> terrain blending -> billboard shadows

Hi,

I think a lot of people would appreciate having the possibility to add the SV_Depth output in shader graph for all render pipelines. (Like HDRP “Depth Offset output” but with no dependencies.)

The SV_Depth is just an additional target in the fragment shader which will overwrite the depth information of the rendered object.
Normally in a custom shader you just define it as an output, so in shader graph this could be an option or could be enabled by a local keyword definition.

Here a possible use cases:

See how it’s implemented in Unreal, very simple, just an input value that can be overwritten:

These are only 2d textures, with SV_Depth you can make them look 3d:

More infos about this see here:

Please Unity add this feature to all render targets in the fragment shader of shader graph! Thx!

A totally needed feature!

Thanks!
Everyone who needs this feature should post something here to keep this feature request visible for Unity Devs!
Thank you!

+1

Yes, needed

Needed, i’m sick of looking around for alternatives.

Unless I missed something, this feature already exists in HDRP, right?

So is this thread just about adding the same thing to URP, or is there more to it?

Hi Ben,
looking into the gen-shadergraph-shader it seems to me that even in HDRP the Depth Offset value is not passed direct to SV_Depth it gets a bit of extra calculations that might alter the result,but…



…I think it’s ok that the DepthOffset is multiplied with -V, I will do some tests if I find any use-cases that don’t work with this method.
Back to your question, yes URP seems to be missing that feature and as some of my users still use builtin it might be helpful to have that too, but URP would be more important! Thanks!

Best regards,
Chris

Edit: After further testing it seems to be an issue to have a Depth Offset and not a direct Depth output, not sure how to fix this easily… the offset just gets added on top of the geometry, but in the imposter case you want to replace the depth… maybe someone has figured that out? Multiplying with a higher negative number seems to get something, but I didn’t figure this out yet, maybe need to reverse the whole deviceDepth chain…

After a few tests outDepth = -mul(float4(surfacePos, 1.0), UNITY_MATRIX_V).z; seems to do the trick. (You could put that into a custom function.) However, in my test the imposter quad still affects the shadows, maybe need to render the quad differently…

Edit: After a few more tests I found out that this only is important for my current shader test, normally you don’t need that, so you can directly use DepthOffset with a normal Camera depth buffer and it works!

And again @BenCloward and @ : Please add this feature to URP and Builtin in the shadergraph, thanks!

Amplify Shader Editor already supports this feature for URP and built-in shaders, I don’t see a reason why this could not be added to ShaderGraph as well (for URP/built-in)

+1 to the feature

Plus one

This is very much needed in Built-in and URP.

Just curious, if this is working in Amplify Shaders, couldn’t this be added to a custom function? or where is the roadblock on the unity side?

Why we didn’t have this feature in URP? I am very confused

Same why there is still no tessellation i suppose, which is no reason at all :slight_smile:

Besides maybe not be a priority for Unity

We really need this for URP! @Unity

We absolutely need this in URP asap!!!

Also running into the PDO limitation when trying to recreate this effect in URP using Shader Graph: Tree pixel depth offset in Tiny Glade.
It would help tremendously if PDO is supported in URP Shader Graph.