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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

[RELEASED] Decalicious – Deferred Decal System

Discussion in 'Assets and Asset Store' started by Daerst, Nov 21, 2016.

  1. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,519
    Also, thanks for info on the terrain workaround! :D

    You could probably work around this by modifying MicroSplat's internal source shader files rather than the generated shaders. From memory they're included as text files. I've tweaked them before, but don't remember their names and am not at my computer.
     
  2. SaltyMaia

    SaltyMaia

    Joined:
    Feb 9, 2017
    Posts:
    1
    Hi, I'm having some troubles with getting the decals to work.
    • Deferred rendering
    • Subtractive GI
    • One Mixed light in my scene (Sun source)
    Basically after having baked the lightmaps onto my scene, the decals only show up if I tag my Mixed directional light to Not Important rendering. This doesn't work for me since it goes against the purpose of subtractive GI (by labelling the light Not Important, it will shade objects per-vertex, meaning my dynamic objects can't cast proper shadows onto my static terrain meshes).

    I'm using actual meshes here, not the unity terrain. I have a deferred camera rendering, and the decals show up if they are placed on an object that doesn't have lightmaps. So for instance, with the light tagged Important I can't see the decals on my meshes. But if I duplicate a mesh, then that newly-created mesh can receive decals because it doesn't have a lightmap

    Any help would be very much appreciated, this is the final proof of tech I need in the project
     
  3. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,519
    Just confirming that changing the angle limit works perfectly. Thanks!
     
  4. RickF

    RickF

    Joined:
    Sep 12, 2012
    Posts:
    33
    An 'exclude' would be an awesome option as well. Great work on this.
     
  5. virtrodev

    virtrodev

    Joined:
    Sep 9, 2017
    Posts:
    3
    Hello,
    Does decalicious asset allow the decal to be automatically updated if the mesh of the texture it is being overlaid on top of moves/deformed during run-time of a scene?
    Thanks!
     
  6. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,433
    It'll behave kind of like a flashlight projecting the decal onto the mesh.So probably not in the way that you would want it to. This is a limitation of the deferred decal technique in general, not something that could be fixed. If you want things like damage decals on deforming characters, you need to look for other techniques.
     
  7. Radu392

    Radu392

    Joined:
    Jan 6, 2016
    Posts:
    210
    I'm using CTS to render the terrain and the cts shaders don't have anything similar to what you said on step 4 and 5. Can't find anything related to emission or gbuffer in them. Any other ideas? Sadly my knowledge of shaders is almost zero.

    Edit: I looked at the code a bit to see how and why it only limits to mesh renderers. It can only do mesh renderers because it needs access to a mesh, but you can't access the vertices of a terrain object. My question is, would it be possible to access the mesh of the terrain at runtime, using say the 'Terrain to Mesh' asset, and limit to the terrain that way?
     
    Last edited: Jul 9, 2019
  8. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    Does this allow for projecting decals to specific Unity layers? Say, I have a decal I want only projected onto a few certain layers, and other decals that I only want on a different bunch of layers? I looked at the demo but it's pretty impossible to tell, from that.

    Been looking for a replacement for the deprecated Dynamic Decals for months.
     
  9. Censureret

    Censureret

    Joined:
    Jan 3, 2017
    Posts:
    361
    Hello. Does this asset work with unity HDRP?
     
  10. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    Two weeks since I asked a question about this, no reply.

    If pre-sale support is non-existent, what hope is there once I've paid?
     
  11. RickF

    RickF

    Joined:
    Sep 12, 2012
    Posts:
    33
    I'm getting this error when using decalicious in conjunction with objects using 'calm water' shaders and their 'mirror reflection' script added to the objects.
    ------
    MissingComponentException: There is no 'Camera' attached to the "m_waterDisc1200_ReflectionSceneCamera" game object, but a script is trying to access it.
    You probably need to add a Camera to the game object "m_waterDisc1200_ReflectionSceneCamera". Or your script needs to check if the component is attached before using it.
    ThreeEyedGames.DecaliciousRenderer.OnPreRender () (at Assets/DecaliciousUpload/Scripts/DecaliciousRenderer.cs:102)
    UnityEngine.Camera:Render()
    CalmWater.MirrorReflection:RenderReflectionFor(Camera, Camera) (at Assets/Calm Water/Scripts/MirrorReflection.cs:252)
    CalmWater.MirrorReflection:RenderHelpCameras(Camera) (at Assets/Calm Water/Scripts/MirrorReflection.cs:138)
    CalmWater.MirrorReflection:WaterTileBeingRendered(Transform, Camera) (at Assets/Calm Water/Scripts/MirrorReflection.cs:155)
    CalmWater.MirrorReflection:OnWillRenderObject() (at Assets/Calm Water/Scripts/MirrorReflection.cs:166)
    ------

    So this object "m_waterDisc1200_ReflectionSceneCamera" doesn't actually exist in the hierarchy. I believe its created at runtime(?) by the 'mirror reflection' script and used for reflections on the water surface.

    Now i don't really care if the water actually reflects the decals, but this conflict is critical and not allowing the game to run. Is there anyway to kill this flag? or workaround the issue using layers?
     
  12. RickF

    RickF

    Joined:
    Sep 12, 2012
    Posts:
    33
    attempting to bump the above,,, is there a way to stop decalicious from looking for this camera?
     
  13. RickF

    RickF

    Joined:
    Sep 12, 2012
    Posts:
    33
    I don't think it does. You can set a decal to affect only a single mesh, or all meshes.
     
  14. Wikzo-DK

    Wikzo-DK

    Joined:
    Sep 6, 2012
    Posts:
    83
    Hello. We have noticed that Decal.OnWillRenderObject() allocates about 4.6k memory every frame, which triggers the garbage collection quite often. Is that normal?

    Using Unity 2019.2.1 with deferred rendering.
     
  15. Manul_

    Manul_

    Joined:
    Jul 28, 2015
    Posts:
    20
    Yeah, that happens in my project, too. A part of the garbage is that SortedDictionary is used to enable the render order for decals. And when iterating over this dictionary garbage is created (for GetEnumerator()). I'm not sure how to get rid of this.
    Another part is that this SortedDictionary contains another Dictionary that holds all the decals that are rendered with a specific Material in this frame (the decals are in a HashSet). This Dictionary is cleared every frame. And therfore every frame, when a Decal is rendered it will put itself back into this structure and lead to generation of new HashSets and the expanding of these HashSets (if you have many Decals with the same material). New HashSets and expanding HashSets generates garbage.
    I fixed this by not clearing the Dictionary in the SortedDictionary, but only the HashSet that contains the Decals that should be rendered in this frame. This way no new HashSet has to be created and it normally does not have to expand in size. But be carefull if you generate new decal Materials over time in your scene, because with this implementation the Dictionary would keep getting bigger and bigger if you don't clear it.
    I did this by changing
    Code (CSharp):
    1. var decalEnum = _deferredDecals.GetEnumerator();
    2.     while (decalEnum.MoveNext())
    3.         decalEnum.Current.Value.Clear();
    to
    Code (CSharp):
    1. if(_deferredDecals.Count > 0) {
    2.     foreach (var decalType in _deferredDecals) {
    3.         foreach (var decalSet in decalType.Value.Values)
    4.             decalSet.Clear();
    5.     }
    6. }
    in DecaliciousRenderer.cs.
    (and the same thing for _unlitDecals)
    This removed a huge part of garbage genration for me.

    Greetings Manuel
     
    DwinTeimlon likes this.
  16. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    So, is this project dead? Creator doesn't seem to respond to anything.
     
    DwinTeimlon likes this.
  17. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    294
    Seems that way for most assets on the store these days. I've spent a good amount of money in the past year or so and most of it has become deprecated. :rolleyes:
     
    DwinTeimlon likes this.
  18. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    296
    I have found that
    decalEnum.Dispose()
    was never called after
    GetEnumerator()
    which actually causes a memory leak. I found no calling of
    Dispose()
    a single time in the code oO.

    Also he does not preHash his shader properties which is quite ineffecient.

    I have replaced all the strings where he sets shader properties
    Code (CSharp):
    1.         private static readonly int MASK_MULTIPLIER = Shader.PropertyToID("_MaskMultiplier");
    2.         private static readonly int LIMIT_TO = Shader.PropertyToID("_LimitTo");
    3.         private static readonly int UNITY_SH_AR = Shader.PropertyToID("unity_SHAr");
    4.         private static readonly int UNITY_SH_AG = Shader.PropertyToID("unity_SHAg");
    5.         private static readonly int UNITY_SH_AB = Shader.PropertyToID("unity_SHAb");
    6.         private static readonly int UNITY_SH_BR = Shader.PropertyToID("unity_SHBr");
    7.         private static readonly int UNITY_SH_BG = Shader.PropertyToID("unity_SHBg");
    8.         private static readonly int UNITY_SH_BB = Shader.PropertyToID("unity_SHBb");
    9.         private static readonly int UNITY_SHC = Shader.PropertyToID("unity_SHC");
    10.  
     
    Last edited: Apr 8, 2020
    Manul_ likes this.
  19. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    161
    This decal package is working great for me, however when i try to place decals on my R.A.M splines then they do not appear. I have tried changing the rendering order of the road surface material to be all kinds of numbers but no luck. I am wanting to use decals for road markings, arrows, lines etc. These decals work amazingly well on terrain and solid assits, but no luck with RAM splines. has anyone got any idea what is going on here?
     
  20. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    296
    Screenshots might help, also what is a RAM spline?
     
  21. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    161

    Attached Files:

  22. Rob78

    Rob78

    Joined:
    Jul 8, 2013
    Posts:
    72
    Hey this looks great! I wonder how it compares with Unreal Deferred decal system, I had a go at the demo but it looks a little dated and looked like the decals didn't blend together so well and instead kind of replaced the effect underneath/overlapping. I could be wrong. I'll check out the latest videos etc..any update to the demo?
     
  23. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    296
    Unfortunatley I cannot help here, don't use/own that plugin. I would talk to the guy doing the RAM river plugins what might cause this, as the guy doing this plugin doesn't seem to care anymore.
     
    Last edited: Dec 6, 2019
  24. JoeriCG

    JoeriCG

    Joined:
    Apr 25, 2018
    Posts:
    17
    We have a few shaders that this asset isn't working on, mainly the Toon Colors Pro asset pack one at the moment. I'm wondering what do I need to adjust in the shader code to allow the decals to draw on them?

    Edit: seems Toon Colors Pro only supports forward rendering so that explains that.
     
    Last edited: Dec 9, 2019
  25. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Awesome decal solution with projection. I have just one trouble, it does not work on the Microsplat terrain. I don't have the newest version, so I asking you, should it work on Microsplat terrain?
     
  26. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    That depends on whether Microsplat uses a deferred shader. If so, Decalicious should work, but we can't guarantee compabitlity with all third party assets.
     
  27. jamespaterson

    jamespaterson

    Joined:
    Jun 19, 2018
    Posts:
    391
    for what its worth in my WIP game I am using Microsplat and Decalicious together no problem
     
    Daerst likes this.
  28. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    That's great news, thanks!
     
  29. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Thanks, it works with Microsplat!
     
    Daerst and jamespaterson like this.
  30. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Hello,

    now I have an issue with the decal system. I want to limit the decal just for the terrain, but if I do so, the decal is not visible. I have unity 2018. It works on meshes, but not on the terrain. The Unity projection shader have a Layer mask that can be used to do such things. Maybe i miss something, is there a way to just limit the projection to the terrain?
     
  31. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    161
    Is there a way to limit what assets a decal will appear on? lets say i am using some decals on my terrain and I have a player walk through the decal projection box. I'd like a way to have it so that it does not appear on the player. Or in other instances it could be a decal on a player that might walk past a tree or a wall and the decal may project on the tree and wall if it's extending past the bounds of the player.
     
  32. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    This decal system allows you to limit the decal to a GameObject, but you cannot limit it for just the terrain. The another decal system in the asset store supports limiting on the terrain, but the decal system works then only with layer. Using both decal system is maybe a good idea, I use both.
     
    Daerst likes this.
  33. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Hello guys, i am having an issue with loading a scene from an asset bundle in run time in the game, and the decalicious system just don't work for some reason.

    I can see the decals all fine in the Unity Editor, and if i load this scene from the normal game (build) process it works fine.

    Just don't seem to work with asset bundle.

    Any tips ?
     
  34. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    So you have a scene with a Decal in it. If you run that scene in Editor or include it in a build, everything's fine. If you put the scene + Decal material + textures in an asset bundle and load that at runtime, the decals don't show. Correct?

    Are all the Decalicious scripts and shaders in your base game (not in the bundle)?
     
  35. Jakub-Pilar

    Jakub-Pilar

    Joined:
    May 18, 2015
    Posts:
    48
    Hi,

    I have just triangle image with transparent background, but in editor/game it has visible outlines, why?

    Is there some settings I am missing to set?



    Thanks in advance,
    Jakub
     
  36. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Could you try setting your texture's wrap mode to clamp instead or repeat?
     
    Jakub-Pilar likes this.
  37. Jakub-Pilar

    Jakub-Pilar

    Joined:
    May 18, 2015
    Posts:
    48
    Thanks! It helped!
    Jakub
     
  38. Jakub-Pilar

    Jakub-Pilar

    Joined:
    May 18, 2015
    Posts:
    48
  39. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Not baking to meshes is specifically the point of deferred decals. I'm afraid you have to use a different decal solution, with an altogether different approach for that.

    Decalicious should work fine with default Unity lightmaps. I haven't used Bakery, so I'm not sure what it's doing and where it is storing its lighting info.
     
    Jakub-Pilar likes this.
  40. ckreusche

    ckreusche

    Joined:
    Oct 10, 2020
    Posts:
    1
    Hello!
    Great plugin, but we are having a problem with it unfortunately.
    The decals are not rendering at all on PS4 and XboxOne.
    Could you please help us getting this to work? Is this a known issue?

    The Unity version we are using is 2018.4.24f1.
    It looks fine in the Editor, but when playing on console the decals don't render at all.

    With kind regards,
    Christoph Kreusche
     
  41. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Wrote you an e-mail, let's try to find a fix together :)
     
  42. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    818
    upload_2020-10-15_12-45-30.png

    We're not seeing any lights being recieved. How can i debug this?
     
  43. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Using RenderDoc or Unity's Frame Debugger.
     
  44. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    818
    I have checked it with that, but i dont see anything out of the ordinary. I see that Decal.cs purposefully disables recieve shadows in the Awake, could that be it?

    Can you test and confirm that lightmaps are indeed supported?
     
  45. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Sure. In the meantime, please let me know what you've tried so far and give some explanations regarding the screenshot you posted. What am I seeing?
     
  46. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    I investigated a litte. Indeed, Decalicious has its share of problems with lightmaps. To get it working in the current version, two things need to be done:
    • Comment out line 86 in DecaliciousDeferredDecal.shader, to avoid lightmaps being overwritten by (empty) light probes
    • Set the Decal's Albedo blend mode to Multiply.
    To explain: The Decal draws to Albedo and Emission buffer (which includes Reflection Probes, Light Probes and Light Maps in Unity) in the same pass and can only use the same blend mode for both, currently. Reflections come in later, so they are not a problem. Light Probes are samples by the Decal itself (if enabled). Lightmaps however are drawn to the same buffer, directly with the geometry in a 'forward' fashion, so I'm not allowed to overwrite them (which I currently do, mea culpa, unless the blend mode is set to Multiply).

    Being forced to use the Multiply blend mode of course limits the appplicability of the Decals. If it doesn't work in your particular case, I'm happy to grant a refund or assist you in modifying the asset to work to your needs.

    upload_2020-10-16_8-32-52.png
     

    Attached Files:

    TJHeuvel-net likes this.
  47. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    818
    Thank you will check!

    We already have some changes in place anyway, for our custom dont-render-decal-map using the deferred normal alpha. We have been using the plugin for a long time, and are just now experimenting with lightmaps.
     
    Daerst likes this.
  48. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    818
    That did do the trick, thank you kindly.

    I did notice that multi-editing isnt supported for materials, the custom editor only sets properties for the first selected material. I made a quick local change to iterate through all the selected materials, otherwise changing the blending mode would have taken me hours on all materials.
     
    Last edited: Oct 20, 2020
    Daerst likes this.
  49. snaksan_

    snaksan_

    Joined:
    Sep 18, 2018
    Posts:
    6
    Hello!
    Do you plan to extend "LimitTo" function with adding exclusion by unity layers?
     
  50. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Hey snaksan, we don't plan to integrate this feature anytime soon. Unfortunately, there is pretty much 0 time for us to work on the asset these days.