Cyanilux / URP_GrassGeometryShader

Example of a Grass Geometry Shader for Unity, Universal Render Pipeline. Based on https://github.com/IronWarrior/UnityGrassGeometryShader
MIT License
65 stars 14 forks source link

DepthBuffer? #3

Open SiriusRU opened 3 years ago

SiriusRU commented 3 years ago

Hi. I use DepthBuffer for some post-processing effects and as far as I understand current shader implementation does not fully write anything there, although in the shader itself I see a "DepthOnly" pass:

image image

Is there any way to fix that?

SiriusRU commented 3 years ago

Hmm. After some research seems like issue was somehow caused by URP ScreenSpaceAmbientOcclusion RenderFeature set to DepthNormal mode. When set to just Depth or disabled - there is nothing wrong with Depth. So issue on Unity side I guess.

Cyanilux commented 3 years ago

URP10+ introduces an additional DepthNormals Pass/LightMode tag which, looking at the ForwardRenderer & DepthNormalOnlyPass code, it appears this pass is required in the shader to support rendering the depth & normals textures during the DepthNormal mode for the ScreenSpaceAmbientOcclusion feature.

Unlike the DepthOnly which returns 0, as the DepthNormals name suggests it's supposed to calculate normals and output them in the fragment too. e.g. The Lit.shader uses this in v10.3.1. (Of note, it's also changed again in the master branch (v11?) due to added deferred support and apparently it stays in world space rather than converting to view??? I guess for now this can be ignored since that version isn't published but wow that's annoying...)

Also if I recall correctly the normal isn't completely accurate to the grass blade direction. The blades all have normals facing directly upwards (/original vertex normal direction?) so that the lighting behaves nicely. Unsure if that'll be a problem but something to be aware of.

I might look into this further at some point and update this GrassGeometryShader example, but until then I'll reopen the issue so it'll be easier for others to see it if they are having the same problem. Thanks!