Unity-Technologies/com.unity.toonshader

[URP] Decal with DBuffer mode is not supported

Closed this issue ยท 19 comments

2A5F commented
[URP] Decal with DBuffer mode is not supported
2A5F commented

And does not support Rendering Layers

+1

@H3idi-X
May I create a PR?

Plans

  • add pragma to UniversalForward pass

#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3

  • add ApplyDecalToSurfaceData() to frag()

#ifdef _DBUFFER
ApplyDecalToSurfaceData(input.positionCS, surfaceData, inputData);
#endif

Implementation of "URP/Lit"

Hi, thanks for reports and suggestions.
But, as far as, we see, the decal feature is solely for Shader Graph and UTS is not compatible with Shader Graph.

Is this an issue that can be raised internally? It certainly doesn't feel normal for UTS, an official shader package by Unity, to not be compatible with a commonly used feature in URP: Decals with Rendering Layers.

@H3idi-X
Thanks for the quick reply!
As far as I know, I am aware that URP supports Decal even for non-ShaderGraph shaders.
For example, the built-in "Universal Render Pipeline/Lit".
In addition, I have tried to add Decal feature to UTS in my local repository and it seems to work well.
Is there a problem specific to UTS?

I am sorry I did not know how to set decal with Universl Render Pipeline/Lit. Could you show me the link or something explaing how to apply decal with Universl Render Pipeline/Lit?

@H3idi-X
https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@14.0/manual/renderer-feature-decal.html
I think you can confirm this by following this link.
By the way, the environment I checked is Unity2022.3.5f1.
Perhaps the version may have something to do with it.

Thanks! but, the link is what I was talking about. It explains how to apply decal using Shader Graph and we haven't found ways how to apply decal without Shader Graph. So, if you know how to apply decal with Univesal Render Pipeline/Lit shader UI, could you tell me about it? We are very small team and it is hard for us to give the first priority to UTS.

We're on Unity 2022 LTS as well and the way you can try this is straight out of the box:

  • Open Unity with the URP active
  • Add Decals to the Renderer and set it to use Render Layers
  • Create any simple mesh geometry (cube, sphere etc) and check it has the default lit material applied
  • Create a decal renderer & decal material using the default decal shader.
  • Place decal renderer to project on your simple mesh geometry.

You will see the decal render just fine. If you swap the standard lit material on the mesh with the toon shader it will not work.

@Hum9183 Thank you for your proposal, it would be greatly appreciated if you could submit a PR.
We are currently short of human resources for this project.

Thanks for the PR!. We tested the PR and found some compilation errors when using 2020.3. Maybe we can fix them.

I see!
Maybe decal feature itself is not supported in 2020.3.

@H3idi-X
Hi!
I was lightly testing with unity2021.2,
I confirmed that adding โ€#if UNITY_VERSION >= 202120โ€ to ApplyDecalToSurfaceDataUTS() eliminates the error

In UniversalToonBody.hlsl

+ #if UNITY_VERSION >= 202120
    void ApplyDecalToSurfaceDataUTS(float4 positionCS, inout float3 albedo, inout SurfaceData surfaceData, inout float3 normalWS)
    {
        #ifdef _SPECULAR_SETUP
            half metallic = 0;
            ApplyDecal(positionCS,
                albedo,
                surfaceData.specular,
                normalWS,
                metallic,
                surfaceData.occlusion,
                surfaceData.smoothness);
        #else
            half3 specular = 0;
            ApplyDecal(positionCS,
                albedo,
                specular,
                normalWS,
                surfaceData.metallic,
                surfaceData.occlusion,
                surfaceData.smoothness);
        #endif
    }
+ #endif

2021.2.0 looks right version when URP started to support DECAL.

We merged your PR to the development branch and started preparation for releaseing the next version.
Thank you very much!. @Hum9183

@H3idi-X
Thank you for the merge!

I see that there are other requests for implementation of a light layers in this issue, so I will create a separate new issue for the light layer issue, if that is OK with you?

@Hum9183 That would be great if you submit a PR for light layers. We really appreciate for the one.

@H3idi-X
Now that 0.9.6 has been released, would you please close the issue if you don't mind?