Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Feature Request URP Decals on transparent surfaces

Discussion in 'Universal Render Pipeline' started by AdamLacko, Apr 27, 2022.

  1. AdamLacko

    AdamLacko

    Joined:
    Oct 10, 2017
    Posts:
    41
    I'm trying to figure out a way to force Unity's URP Decal Projector to also influence transparent objects.

    I do know that URP Decal system does not support transparency, most likely due to transparent geometry not writing into depth buffer.
    However, I noticed a few new options in URP that I hoped could help "hack" my way around this limitation. For instance, URP Shade Graph provides a way to force writing into depth buffer, even for transparent shaders (confirmed with Frame Debugger). In the latest URP (14.0), there's also an option in the renderer asset to copy scene depth after transparents (instead of opaques).

    I have two questions:

    1) Does Unity plan on supporting decals on transparent surfaces in the future?

    2) Isn't there at least a hacky way to overcome this limitation of the URP Decals? Custom render features, material render order, shaders, anything.
     
    Lampys and pixelR like this.
  2. AdamLacko

    AdamLacko

    Joined:
    Oct 10, 2017
    Posts:
    41
    Upon further trial-and-error experimenting, I suppose I found a solution. When using Screen Space technique for Decals, I managed to get the transparent objects to be influenced by the decals simply by changing the render event of DecalScreenSpaceRenderPass, in the URP package source code. That did the trick.

    I don't know if there are any possible side effects of this, but for my use-case (projecting Fog Of War texture over environment), I found none. Transparent objects are influenced by the projected fog, and there is no sorting issue (which I have experienced before when trying to change material render order and use custom projector shaders).



    However, since I created this thread, I'd like to point out another possible feature request I found after I managed to get this to work.

    Screen space decal shader pass produces a different blending than DBuffer (visually, despite having the same blending setup in code). I've been noticing this since the Decal system release and that's why I tended to avoid Screen space decals. Now that the Screen Space decals allowed me to use transparency as well, I went ahead and manually changed the blending setup in the generated code from the Shader Graph's Decal graph to get the same visual results as in DBuffer decals.

    So I think it could be useful to have the blending options exposed in the Decal master node settings, just like in other graphs.
     
    Last edited: Apr 28, 2022
    amit-chai and Binary42 like this.
  3. amit-chai

    amit-chai

    Joined:
    Jul 2, 2012
    Posts:
    80
    Hi! please can you explain how you did it? "changing the render event of DecalScreenSpaceRenderPass, in the URP package source code." what does it even mean? how you can access the code? does this mean you set "Lit" to act as a decal material?
     
  4. amit-chai

    amit-chai

    Joined:
    Jul 2, 2012
    Posts:
    80
    OK so I've found the DecalScreenSpaceRenderPass and changed the script, but not sure how to use your example. looks like you are settings a Lit material, and not a Decal material. please can you explain?