Search Unity

Easy Decal - Decals everywhere

Discussion in 'Assets and Asset Store' started by Sycoforge, Oct 28, 2014.

  1. akareactor

    akareactor

    Joined:
    Apr 6, 2015
    Posts:
    108
    I believe this is a limited solution. Do not wish to strictly rely on its hardness. If the pool cannot return an decal for his internal reasons - let it be so. In this case, I get more choice due to optimization.
     
  2. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    The instantiation injection has been designed for a replacement to Unity's internal Instantiation method, thus nulls are not supported. This is a design restriction. What you can do though, is to create your own ProjectAt() method which handles nulls.

    Please find below the source of how the Easy Decal plugin implemented those methods.

    Code (CSharp):
    1.         private static EasyDecal ProjectInternal(GameObject decalPrefab, GameObject parent, Vector3 position, Quaternion rotation, Vector3 scale)
    2.         {
    3.             EasyDecal decal = decalPrefab.GetComponent<EasyDecal>();
    4.  
    5.             if (decal == null)
    6.             {
    7.                 throw new Exception("The prefab you want to instantiate has no 'EasyDecal' script appended.");
    8.             }
    9.  
    10.             if (parent != null && !ContainsLayer(decal.Mask, parent.layer))
    11.             {
    12.                 return null;
    13.             }
    14.  
    15.             float yScale = decal.Technique == ProjectionTechnique.Plane ? 1f : scale.y;
    16.  
    17.             EasyDecal clone = null;
    18.  
    19.             if (Instantiation != null)
    20.             {
    21.                 // Insert your pool logic here
    22.                 clone = Instantiation(decalPrefab, parent, position, rotation);
    23.  
    24.                 if(clone == null)
    25.                 {
    26.                     Debug.LogError("The assigned instantiation method returned a null object.");
    27.                 }
    28.             }
    29.             else
    30.             {
    31.                 clone = ((GameObject)GameObject.Instantiate(decalPrefab, position, rotation)).GetComponent<EasyDecal>();
    32.             }
    33.  
    34.             clone.transform.localScale = new Vector3(scale.x, yScale, scale.z);
    35.             clone.Receiver = parent;
    36.             clone.LateBake();
    37.  
    38.  
    39.             if (parent != null)
    40.             {
    41.                 DecalReceiver decalReceiver = parent.GetComponent<DecalReceiver>();
    42.  
    43.                 if (decalReceiver != null)
    44.                 {
    45.                     clone.Distance = decalReceiver.fractionsum;
    46.                     decalReceiver.Receive(clone);
    47.                 }
    48.  
    49.                 clone.gameObject.transform.parent = parent.transform;
    50.             }
    51.  
    52.             return clone;
    53.         }
    Code (CSharp):
    1.         /// <summary>
    2.         /// Instantiates the prefab at the specified position facing in the specified normal direction and rotation as child of parent.
    3.         /// </summary>
    4.         /// <param name="decalPrefab">The decal prefab.</param>
    5.         /// <param name="receiver">The decal parent (parent).</param>
    6.         /// <param name="position">The decal's position.</param>
    7.         /// <param name="normal">The parent's surface normal.</param>
    8.         /// <param name="rotation">The rotation along the receivers normal axis.</param>
    9.         /// <param name="scale">The scale of the decal.</param>
    10.         /// <returns>The decal object or <c>null</c> if the projection criteria was not fulfilled.</returns>
    11.         public static EasyDecal ProjectAt(GameObject decalPrefab, GameObject receiver, Vector3 position, Vector3 normal, float rotation, Vector3 scale)
    12.         {
    13.             Quaternion quat = Quaternion.AngleAxis(rotation, normal) * Quaternion.FromToRotation(Vector3.up, normal);
    14.            
    15.             return ProjectInternal(decalPrefab, receiver, position, quat, scale);
    16.         }
     
  3. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    [UPDATE 24/9/2019] More testing reveals this issue affects only box decals. Also, I've narrowed it down to static batching. If I turn that off, everything seems to be working OK.


    [ORIGINAL POST]
    New bug, and it's a weird one. It seems to be to do with static meshes and I think we've had issues with them before so I'm thinking this bug is most likely related to that.

    Untitled.png

    Bear with me, this is a bit complicated.

    The white thing is just a cube primitive, static geometry.

    The radar building has four legs and a platform, which are all static. The radar on top is not static (it has a script which rotates it).

    I have a couple of bullethole decals (for variation), and a blastcrater decal. The problem affects all ED decals.

    OK...

    If I shoot at the radar (legs), decals spawn and render fine. If I then shoot at the white cube, decals are being spawned, but do not render. The decal is in the correct place, facing the right way, but has no geometry. They show as visible to the camera, but no vertices or faces.

    Likewise, if I shoot the white cube first, THEN shoot the radar building legs, decals do not render on the legs.

    It's as if whatever static geometry I shoot first, is the only static thing decals will then project to.

    But then, if I have TWO static unity cubes, decals will render to both if any one of them has been shot first, or to neither, if the radar unit was shot first.

    The exception to all of this, is the terrain. That's also static, but decals work fine on that, all the time.

    To summarise I think there's still some issue with projecting onto static geometry, and when a decal has been projected onto something that's static, decals then won't project onto anything else that's also static.
     
    Last edited: Sep 24, 2019
  4. anzerkree

    anzerkree

    Joined:
    Feb 16, 2017
    Posts:
    14
    *** SOLVED With deferred decal ***
    Hello Sycoforge
    Thanks for this great plugin.

    I have a problem when my scene is darker (without light)

    My decals seem to be fluorescent. As if there were texture emission.

    My material is "Easy Decal / ED Standard (Mettalic, Vertex Alpha)"

    How can we ensure that the brightness of the decals is affected by the ambients lights?
    How can we remove this emission light ?

    My config : Linear Color and Deffered Camera






    *** SOLVED With deferred decal ***
     
    Last edited: Sep 26, 2019
  5. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Our office is currently under construction. Our reaction time is therefore very slow. All inquiries will be answered by 1 October at the latest. We ask for your understanding. Thank you!
     
  6. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    I think I'm having an epic brainfart today.

    Suppose I want to fire splodges of paint around, all different colours. How can I change the colour of each decal individually?

    I've tried setting DecalMaterial.Color directly, and also DecalMaterial.SetColor. Both seem to be setting the colour of the source material without creating an instance of it.

    [edit] Worked around it by manually instantiating the material on Awake(), but I shouldn't have to do that, right?
     
    Last edited: Sep 26, 2019
  7. ZolnierGames

    ZolnierGames

    Joined:
    Feb 19, 2018
    Posts:
    88
    Just bought this and I'm curious if there is any way to create a custom text decal so I could use it for something like putting a custom text string on the back of a jersey. Is this possible?
     
  8. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Changing the material leads to an instance with disables the auto batching. When not working with thousands of decals, this is fine. You could also store color data in the decal's vertex data and then write a shader that reads the vertex colors. You can change the vertex color by hooking to the OnProjectionFinished event of the decal. However, this method increases the projection CPU time.
     
  9. BitAssembler

    BitAssembler

    Joined:
    Jul 13, 2017
    Posts:
    90
    Maybe this is possible when having the text in a texture. Letting the player/user change the text at runtime requires you to render text to textures.
     
  10. a-bottosso

    a-bottosso

    Joined:
    Nov 13, 2015
    Posts:
    22
    Hi @Sycoforge
    We are currently using the latest version of Easy Decal, in a LWRP context and using Box Decals.
    We're experimenting a weird behaviour: the Decals work fine only when baking is on; when is disabled, changing the decal from the Atlas in play mode results in a huge fps drop in the editor and in build (down to around 7 fps).
    From the profiler, we can see that this is caused by the EasyDecal update, but we are unable to go deeper.
    In our game we need to change decals at runtime.
    Can you please help us to shed some light on this?
    Thanks in advance,
    Alessio
     
  11. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Hi Alessio,

    The Box projector needs a noticeable amount of CPU while projecting the decal. There some heavy algorithms involved to calculate the intersection of the decal's bounding box with world geometry. However, box (mesh decals in general) decals are the best choice for static decals. Once they are soft-baked they need only a very tiny amount of CPU time (0.1 ms for 50 decals) to manage fading and stuff. When placing them at design time they could also be hard-baked to produce no overhead at all.

    In your case, when you have to change the atlas index (actually a geometry change -> UVs), you have to perform the following operations on the decal:

    1. Call LateUnbake()
    2. Wait for next frame
    3. Change atlas index
    4. Call LateBake()
    Code (CSharp):
    1.             Decal.EasyDecal d;// Your decal instance
    2.             d.LateUnbake();
    3.  
    4.             yield return null;// Wait one frame
    5.  
    6.             d.AtlasRegionIndex = 2;// New atlas index
    7.             d.LateBake();
    Please let me know if that helped!
     
  12. a-bottosso

    a-bottosso

    Joined:
    Nov 13, 2015
    Posts:
    22
    Hi @Sycoforge,
    Thanks for your super-quick answer!
    Now it works like a charm in editor.
    Testing on Android results in a short fps drop when changing the decal of the Atlas. Do you suggest using another tecnique instead of the Box one?

    Many many thanks,
    Alessio
     
  13. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    This mainly depends on the receiver and the usage:

    Plane

    Performance affected by
    • Resolution property
    Best for
    • Simple surfaces
    • Convex surfaces
    Drawbacks
    • May creates unnecessary geometry on complex surfaces
    • Always needs colliders
    • Not necessarily fit the geometry of the receiver

    Box

    Performance affected by
    • World space size of the decal
    • Geometry complexity of the receiver
    Best for
    • Complex surfaces
    • Static decals placed at design time
    Drawbacks
    • May creates unnecessary geometry on flat surfaces
    • Performance is size-dependent
    Deferred/Screen Space
    In HDRP: It's recommended to use Unity's implementation.
    In LWRP/URP only "Easy Decal/SSD/Multiply" shader is supported

    Performance affected by
    • Screen space size of the decal
    Best for
    • Complex surfaces
    • transparent decals with the need for proper shadow receiving
    Drawbacks
    • Cannot be batched
    • Works only with deferred rendering path
    • Works only with a perspective camera
    • Projection constraint options are limited

    When you need dynamic decals with a lot of changes in geometry, I would recommend using the Screen Space technique. However, you are bound to a multiply-blend shader.
     
  14. a-bottosso

    a-bottosso

    Joined:
    Nov 13, 2015
    Posts:
    22
    @Sycoforge it's possible to have a shader for the screen space without blending?
    We need a simple basic shader that handles decals with transparency in screen space.
    Have you something to share with us?

    Thanks
    Alessio
     
  15. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Currently, only an unlit screen space shader is defined for the non-deferred pipelines. We'll investigate if it's possible to inject our screen space functionality to LWRP. Maybe there's a simple way to do this. Keep your fingers crossed. We'll keep you posted.
     
  16. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    We can provide a first prototype for a lit screen space decal shader for LWRP/URP. Please send us a private message or email with your invoice number and we'll give you early access to the shader. Please keep in mind that this is an alpha version and should not be used to ship a product.
     
  17. RaulChristian

    RaulChristian

    Joined:
    Aug 16, 2019
    Posts:
    1
    Hey there! I recently bought your plugin online partially due to the promise of source code access. Unfortunately I haven't been able to get your website working - the "add unity invoice" panel doesn't work at all, hitting the "add" button does nothing, I've tried in both Chrome and Firefox - and I've tried contacting support but haven't gotten a reply after a week. I do actually need sourcecode access. Can I get this taken care of?
     
  18. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Unfortunately, your mail somehow didn't make it into our mailbox. Apologies for that. I have sent you a PM containing all info to access the additional downloads.
     
  19. aunity91

    aunity91

    Joined:
    May 20, 2019
    Posts:
    6
    Does EasyDecal require HDRP to be enabled? And is it compatible with Android build?
     
  20. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    No. HDRP is not needed.
    Yes. It works on Android. :)

    HDRP
    Use mesh decals (box or plane projectors) or Unity's deferred decals.

    LWRP/URP
    Use mesh decals or screen space multiply or screen space lit shader (experimental)

    Standard
    All is possible.
     
  21. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Easy Decal 2020.1 is available for download from our website and soon also in the UAS.

    New in experimental state: Screen Space Decals for LWRP/URP (Unity 2019.2 +)! Let us know how they perform in your project.
     
    ratking and JBR-games like this.
  22. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
  23. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Thanks for the report. There was an access right issue on the web shop. It should all be back to normal.
     
  24. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Easy Decal 2020.1

    Fixes

    • Fixed tangent issue when combining.
    • Fixed normal scale issue with box projector.
    • Fixed "Instantiate after save" issue.
    • Fixed wrong scale after prefab creation.

    Features
    • Unity 2019.3 and 2020.1 Support.
    • Moved shortcuts to accessible C# file for easy change.
    • Added experimental LWRP/URP screen space decal shader.
     
    Willbkool_FPCS likes this.
  25. StenCG

    StenCG

    Joined:
    Mar 26, 2015
    Posts:
    66
    The work breaks with an error, it is not clear what causes it, but it is necessary to restart the editor after a while it happens again.
    Asset Atlas has always broken thumbs. latest version of the plugin. Version of the Unity 2019.2.17
     

    Attached Files:

  26. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Thanks for connecting. Does the atlas previews disappear when the exception gets thrown? Or are the preview broken from the very beginning?
     
    Last edited: Jan 30, 2020
  27. StenCG

    StenCG

    Joined:
    Mar 26, 2015
    Posts:
    66
    preview broken from beginning
     
  28. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Unfortunately, we couldn't reproduce the broken previews on our side. Could you please provide the repo steps performed in a fresh project with just Easy Decal contained.

    About the other issue, this is a known Unity bug which we have reported some time ago and it hasn't been addressed yet. It would be great if could report this to Unity too to increase chances to get this fixed soon. Please add our old case number for reference.
    Case 1179600 Material Editor breaks when it gets rendered several time
     
  29. StenCG

    StenCG

    Joined:
    Mar 26, 2015
    Posts:
    66
    1) Create new 3D empty project
    2) Import ED from store
    3) Open any decal atlas asset
    4) View broken

    I think console log can be useful (have new errors):
     

    Attached Files:

  30. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Thanks for the repo project. We'll come back to as soon as we could either reproduce and/or fix it.
     
  31. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    If someone has problems with the 2020.1 screen space shader for LWRP/URP, please follow the steps below until the new version hit the UAS.

    1. Delete "Assets/nu Assets/Easy Decal/Shader/SSD/Legacy/ssd_urp_lit.shader"
    2. Move "Assets/nu Assets/Easy Decal/Shader/SSD/ssd_urp_lit.shader" to "Assets/nu Assets/Easy Decal/Shader/SSD/Legacy" folder.
    3. Reimport the moved shader.
    4. Assign the "Easy Decal/SSD/URP - Lit SSD" to objects rendering in magenta.
     
  32. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Thanks for the additional data. Unfortunately, everything seems to work over here. We have opened your project and couldn't see any issue with the atlas rendering.

    Could you check whether the image texture is readable? Are some textures corrupt? Can share your hardware spec?

    2020-02-03.png
     
  33. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Hi, got a question, does Easy Decal -- Deferred decals work on the lightmapped surfaces (via built-in renderer)?

    Got a simple decal system of my own (that writes to the GBuffers), and I can't figure out how in the world to inject decals to the GBuffers in order for them to look correctly.

    Maybe you can point me to the right solution for this case?
     
  34. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    The deferred decal shader for the Standard pipeline doesn't fully support baked lightmaps. However, the experimental screen space decal for LWRP/URP does. Feel free to download the evaluation version here. :)
     
    xVergilx likes this.
  35. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    That's the thing, I've got quite a large project, transfering it to HDRP or URP will be a pain.
    And newer pipeline utilizes DBuffer approach (I think).

    Mesh decals are the only solution to this then, right?
    I wonder what performance it would be for ~100 decals / frame on current gen PC.
     
  36. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    This performance depends on the following points:
    • Are the decals static? → bake them to perform like meshes (+ small overhead)
    • How complex is the receiver geometry?
    • Is the receiver surface flat? → Plane projector decal gives the best performance
     
    xVergilx likes this.
  37. StenCG

    StenCG

    Joined:
    Mar 26, 2015
    Posts:
    66
    You mean flag "Read/Write" in import texture? If yes, then its false. Mark it true (and apply of course) did not change anything. All atlas textures look fine.
    My HW spec: I7-5930k, GTX 950
     
    Last edited: Feb 7, 2020
  38. LukeBryan93

    LukeBryan93

    Joined:
    Dec 3, 2018
    Posts:
    17
    Hi there,

    I recently just bought this plugin and im having a few problems, Im using Unity 2019.3.0f6 FYI. So the issue is that i can't seem to get the decals to show up on any of the meshes i have created in my scene. However If i create a basic unity primitive shape like a plane and put the decal on that it works perfectly! Sorry if im being insanely stupid. I must be missing something but im not quite sure what! Any chance you could point me in the right direction? thanks
     
  39. BitAssembler

    BitAssembler

    Joined:
    Jul 13, 2017
    Posts:
    90
    Okay, I need to know a few more details to provide appropriate help:
    • Render pipeline: Standard, HDRP, URP?
    • Decal type: Deferred, Screen Space (Standard, URP), Mesh (Plane/Box projector)?
    • If mesh decals: Do you have any static geometry?
     
  40. LukeBryan93

    LukeBryan93

    Joined:
    Dec 3, 2018
    Posts:
    17
    Hey, Cheers for the quick respone.

    So im using the standard pipeline

    Im just trying to use one of the prefab decals that are included in the package at the moment 'Graffiti A' which is a box projector.

    Pretty much all my meshes in my scene are static.
     
  41. BitAssembler

    BitAssembler

    Joined:
    Jul 13, 2017
    Posts:
    90
    Static geometry cannot be read by the projector at runtime (unity limitation). The system tries to automatically work around this by checking whether there's box or mesh collider to guess the actual geometry. For static environment decals, this is not a problem because they got placed at design time in the editor (where the meshes are accessible) and they can be baked before entering play mode. For dynamic decals placed at runtime, I recommend using either deferred decals or plane projector decals (when using mist flat surfaces like walls etc). Hope that makes sense. :)
     
  42. LukeBryan93

    LukeBryan93

    Joined:
    Dec 3, 2018
    Posts:
    17
    Thanks for that. I got it working instantly after reading your response.

    Cheers for your help
     
  43. RichardSim

    RichardSim

    Joined:
    Dec 15, 2013
    Posts:
    14
    I'm trying to import Easy Decal into Unity 2019.3.1f1 and get the following errors:

    and

    Apparently this is due to the ch.sycoforge.Decal.dll and ch.sycoforge.Decal.Editor.dll files having dependencies on UnityEngine.XModule.dll rather than UnityEngine.dll, so Unity is trying to patch them to fix it, but failing for some reason. See this thread for a bit more information: https://forum.unity.com/threads/sta...o-update-assembly-on-dll.722627/#post-5287620

    As a workaround, if I delete the associated PDB and MDB files it succeeds.
     
  44. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Thanks for sharing this issue and its workaround!
     
  45. martman100

    martman100

    Joined:
    Sep 4, 2013
    Posts:
    44
    I am looking for an asset package that will allow a user to place decals on vehicles in a mobile game and save the placement and such and remove them. I am not versed technically in decals so was curious if this package would work? If not does anyone have suggestions on a package or an approach to accomplish? I searched this forum for truck and vehicle with no results so sorry if this has been asked before.

    Thanks for any help!
     
  46. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Yes, that's possible with Easy Decal. You just have to check which projector types is the right one for your use case.

    You can download an evaluation version from our website.
     
  47. DChap

    DChap

    Joined:
    Dec 24, 2016
    Posts:
    23
    Hi, I'm trying to use Deferred Decals with the Deferred SSD shader and everything seems to be good except the decals are not receiving the Realtime Global Illumination from my lighting setup. Is there a way for deferred decals to receive the indirect global illumination?

    • First image shows scene with Indirect intensity of 1 (decals don't match the terrain)
    • Second image has Indirect Intensity set to 0 (decals match terrain, but scene has no bounced lighting)
    • Third image has Indirect intensity jacked up to 3 to highlight the decals not receiving indirect lighting.

    (Also I'm getting odd behavior when I project the decal from a diagonal angle, it gets weirdly dark)
     

    Attached Files:

    Last edited: Feb 19, 2020
  48. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Hi,
    Thanks for connecting! Unfortunately, the deferred decals do not fully support GI. If you are in URP, you could give the new screen space shader a go to see if it suits your use case. However, keep in mind that the screen space URP shader is still in an experimental state. Sorry for the bad news!
     
  49. Jackless

    Jackless

    Joined:
    Jan 9, 2018
    Posts:
    19
    I have a problem using baked decals on prefabs with skinned meshes. I am of course using the skinned box technique.
    The prefab that I initially set up by hand works fine but every other prefab instance that i put in the scene afterwards doesnt display the decals.
    The outline boxes are still visible but not the decal itself. I have to manually unbake and then bake again to make it visible and even that sometimes doesnt work.
    Is this a known issue?
     
  50. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    This is a known limitation. This happens because the mesh of the decal is serialized in the scene and not as an asset. So when ever the model is saved as prefab, it loses all references to the mesh. However, we have an experimental branch (available on our website) that allows to save the skinned decal as an asset which makes the skinned character savable as a prefab.
    • Download Easy Decal 2020.2.0 from our website
    • Place the decal on the skinned character/object
    • In the "Extras" tab of the decal select "Instantiate after save" and click "Save"
    • Select a save location within your project in the modal dialog and click "Save"
    • Now it's safe to create a prefab from the skinned object.
    Please let me know if this solved your issue.