Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Assets Fast Screen Space Decals — Deferred, Forward, LWRP, URP

Discussion in 'Works In Progress' started by drcrck, Mar 24, 2019.

  1. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    New thread: https://forum.unity.com/threads/released-ultimate-decals-deferred-forward-lwrp-urp.891343/

    I made a deferred decal system for my game, but it was too easy (like, put stuff to the gbuffer and let unity do the rest) so I made them work in forward as well:



    Full PBR
    Can be projected onto arbitrary opaque geometry
    Rendered with command buffers
    Lights processed in a single pass in a loop (instead of multiple passes)
    Without overlapping decals performance is similar to deferred
     
    Last edited: May 15, 2020
    qoockle, Lars-Steenhoff and GuitarBro like this.
  2. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    No decals:

    upload_2019-3-24_23-41-28.png

    Deferred:

    upload_2019-3-24_23-41-48.png

    Forward:

    upload_2019-3-24_23-42-2.png

    Lighting is still a bit wrong compared to deferred =\
     
    Last edited: Mar 24, 2019
    hjohnsen likes this.
  3. lucpham

    lucpham

    Joined:
    Feb 2, 2017
    Posts:
    4
    Does this support Lightweight Render Pipeline ?
     
    WILEz1975 likes this.
  4. raingame_

    raingame_

    Joined:
    Jan 15, 2019
    Posts:
    14
    Looks cool, man.

    I wonder, when should I use decals instead of materials?
     
  5. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    Not yet, but it will

    upload_2019-3-25_16-1-15.png

    Let's say you have a place like this — multiple meshes with different materials (or maybe even of different types, like terrain and buildings) and you want to put a decal like it's put on the pic.

    I don't know a way to do this without projected decals. You can create a mesh that fits this corner, but what if you want 100 decals like this? What if later you'll need to move them? Or change the map? Or maybe your map is procedurally generated at runtime and you want players to put decals at arbitrary locations?..
     
    Mark_01 and raingame_ like this.
  6. raingame_

    raingame_

    Joined:
    Jan 15, 2019
    Posts:
    14
    thanks! got it
     
  7. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    LWRP decals (WIP)

    upload_2019-3-26_0-0-34.png
     
    Malkyne and Elecman like this.
  8. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    GPU "raycasts" (actually, sampling depth at the given position and restoring normals using neighbor pixels)
    Works with cutout shaders and doesn't need colliders



    Though it works with skinned meshes as well, trying to simulate skinning by binding decals to nearest bones doesn't produce reliable results:



    It can be used for manually placed stuff:



    But for arbitrary runtime decals, I need something else
     
    zIyaGtVm, Mark_01 and DeadNinja like this.
  9. LordAnders

    LordAnders

    Joined:
    Apr 8, 2019
    Posts:
    1
    cool project! Can you explain how you made this work with LWRP?

    I've been looking for a few days now for a decal solution that will work with arbitrary surfaces in LWRP and this is the only solution I've seen demonstrated to work
     
  10. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    LWRP is the same as forward, and forward is the same as classic deferred decals with 3 additional steps:

    1. Reconstruct surface normals from depth (depthnormals texture is not available in LWRP and might be disabled in Forward. You won't get per-pixel normals with this method but it's better than nothing. If it's enabled, mixing both textures gives the best results).
    2. Before rendering decals, make a sorted list of lights affecting each decal. Currently I use compute shaders, can be also done on CPU (pretty easy for static decals/static lights, a bit slow for dynamic stuff), geometry shader (if used) or even vertex shader (with slight overhead of calculating the same stuff multiple times but still better than doing it on CPU).
    3. Instead of writing to GBuffer, calculate lighting for each fragment in a loop using lists you prepared in the previous step
    4. ?????
    5. PROFIT!
     
  11. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312


    Experimenting with decals on transparent surfaces
     
  12. lucpham

    lucpham

    Joined:
    Feb 2, 2017
    Posts:
    4
    what is the news for decal on LWRP ?
     
  13. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    Got mad at its bugs and postponed it :D
    I'll return to it soon
     
  14. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    upload_2019-4-11_20-9-22.png

    Another method of rendering decals on transparent objects: Decal Projector
    Works like unity built-in projectors, but faster and supports PBR
    Can be injected into deferred pipeline (without alpha blending) or rendered separately after transparent objects

    Note it's experimental and most likely won't be officially supported in the first version
     
    Jes28 and DrOcto like this.
  15. pixelR

    pixelR

    Joined:
    Sep 16, 2013
    Posts:
    51
    Still hoping to see someday decals coming for LWRP...

    /me keeps fingers crossed
     
  16. mikerz1985

    mikerz1985

    Joined:
    Oct 23, 2014
    Posts:
    75
    FWIW, I would immediately buy this once released.

    The Unity projectors are really useful if inefficient; my use of one is currently a barrier for me moving over to LWRP or HDRP.

    edit: Would really, really want a way to write a custom shader that allows controlling how the decal is rendered into the buffer/onto the screen. I want to adjust based on surface normal
     
    Last edited: Aug 30, 2019
  17. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    106
    That looks really good, Any news about ETA? thanks
     
  18. legoblaster1234

    legoblaster1234

    Joined:
    Aug 7, 2017
    Posts:
    26
    This thread is getting pretty old and seems to have died off. Has this been given up on or is there a usable version somewhere?
     
    mikerz1985 likes this.
  19. Luci4Games

    Luci4Games

    Joined:
    Nov 20, 2017
    Posts:
    3
    Hey, is this on the asset sore or on github?
     
  20. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    397
    it's unreleased.
     
  21. EHG_Unity

    EHG_Unity

    Joined:
    May 21, 2017
    Posts:
    20
    We need this. Drcrck are you going to resume this? Does anyone know of an alternative solution? Would anyone that understands how this was achieved be willing to create this if they were paid?
     
  22. VTIL_Papageorgiou

    VTIL_Papageorgiou

    Joined:
    Dec 14, 2017
    Posts:
    11
    Any update on this? It would really be appreciated
     
  23. Jribs

    Jribs

    Joined:
    Jun 10, 2014
    Posts:
    110
    Throwing my hat in on this one too. The LWRP support for skinned and non skinned meshes would be huge. I probably dont speak for everyone but I would pay a lot of money for this.
     
    Ghosthowl likes this.
  24. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    Hey everyone, I'm back. The asset will be released soon. Not sure about LWRP in the first version though, but maybe. More details coming soon!

    PS Skinned decal experiments:
     
  25. Ghosthowl

    Ghosthowl

    Joined:
    Feb 2, 2014
    Posts:
    186
    I think it would be wise for you to release this with support for the LWRP on the first version. LWRP right now has no decal or projector support and many developers including me would pay a high price for it. I'd imagine most of your sales would come from those of us on the LWRP in need of a solution to this matter.
     
    Jribs likes this.
  26. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    Ok, made it work with LWRP, will publish the first version soon
     
    zIyaGtVm, Ghosthowl, L3AD and 2 others like this.
  27. VTIL_Papageorgiou

    VTIL_Papageorgiou

    Joined:
    Dec 14, 2017
    Posts:
    11
    Invertex likes this.
  28. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    171
    any updates??
     
  29. Anisoft

    Anisoft

    Joined:
    Jul 5, 2013
    Posts:
    109
    Is this still being worked on?
     
    Korimaru88 likes this.
  30. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
    There were some unexpected delays but I'm back and it will be released soon with Deferred/Forward/LWRP/URP + Single Pass support
     
  31. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
  32. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    312
  33. vuxuanhung

    vuxuanhung

    Joined:
    Jan 23, 2019
    Posts:
    2
    I really care about this plugin,
    Does this plugin work fine on Android and IOS?
     
    zIyaGtVm likes this.
unityunity