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:
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!
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)
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.