Closed riina closed 2 years ago
Thanks for detailed information. We'll look into this.
Thank you for your research for helping to solve the problem!
We will apply your feedbacks to Unity toon shader at first as we need to follow our process. Then apply them to Universal Toon Shader in this repo.
Hi, we have just released 2.5.0 adapting your patch. Just one thing we mended is the supporting URP version as the doc says it was since 10.0.x.
We really apricate your contribution.
Starting from version 10.0.x, URP can generate a normal texture called _CameraNormalsTexture. To render to this texture in your custom shader, add a Pass with the name DepthNormals. For example, see the implementation in Lit.shader
This is in reference to #100, as I tried looking at the problem myself and decided to make a separate issue if this turns out to be something different. I tried creating "3D (URP) Core" template in 2021.2.11f1, and in default settings, according to the frame debugger, the depth information appears to come from using shader's DepthNormals pass. The UTS2 shader does not appear to have this pass, and thus cannot provide depth information under this default configuration. I do not know how to get SRP to use DepthOnly pass instead. This issue might be worked around if there actually is some way to do that.
As an example, here the spheres are using a basic UTS2 material and other things are default Lit. Note that something with the Bokeh postprocessing or maybe SSAO appears slightly wrong, you can see the edge of the cube in the back, when it should be obscured by the sphere. The depth texture used by Bokeh does not have a correct depth texture with the UTS2 spheres.
I tried adding DepthNormals pass myself to the shader, and it appears to at least provide the right depth information. Weirdness around edges is gone. UTS2 spheres show up correctly in depth texture.
Changes made: https://github.com/unity3d-jp/UnityChanToonShaderVer2_Project/compare/release/urp/2.4.0...riina:urp-depth-normals?expand=1
The addition just uses the basic DepthNormalsPass.hlsl in the URP library. Because of this, standard normals calculation is done, and I do not know if special treatment of normals would be desired for this shader.
Also, this is only available in URP 10.1+ (as far as I know) so adding this probably triggers warnings on lower URP that fragment/vertex for this pass are missing (I did not define alternatives so the whole HLSL is just guarded in version check).
Original sample (for git tag
urp-2.4.0
)files_orig.zip
Modified sample (just changes UPM link to
https://github.com/riina/UnityChanToonShaderVer2_Project.git#96cb6b65f85d8cdbbba0f2e06500bdc5c65d2cb8
)files_mod.zip