Search Unity

[RELEASED] Dynamic Decals

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

  1. Django

    Django

    Joined:
    Nov 25, 2008
    Posts:
    120
    Version 2 sounds very promising. I will wait until it is out as I am not into a hurry. I am looking forward to it!
     
    Llockham-Industries likes this.
  2. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @Image3d - The sheet animator is currently untested, and I'm very much open to tweaking it based on feedback. Currently there are 5 variables.

    Count - the number of frames in your sprite sheet (64 for you). (Using count instead of columns and rows because there could be situations in which you have empty frames, ie. 5 frames on a 2x3 sprite sheet etc.)

    Speed - Playback speed in frames per second.

    Then we have 3 Vector2s, the fame size, the offset/border and the frame gap. in 90% of sprite sheets there will be no pixel border and gap, so you can leave these as 0. The frame size is in UV space, so for you, assuming there is no border and gaps on your sprite sheet, your size would be 1 / 8 (0.125, 0.125).

    I'm not convinced this is the best way to present this information, but it covers all of the use cases I could think of. Definitely open to feedback.
     
  3. Image3d

    Image3d

    Joined:
    Jun 20, 2008
    Posts:
    99
    I understand that the Sheet Animator script is to attach to the Projection Renderer.

    I did that using the above values, but got no animation on the decal. Can you post an example ?
     
  4. Cliff-Lee

    Cliff-Lee

    Joined:
    Apr 18, 2016
    Posts:
    7
    Hello, I encountered a problem with the Dynamic Decals.

    I bought your decal solution and it's is the best solution for our case. In our case, we use Dynamic Decals to draw in VR like texture painting tools. We will print different colors from the same decal on the scene, and the painting action gave us performance issue that seems to relate to fast-growing draw calls.

    Is there any solution for printing different colors from the same decal and keep the performance?
     
  5. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @Image3d - Any chance you could send a copy of your sprite sheet in an email attached to Support@LlockhamIndustries.com? I'd be happy to take a look at it tonight and send you back a copy of the component.

    @Cliff-Lee - 2.0 has you covered. You should be able to instance your paint decal, and then set the color as per-instance values without breaking GPU instancing. Send me an email (Support@LlockhamIndustries.com) I'll send you an early version and a code snippet detailing how to adjust the color.
     
    Last edited: Aug 8, 2017
  6. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    555
    I wonder if anyone has asked if you can do mesh vs mesh blending for example a rock and a ground plane - using a sand decal that wraps around the intersection between the two to create a blending effect, here's an example of a boat blending with the ground:

    I wonder if it can be done using decals because other methods usually require using the terrain system and it's not good.

    As you can see the intersection is pretty seamless, it really looks like part of the ground!

     
    ZJP likes this.
  7. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @SilverStorm - It could be done with decals, but it would be very finicky, and you could achieve much nicer results with a lot less setup and toying using other techniques. I would approach it using a sort of Tri-Planar shader that calculates UVs based on it's position in would space. This way textures automatically line up across multiple objects, like above, and you can scroll textures in 3 dimensions, so they would never stretch. :)
     
    SilverStorm likes this.
  8. Thermos

    Thermos

    Joined:
    Feb 23, 2015
    Posts:
    49
    Hi,
    Is is possible to make a status indicator like https://www.assetstore.unity3d.com/en/#!/content/88156 in v2.0?
    I can put several different decal together to create a dynamic indicator, but the draw call would be high and this approach can't be used to create cone shapes. If there is a way(a tool maybe?) to toying round the uv calculation, it would be very flexible and powerful.
     
  9. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @Thermos - 2.0 supports gpu instancing & atlassing, so you could do it in a single call with multiple projections if your clever about it, and this is probably the approach I would take as well. I actually have box selection working using multiple projections in an upcoming demo. Dynamic cones would be tricky though. For simpler cones, I would construct the cone initially out of 2 edge pieces, then as the cone gets wider or smaller rotate them apart and add or remove center pieces, this would limit the outer edge to being a solid line though.

    2.0 already has too much packed in and I need to get it out and into everyone's hands, so I'm trying not to add too much more. I might look at creating generic 9-sprite, ring and cone projection UI components post 2.0 though.
     
  10. LlamaStan

    LlamaStan

    Joined:
    Jan 12, 2015
    Posts:
    3
    Would the dynamic decals of this asset work on transparent or semi-transparent meshes?
    We have a moving see-through ocean in our game and need an easy way to make stylistic foam, seaweed and other things on the surface. So they would have to move up and down, with the waves of the ocean.
     
  11. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    Transparent shaders won't write to the depth buffer, so they cannot be drawn on. However, If you know you won't be drawing any semi-transparent objects(ie. no jellyfish etc.), or decals underneath the ocean , you can tweak your water shader to write to the depth buffer and draw after all of your opaque objects.

    As for having your projections move with the surface of the water, this has been discussed earlier. Essentially you can move the bounds of the projection like any other transform, so you can ray-cast from above the projection a few times a second to regularly re-position/re-orientate the bounds to fit with your wave height/normal. Or you can just stretch the projection bounds to encompass the minimum and maximum height of your wave, but if you have large waves this approach will show the decals stretching a fair bit.

    If you pick it up, send me your shader and I'll tweak it for you. And if you want to go for the first approach, I'll give you an early version of 2.0 so you can print projections with behaviors attached (Will allow you to attach ray-casting/height adjusting behavior).
     
  12. LlamaStan

    LlamaStan

    Joined:
    Jan 12, 2015
    Posts:
    3
    @Llockham-Industries Thanks for the response!
    Yes, that's what I thought. That's why we haven't been able to do it ourselves yet.
    We kind of need semi-transparency for plants under water and maybe other stuff that I can't think of now. So I guess we'll have to find another solution.

    I might still pick up your asset for things above the water, so I might still test your solution. We will have to change our way of doing plants then of course.
     
  13. churi24

    churi24

    Joined:
    Sep 17, 2013
    Posts:
    72
    Hi, how could I use this with Custom Shaders. I'm asking this because I'm using this asset with HXVolumetrics and all decals looks white. I need this decal system for blood, so I have a custom shader that I want to use.
     
  14. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @churi24 - You cannot use custom shaders for the decals themselves, but you should be able to project onto any opaque shader, provided it's setup properly. (replacement tags etc.)

    Send me an email at Support@LlockhamIndustries.com with your shader attached and I'll set it up for you :).
     
  15. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    568
    Any ETA on v2?
    I'm close to suggest buying this asset, but knowing that there's a new version waiting around the corner...
     
  16. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @maro-Sperling - Currently about 3-4 weeks until planned release. This includes polishing a second new demo scene (Think Portal physics goo (Slide/Bounce)), website overhaul, marketing images & documentation. The system itself is feature locked and, aside from a few final bugs, complete. If you end up picking it up I'd be happy to send you out an early copy. The more feedback and testing the better.
     
    hippocoder likes this.
  17. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    For anyone still interested, I've managed to get the latest version of the system working with single pass stereo rendering in VR. While it's not actually rendering the requisite replacement shaders using single pass stereo (It's still done in 2 passes) all the decals themselves are now able to be rendered in the same pass and the system is fully compatible.

    It's not perfect, but it's still significantly faster than multi-pass rendering. If any of you are using the system in VR and would like an early version hit me up at Support@LlockhamIndustries.com. Happy to send out copies :).
     
  18. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
  19. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    Happy to announce version 2.0 has been uploaded to the store and should be available within the week. I'm pushing this out a little earlier than planned, forgoing a little polish on the second new demo scene in favor of getting this in your hands early.

    This is a massive upgrade that overhauls the entire system. As a result, a large portion of the system is not backwards compatible. Please backup before upgrading.

    2.0 brings a ton of new features:
    - GPU instancing with per-instance properties.
    - Texture atlases.
    - Animated projections.
    - Additive projections.
    - Multiplicative projections.
    - Masking by Unity layers.
    - Nine-sprite projections.
    - Single Pass Stereo Support (VR).
    - Print projections with behaviors attached.
    - Omni-Directional decals now support all projection types.
    - Brand new demo scenes.
    - Just a whole bunch of optimizations.

    I'm also increasing the price of the system from 29 usd to 34 usd. If you've already bought the system though, don't stress updates are of-course free for life, I'm not going to charge anyone for new features.

    There are simply too many people to thank for helping me test and polish the system. I'll forgo a huge list of names, but thank you to everyone who helped test the system, report bugs and suggest features/ improvements, as well as everyone who simply shows interest. For a 1 man development team, it's more encouraging than you could ever know.

    Cheers
    Dan
     
    Marco-Sperling and hippocoder like this.
  20. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,449
    This sounds excellent!
     
    Llockham-Industries likes this.
  21. Thermos

    Thermos

    Joined:
    Feb 23, 2015
    Posts:
    49
    Within a week? 7 sleeping pills are needed for sure.
     
  22. djarcas

    djarcas

    Joined:
    Nov 15, 2012
    Posts:
    154
    Is this a new package, or an update? Ie can I just purchase the existing package right now and it'll update when Unity get around to reviewing it?
     
  23. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
    Looks like a lot of brokenness in 2.0. Your demo scenes throw errors. Samples don't seem to be working correctly. Decal mode doesn't show anything, only omni mode works.

    This is on 2017 p5, deferred gamma.
     
  24. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
    Projection/Decal/Normal shader also has an error.
     
  25. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
    For some reason a lot of people think 2017 is still beta. It's not, it's the latest official release.
     
    gremberman likes this.
  26. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @snacktime - What OS are you using/ what are you building for? are you using any form of graphics emulation? Make sure you've read the getting started guide, different projects will require different forms of shader replacement.

    Could you also try a clean install (ie. Delete the old system before installing the new one (Please backup first))? You may be importing half of the system, while keeping unnecessary components from the old one, as well as old demo scenes that will not be compatible with the new system.
     
  27. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @djarcas - 2.0 is the same package, no upgrades, purchase it and you get it and all updates in the future.
     
  28. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    355
    Is performance for 2.0 much better than the last version?

    I'm placing decals dynamically in the scene for blood and bullet impacts. Does GPU instancing work for these as well? I want to know if I would be able to increase the amount of decals I'm using in the scene.

    Note: I'm currently seeing about 4 draw calls per lit decal.
     
  29. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
     
  30. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
    FYI On the decals, if you crank the angle limit to max it shows 2 sides, if that helps track down that issue.
     
  31. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
    Sorry, that's with a rectangle mask. WIth no texture it also comes in if you crank up angle limit, although it's not correct either.
     
  32. djarcas

    djarcas

    Joined:
    Nov 15, 2012
    Posts:
    154
    Llockham-Industries likes this.
  33. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
    Hey my project is huge so I don't keep third party assets in version control. Any way you can shoot me a link for a download of the last version before 2.0? I can email/message you invoice number.
     
  34. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
    The decal issue was rotation. Stupid error on my part.

    The shader bug is calling WorldNormal, probably due to some includes or something but it's calling a 3 param method with 2. I just put in a quick fix myself on that one, hardcoded in a scale of 1.0.
     
    Llockham-Industries likes this.
  35. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
    Wonder if some lighting settings are causing the shader error. There are a lot of switches that change what gets defined or not in Cginc. I've been bitten by that more then once.
     
  36. djarcas

    djarcas

    Joined:
    Nov 15, 2012
    Posts:
    154
    I'm in 5.6.2 and seeing this error:

    In order to call GetTransformInfoExpectUpToDate, RendererUpdateManager.UpdateAll must be called first.

    No callstack, of course.
     
  37. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @sbmhome - Performance should be significantly better in 2.0, if your seeing high draw-calls it's the requisite shader replacement, not the decals themselves. In previous versions I was leveraging Unity's shader-replacement now it's all custom (Except mobile shader replacement, which is Unity's low precision depth normals) I'm also doing masking via shader replacement instead of command buffers, which, while additional calls, is significantly faster than the command buffer technique I was using previously (And can be done in a shared call with depth/normals 90% of the time).

    With instancing on you should be able to draw 1000 decals in a single call (You need to tick the instanced box on your projection to enable instancing for a projection) You could definitely use this for blood and bullet-holes, I'm using it for blood in the Minion demo scene :).

    @djarcas - Add a 2.0/ to the end of the link
    documentation is - http://www.llockhamindustries.com/documentation/dynamic-decals/2.0/
    I thought I updated all the links to the documentation, must have missed one, I'll need to change it, thanks.
    I've put a redirect in the meantime, that link should now head to the latest documentation.

    The getTransformInfo issue is a 5.6 issue related to rigidbodies with an interpolation mode set, Unity fixed it in 2017.1. :)

    @snacktime - Good to see you found a solution, do you still want a copy of the previous version? If so send me an email at Support@LlockhamIndustries.com I'll send one right over. Also what line did you find the shader error? Unity has multiple shader compilers, some are stricter than others. Thanks for your patience.
     
  38. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
    The error is in your normal shader where it calls WorldNormal, it's trying to call it with 2 arguments instead of 3.

    Nope don't need an older version but thanks.
     
  39. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    Thanks! appreciate it :).
     
  40. grujicbr

    grujicbr

    Joined:
    Aug 19, 2014
    Posts:
    18
    Hi,

    After the upgrade I notice a huge spike in terrain rebuild mesh vbo on the first instance of a decal being allocated which causes a huge 200ms+ spike. Have you tested this new update on a level which is using a terrain instead of just a regular mesh collider? (I'm using Unity 2017.1f03 for the record)

    In order to reproduce this issue, simply attach a projection renderer to an object that is disabled, and than enable the object while the game is running, and you see a huge spike in performance. I attached a picture of the profiler spikes. Super easy to reproduce in a level where the terrain actually has detail in the mesh (Using DX11 on PC)
     

    Attached Files:

  41. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @grujicbr - Enabling the single projection initializes the entire system which kicks in the shader replacement drawing the terrain. I'm not sure why but drawing the terrain with replacement shaders appears to cause the terrain to build visible detail meshes in advanced.

    I'll see if I can figure out why and find a solution, but for now I'd suggest having an active decal in your scene on startup, so the system initializes straight away and you get the 0.2 seconds spike as part of startup instead of at run-time.
     
  42. grujicbr

    grujicbr

    Joined:
    Aug 19, 2014
    Posts:
    18
    That is what I'm currently doing, just a bit annoying to have a large spike at the start of your game scene load...
     
  43. 5566s183

    5566s183

    Joined:
    Apr 5, 2013
    Posts:
    5
    I used the Version 2.0 to make blood, but the fps of my game is not good as Version 1.6.
    After having an active decal in the scene, the fps immediate decrease about 15 fps and keep.
    I ticked the instanced box on the projection renderer. One or a lot of active decal in my scene, the fps looks almost the same.(Decrease about 15 fps.) The GPU instancing with per-instance properties should have worked.
    My scene is made by using Terrain.
     
  44. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @5566s183 - If you where using deferred in the 1.6, the new system will have a larger upfront cost. I've switched from using command buffers to a technique that uses shader replacement. Command buffers had the advantage of being able to use the in-built deferred buffers as the depth/normal source, so didn't require shader replacement/ any upfront cost. The problem with this approach however, was that all the culling / drawing of the projections had to be handled in C# code, which is insanely slow and scales very poorly (Even with culling groups) and that masking then had to be handled by command buffers as well, which also had to be have it's own culling and was kind of tedious to setup. In the new approach we draw our own depth/ normals/ masking up-front in a single replacement pass and let Unity handle culling and drawing the decals in C++. This approach scales significantly better and handles masking at the same time for no additional cost :).

    Fps is not really the best metric to judge performance, as going from say 900 to 885 frames per second is a difference of 0.018ms in processing time, while say 30 to 15 is a difference in 33.33ms in processing time (Don't get me wrong, losing 15fps no matter the case is still clearly unfavorable). Try and judge performance via the ms (next to the frames per second). This is the time taken to calculate and render the frame in milliseconds by the bottleneck of the system (either main thread, render thread or GPU). This way if your aiming to hit 60 fps you know you have 16.66ms (or 33.33ms for 30fps) to work with and a clear linear indication of how much space you have left to work with :).

    Ideally the system shouldn't take up more than 2 or 3ms unless your drawing tens of thousands of decals. Most of this will be up-front (ie. once the first projection hits it will initialize the system and start rendering the requisite shader replacement) but from there you should be able to comfortably pile on a few thousand decals. For example, on my PC the minion demo scene requires roughly 0.8ms to run the requisite shader replacement, and 0.2ms to draw all the decals in the scene.
     
    Martin_H likes this.
  45. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
    Hey when you release something make sure to make a build, so it catches places where you use editor only stuff. Right now that's breaking builds.
     
  46. Llockham-Industries

    Llockham-Industries

    Joined:
    Aug 4, 2013
    Posts:
    262
    @snacktime - agreed, I'll be uploading a build in a few days, I expect I missed a few other things as well. Thanks for the bug reports. You seem capable enough to drop #if UNITY_EDITOR around where it catches and the using statement, for anyone else though, if you need to build immediately hit me up at Support@LlockhamIndustries.com, I'll send out builds with the bug fixes.
     
  47. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,355
    Ya that's what I did it was an easy fix
     
  48. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,416
    Humm, I don't know about shader replacement techinque introduced in 2.0. I can understand the reasoning but the performance difference will largely based on how complex the actual background scene is that the decal is being drawn.

    It sounds like it is doing a full forward rendering of the scene using replacement shader and then uses its data to render the decals. This may prove to be ok, if there is other post processing effect that already does this anyway and reuse its depth and normal texture, but if it is not, the "up front" cost may be more expensive than the performance saving of decals being drawn afterwards. This will be especially true, if there are not that many decals to draw in the first place.

    So I guess it will come down to the usage cases... the problem is that after updating to 2.0, I am not sure which one would be better. Darn.
     
  49. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,416
    Also for PS4, you have to use sampler2D not sampler. I know... It's PS4...
     
  50. 5566s183

    5566s183

    Joined:
    Apr 5, 2013
    Posts:
    5
    Thank you for your reply.
    I change the Terrain's "Detail Distance" value form 150 to 80 and then the fps didn't decrease so much.
    If my terrain have no grass, the fps looks almost the same.