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

[RELEASED] Dynamic Decals

Discussion in 'Assets and Asset Store' started by Llockham-Industries, Jan 12, 2017.

  1. bcv

    bcv

    Joined:
    Sep 1, 2012
    Posts:
    23
    Hello Lockham-Industries, I have a blood splat decal on a character, say on the torso, the problem is that if the character moves an arm near his torso to where the decal is located, the arm will receive the decal projection too thus breaking the illusion that the blood decal is only on the torso, is there a way to prevent this ? thanks
     
  2. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @bcv - Your best bet would be to reduce the thickness (local scale z-axis) of your projections so that they're thick enough to reliably project onto your characters torso, but not protrude through to the front of the arm. You could then reduce your projection limit (to around 80 or so) to stop it from projecting onto the inside of the arm.

    In general, if your using the system to project decals onto characters that need to stay and move with the character, try to keep the decal size reasonably small.
     
  3. bcv

    bcv

    Joined:
    Sep 1, 2012
    Posts:
    23
    Sounds good, would be nice if there was a way to avoid projecting the decal on a certain area, for example a radius that we could define somehow around objects or joints. Thanks for the tip.
     
    Llockham-Industries likes this.
  4. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @bcv - Agreed, would be nice, but unfortunately it's not possible.

    Decals are calculated in screen space. So if you where to block out say, a sphere in 3d space and tell your decals not to render there, what you would actually be doing is telling your decals not to render in that area of the screen. So any decals that are in front or behind where that sphere was rendered into you mask would be masked too.

    The decals don't actually exist in 3d space, they're calculated in screen space, so you can't tell them where not to render in 3d space, only in screen space. I get what your after, and if it where possible I'd definitely implement it for you. Keep the suggestions coming :).
     
  5. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    51
    Apologies - I admit I didn't read through all of this thread or the docs. Just a few quick questions:

    - I'm assuming it works in Unity 5.6 deferred + HDR, etc., and will play well with the new "uber" cinematic effects system.
    (https://forum.unity3d.com/threads/new-post-processing-stack-pre-release.435581/)
    - Does it receive shadows?
    - Is the masking system fully functional and not fiddly. So, for example, can I easily cast decals onto terrain and ignore the player running "through" the decal space?
    - Can decals be added dynamically easily through script - like blood splats coming off enemies?

    Thanks!

    P.S. I am using a custom terrain shader already. If the shader needs to be modified in some way to enable masking of decals, that's possible too.
     
    Last edited: Jul 6, 2017
  6. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @mgeorgedeveloper -
    1. Works in 5.6, supports HDR and the post processing stack.
    2. Decals do receive shadows.
    3. Masking system, funnily enough, works on everything but the terrain currently. You can mask a character and tell your decals not to draw on your character, or you can mask environment objects and tell your decals only to draw on them, or to ignore specifically them. Working on a way to mask the terrain as well now, but currently not implemented.
    4. You can instantiate decal prefabs like you would any other gameObject. The system also includes a bunch or "Printers" that print decals in common situations. eg. on collision, on ray-collision etc. and a generic printer that you call a Print() method on to print decals at a desired location / rotation (Allows you to take advantage of in-built pooling etc.) :).
     
  7. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    51
    Regarding masking, I just need the ability to say... don't draw on enemies, main character or other moving objects. Anything static that is not masked out, is fine. Basically need to avoid a blood splat suddenly appearing on a dynamic object moving through that area after the splat is already being drawn.
     
  8. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @mgeorgedeveloper - Masking in it's current state can definitely support your needs. Though it should be said, masking does require the object be drawn into a mask buffer. The shader is cheap but if you need to mask out thousands of dynamic objects it can add up. If you've only a few hundred masked objects, characters etc. you won't notice it. If you have thousands, it would be better to for example, mask the ground instead and tell your decals to only draw on that. The best way to approach masking varies on a game by game basis.

    If your working with terrains, for now your only option is to mask out all of your dynamic objects. If you do have thousands of dynamic objects and this becomes impractical, It would probably be better waiting to see if I can get a terrainMask component implemented :).
     
  9. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    51
    Dynamic objects will sit somewhere between 2 and 40 depending on what's going on. I will give your system a try soon and let you know how it went. Thansk!
     
    Llockham-Industries likes this.
  10. Sailing

    Sailing

    Joined:
    Sep 6, 2015
    Posts:
    12
    very impressive assert, but i just found it can't work with static mesh, is it a bug?
     
  11. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @Sailing - It should work fine with static meshes, are you perhaps using a custom shader on the mesh? Is it semi-transparent? What rendering path are you using, forward or deferred? Unity version?
     
  12. Sailing

    Sailing

    Joined:
    Sep 6, 2015
    Posts:
    12
    sorry i mean static meshes with lightmap, i use unity standard shader for static meshes with rendering mode opaque and deferred. decals work only if i use Precomputed Realtime GI.
     
  13. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    I've tested every version I have between 5.4 and 2017.1 and decals appear to be projecting perfectly fine on static geometry with baked or pre-computed GI.

    I think I may be misunderstanding the problem though. Decals themselves don't support light-mapping, but they should be able to be projected on a surface regardless of if or how it's light-mapped or GI is calculated. The decals themselves should not be marked as light-mapped static objects though.
     
  14. Sailing

    Sailing

    Joined:
    Sep 6, 2015
    Posts:
    12
    i upload a image
    error.png
    the upper two image is using Baked GI and lower two is using Precomputed Realtime GI
    as you can see tiremark is show with Precomputed RealTime GI enable.
     
  15. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @Sailing - Are you using normal decals? Does this only occur on normal decals, or all decal types? Love your art style btws, props to your artists.
     
  16. Sailing

    Sailing

    Joined:
    Sep 6, 2015
    Posts:
    12
    yes, i use normal only decals.and im not sure this only occur on normal decals,i will test it tomorrow at office
     
  17. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @Sailing - So the issue is that your telling the object you want to bake all of it's lighting information into a texture, then trying to use decals to adjust how it's lit at runtime, ie. Change it's normals. But because the lighting information is already baked into the objects lightmaps, and is not being calculates at runtime, adjusting it's normals at runtime with decals doesn't do anything..

    Your best bets going to either be marking your sand as non-static, and give up all that nice baked lighting detail, or trying to achieve similar tracks using semi-transparent decals..
     
  18. Sailing

    Sailing

    Joined:
    Sep 6, 2015
    Posts:
    12
    thanks for the tips, i will try it.
     
    Llockham-Industries likes this.
  19. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    404
    I'm currently using Decals for bullets holes in the environment. The problem I'm facing is that sometimes (1 out of 50 bullets) when shooting edges....I can see a white box show up for a spit second.

    I'm using Transparency "cutout" at the default value of .02.

    Is it the cutout I'm seeing? If so, how can it be fixed?
     
  20. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @sbmhome - Are you in forward or deferred rendering? and are you pooling your objects? If so does the issue occur after you've reached your pooling limit, or only while generating new decals?
     
  21. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    404
    I'm using forward rendering and I am pooling the objects. They don't seem to be related to the pooling system (I'm using my own pooling system)...as there is no issue with 1 instance or 100...as long as the geometry is flat.

    I am instantiating all decals when first loading the scene.

    I am placing the decals myself...not sure if that could be the issue.
     
  22. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @sbmhome - I have a theory - When enabling the object the forward rendering component is being enabled, but the material/decal shader is only being marked to be applied, so 1 in every x frames your seeing the decal renderer enabled without it's material applied (white cube).

    Could you try changing line 552 in Projection.cs from UpdateMaterials() to UpdateMaterialImmeditately(). If I'm correct this should fix the issue.
     
  23. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    404
    That seems to be working so far, I haven't been able to reproduce the issue since changing the line....Thanks!
     
    Llockham-Industries likes this.
  24. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    78
  25. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @churi24 - Due to the sheer scale of the asset store, it's not really feasible for me to test compatibility with every other asset on the store, but I see no reason these assets wouldn't work together. If they don't work, and I'm unable resolve the problem, you have it on record that your entitled to a refund, as you should be :).
     
    churi24 likes this.
  26. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    317
    I just bought this today gambling that it might work with Daydream (mobile VR, forward rendering, no single-pass stereo), but sadly it does not... I tested it with the showcase scene, deleting everything but the unlit decals, and nothing appears on the spheres. The decals seem to show in the editor using the Gvr Daydream emulator, however. Also I have noticed a couple of strange behaviours. I'm on OSX with my editor set to forward rendering, and when playing through the editor decals will toggle visiblity depending on the angle that I am looking at it. And that angle threshold doesn't seem to be based upon whether it is visible by the camera (though I'm guessing that is the intended behaviour). When looking at a decal straight on, this will happen. I'm having trouble reproducing it reliably too, but it does happen sometimes. Also, when not playing in the editor, the decals will disappear/reappear randomly in the scene window and game window, and won't appear until I hit play. I don't have any errors that might be interferring with the ExecuteInEditor mode. This also happens sometimes when toggling other gameobjects/decals on and off. I thought that this meant it might have something to do with the priority system, but the behaviour still occurs if I delete the other decals from the scene, or give certain decals 100 priority. Anyways, pretty confused in general. I guess I'll need to dig through the documentation to understand why this is happening, though since it doesn't seem to work on Daydream, I might just give up.
     
  27. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @arlevi09 - Could you send an email to me at Support@LlockhamIndustries.com, I have a build I'd like you to try. I can offer you a refund, but I'd much rather work with you and get it up and running for you. If there's bugs you shouldn't need to dig through the documentation and try to fix them, the ownness is on the developer (me) to fix them for you :).
     
  28. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    317
    Even if you can't get it up and running, I wouldn't expect a refund. The system obviously works very well for its intended platforms, I just happen to have three attributes (forward rendering, mobile, vr) that are secondary compatibility targets. It was a gamble for sure. Thanks though! Will send you an email :)
     
  29. RobinNvizzio

    RobinNvizzio

    Joined:
    Sep 29, 2016
    Posts:
    9
    Hi,

    Bought the asset, and it's pretty great.

    My artists ask me for a feature that's missing and that is used commonly on decals.
    Is to have the possibility to have 2 masks.
    One that will be use for alpha blending and one for cutout.
    All of that to make a kind of dissolve effect on the decal
    Like this shader:
    upload_2017-7-19_15-22-5.png

    Do you think it would be possible to add this feature ?
     
  30. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @RobinNvizzio - Sounds reasonable, there's a lot I need to finish first, but adding a dissolve variant should be trivial in the new system, added to my list.
     
  31. RobinNvizzio

    RobinNvizzio

    Joined:
    Sep 29, 2016
    Posts:
    9
    Any ETA ?
    Or should I do it my self ?
     
  32. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @RobinNvizzio - If this is something you urgently require and are comfortable doing yourself, go ahead. There are too many things I need to finish before I can jump on it myself so I can't give you an ETA.
     
  33. applicattura

    applicattura

    Joined:
    Mar 28, 2017
    Posts:
    12
    Hi,
    I bought the assets and for now I am unable to use it in my mobile game. I pmmed llockham, and he is really kind, but I thought to share the problems here. Hope to get some solutions from other users, maybe it could help someone who has similar problems.

    In my mobile project I need to use printers & projectors. Unfortunately it doesn't work with the orthographic camera. Llockham sent me a new unitypackage and it worked but only on the pc, the mobile ortho still isn't supported.

    The next problem is using standard unity Post Processing Behaviour script. After turning it on the decals aren't visible (similar to the previous problem).

    Generally the asset is great, I am not a guy who wants a refund, I would really love to get a support and solution for the problems I met.
     
    Llockham-Industries likes this.
  34. applicattura

    applicattura

    Joined:
    Mar 28, 2017
    Posts:
    12
  35. Sosowski

    Sosowski

    Joined:
    May 20, 2013
    Posts:
    5
    I tried the asset being in need of normal (and parallax) mapping for my decals, but it appears not to be working in Untiy 2017.1.0f3. Changing the normal texture and slider does nothing and no normal maps are being rendered. Also, displayed normal map in the script properties has this weird pinkish colour. Attached a DemoScene screenshot.

    http://imgur.com/a/fP7Ye

    Please let me know if you need any more info!
     
  36. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
  37. siliwangi

    siliwangi

    Joined:
    Sep 25, 2009
    Posts:
    298
    @Llockham-Industries
    Please check your e-mail with subject "Dynamic Decals problems", sent it two days ago! :(.
     
    Llockham-Industries likes this.
  38. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @vortexilation - Sorry for the delay, check your emails, got you covered :).
     
    siliwangi likes this.
  39. simonb3d

    simonb3d

    Joined:
    Jun 11, 2013
    Posts:
    1
    Hi, I am also seeing the issue with normals not working in 2017.1
     
  40. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @bochengy - theres a patch coming up with a fix to that bug, In the interim send me an email (support@LlockhamIndustries.com). I'll send you a fixed copy :).
     
  41. Image3d

    Image3d

    Joined:
    Jun 20, 2008
    Posts:
    111
    Hi, just bougth Dynamic Decal package and seems it will solve my water wake trail problem.

    I have a morphing surface where the decal must be applied (the surf wave). If the surface is not morphing or moving the decals are applied, but if the surface is morphing or moving some of the decals are not applied.

    It seems that the raycast is printing the decals after the wave morph is updated. 2017-07-31_17-26-08.png 2017-07-31_17-26-55.png 2017-07-31_17-27-48.png

    I am using the RayCollisinPrinter Component.
     
  42. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @Image3d - So the decals won't automatically move with a surface, they exist in world space. So it sounds like they're being spawned correctly, but then the surface they're moving with is moving out from under them. Normally you would parent the decal to the object it needs to move with, but that won't work here. There's 2 approaches you could take here.

    Approach 1 - move the decals with the surface. Attach a component to your decals that ray-casts down to find the water level, then moves/rotates the decal to match the surface height and normal of the water. If your going for this approach email me (Support@LlockhamIndustries.com), I'll give you an early version of 2.0, which allows you to print decals with components attached. Should make it significantly easier. This will be somewhat expensive but give the best results.

    Approach 2 - Adjust the thickness of the decals so they encompass the full height of the waves. This approach would require a custom printer to print the decals so they're always facing directly upwards, and in areas where the waves have height the decals would stretch a little, but it would be very cheap to implement and have no running cost after the decals have been printed.

    Hope this helps :)
    Dan
     
    ledbetterman likes this.
  43. Django

    Django

    Joined:
    Nov 25, 2008
    Posts:
    120
    Hello Dan,

    I am very interested in Dynamic Decals as it looks great! It would be for a mobile game that is in forward rendering but I would really appreciate to have some more information to make sure it can do what I am looking for. My main use would be to fake shadows under skinned mesh characters.

    In my project I currently use a unity projector that gets a render-to-texture of the character and projects it to create the shadow under the character. (short story: I cannot use Unity built-in shadows due to the nature of my game that requires all the shadows to face a different direction per character. )

    The projector duplicates any mesh it projects on so with multiple characters performance naturally takes a hit. I sort of mitigated this issue by having the projector project on a mesh decal that moves with the character and takes the shape of the ground under it and is not always updated to save performance. I am hoping I could do something similar using your system. I am hoping it would be faster in terms of performance and a better solution for my shadows than my current implementation.

    I would like to know if it is possible to use a render to texture as the material of the decal with your system?
    Is it possible to use a Unity projector to project on the decal? Is that something that would be achievable with your system? I am not familiar with screen-space decals so any suggestions would be appreciated.

    Thanks so much for your time,
    Django
     
  44. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @Django - Have not tried using renderTextures as a texture source, but they should behave like any other form of texture, so I see no reason you couldn't just slot them into the decal component as your texture for an unlit decal.

    Regarding whether or not the system works with projectors, decals in this system aren't meshes, they are generated in shader at run-time, per pixel. You couldn't project onto them with a projector. However, this seems like the wrong approach, why not simply use the decal directly and ditch the projector as the awkward middleman. This should be significantly faster and less bug prone.
     
  45. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    677
  46. Django

    Django

    Joined:
    Nov 25, 2008
    Posts:
    120
    Thank you for your reply Dan, I really appreciate it.

    I understand better how it works now and I think you are right about ditching that "middleman" projector. I will certainly be using Dynamic Decals in my project!
     
  47. Django

    Django

    Joined:
    Nov 25, 2008
    Posts:
    120
    Hi Dan,

    I just purchased it and imported it to my project but it is causing this error with my own scripts because I also have decal scripts of my own that are called Decal. Is this something I need to fix on my side or yours?

    Thanks,
    Django
     
  48. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @Griffo - I'm starting to roll out 2.0 to testers, It's close to feature complete, just working on improving masking, new demo scenes (also serves as internal testing) and documentation. If you'd like an early copy send me an email at Support@LlockhamIndustries.com.

    As a heads up, the system has almost been completely rewritten from scratch.

    There are no more decal, eraser and omni-decal components, instead we just have a projection renderer and projections. Think of it as similar to how Unity has mesh renderers and materials. The projection renderer takes a projection as an input and renders it. This means all renderers share the same projection, however, each renderer also has instanced properties (Like Tiling and Offset for animated decals, masking and color etc.) that allow you to modify the properties of a single instance of your projection.

    Fading and culling has been disconnected from pooling, and is instead now implemented in separate components. To allow these to be used with printers, printers now have the ability to print projections with components attached. So if you wanted to say, randomize the size of your decal as it's printed, instead of hacking it into a custom printer, you can now just attach a component to your projection renderer that sets the scale of your decal in OnEnable(). Or if you wanted to animate a decal over time, you could attach a component that adjusts the tiling and offset of your decal accordingly and attach it to the projection renderer being printed.

    Masking is no longer dependent on attached mask components and is now dependent on Unity Layers. You still only have 4 layers (for now) and you specify which Unity Layers make up each mask layer. This has the added benefit of supporting terrains and terrain billboards out of the gate. It's also significantly less painful to setup. It's accomplished using shader replacement so currently requires an additional pass, but I'm working on setting up the system to perform this in the same pass as your depth/normals so it will come at essentially no cost (In it's current state it's still significantly faster than the 1.6 method).

    The system also takes advantage of GPU instancing, so on modern systems it's now pretty reasonable to have 10 - 20000 decals on screen at once semi - comfortably. Now that we're not using command buffers to draw decals, Unity manages culling in C++ code, so having decals persist is very viable.

    The system also has it's own namespace so @Django, If your interested, it will solve your issues also.
     
  49. Image3d

    Image3d

    Joined:
    Jun 20, 2008
    Posts:
    111
    I solved the position problem with the new Dynamic Decal version. How do I set the Sheet Animator to play an 8 by 8 row/column texture?
     
  50. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    I think this is probably the best possible decal solution in Unity. Looking forward to V2 as well!
     
    HakJak, ZJP and Llockham-Industries like this.
unityunity