Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Decal System - WIP

Discussion in 'Works In Progress - Archive' started by Dantus, Jun 20, 2012.

  1. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    This thread is obsolete. Please use the official Decal System Thread instead.

    The Decal System will be published in the Asset Store for free as soon as it is ready. At the moment the documentation is not complete and proofread, several videos have to be created and the code needs to be cleaned up. That's why it is still in beta :D.

    Try it out, give feedback, have fun!

    Download: Decal System Beta 2

    Introduction video (was created for Beta 1):

     
    Last edited: Jun 29, 2012
  2. LeakySink

    LeakySink

    Joined:
    Apr 9, 2012
    Posts:
    141
    This looks like a really nice tool, I particularly like creating them on the fly from inside the editor. I'll be picking this up.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hi dantus,

    that really looks gorgeous!
    especially the fact that your decals work with the terrain is just pretty amazing and should enable anybody to create much more convincing and lively terrains without having to go with more than 4 terrain textures.

    lars
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hi,

    i just gave it a quick try – and it works pretty well even on terrain.
    although it produces some artifacts when the terrain switches to a lower LOD.
    raising the offset-paremter in the shader to "-5,-5" loweres the problem but gives you visual artifacts when coming closer as the decal seems to float above the terrain.

    any suggestion on how to solve this?
    is it possible to generate different decal meshes for the different LOD states of the terrain based on the number of pixel errors in the terrain settings? and is it possible to predict when the terrain is going to switch to a different LOD level?

    another possibility might may be to dynamically adjust the shader’s offset value according to the distance between camera and decal: far distance --> high offset / low distance offset -1,-1…

    or adding a vertex function which increases the y-position according to the distance.

    the easiest way i guess would be to fade in/out the decal on the terrain… but that would limit the use of decals on terrains.

    may be there will be some help from the guys at the shader lab thread: http://forum.unity3d.com/threads/14...ted-per-vertex-on-distance-to-camera-possible

    i would love to see decals happen to work well with the built in terrain.

    anyway: great job!

    lars
     
    Last edited: Jun 20, 2012
  5. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    733
    awesome tool...great job
     
  6. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Thanks for the positive feedback!

    @larsbertram: Your obeservations are absolutely correct and there is unfortunately no general solution I could find. Predicting the LOD or even it's shape is not possible without an extended terrain api. Just added the terrain issue to the documentation. Your solutions sound interesting! It very much depends on the application which solution may work better.
     
  7. Max_Damage

    Max_Damage

    Joined:
    Nov 4, 2011
    Posts:
    50
    Very nice. I'll buy this as soon as you have it on the store.
     
  8. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You won't have to buy it, because it will be freely available. Donations will certainly be welcome.
     
  9. Pixelstudio_nl

    Pixelstudio_nl

    Joined:
    Jun 22, 2009
    Posts:
    179
    Looks great!! and good thats it's free!
     
  10. ivanzu

    ivanzu

    Joined:
    Nov 25, 2010
    Posts:
    2,065
    Thanks! This really came in right time for me:).
     
  11. rstorm000

    rstorm000

    Joined:
    Aug 19, 2010
    Posts:
    229
    Looks nice, I didn't hear in the video. Are these projectors the same as the Unity Projectors or do they process differently. I was wondering if it would be good for something like bullet holes where there could be potentially 100s with hopefully no slow down. This works fine if you generate a plane mesh with the bullet hole on it, but projectors are too expensive when you get past a few dozen. So would this be appropriate would what I'm talking about?
     
  12. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Thanks for the positive replies!

    @rstorm000: No, the projectors are not related to the ones from Unity. The projectors are just used to define where a decal has to be projected and how. If you donwload the Decal System (link is in the first post), you'll find a demo scene. It already contains a bullet hole implementation for demonstration purposes. But be aware that it was not created with performance as the ultimate goal in mind. It is slower at runtime than the decal implementation from the Bootcamp demo, but uses a lot less memory and the meshes have fewer vertices. Another advantage of the Decal System is, that the individual holes are automatically combined into as few meshes as possible.
    Compared to Unity's projectors, decals will be a lot faster, as soon as the computation of the decals mesh is made. On the other hand, if you add a projector to a decals instance, some quite expensive computations will take place to produce the decals mesh.
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    hi dantus,

    i guess using a vertex function and raise the y.position at far distances would be the most general solution.


    lars
     
  14. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Sounds definitely interesting. Though, I don't know if I will have the time to develop it in the near future. And as I am no too experienced with advanced shaders... :D
    Do you know of some reference shaders where the vertex position is changed based on the distance to the camera?
     
  15. Pixelstudio_nl

    Pixelstudio_nl

    Joined:
    Jun 22, 2009
    Posts:
    179
    Interactive update is a tad slow, perhaps you could check it out and see if you can improve
     
  16. TomasRiker

    TomasRiker

    Joined:
    Jan 26, 2012
    Posts:
    48
    I'm wondering: do you use the physics engine (a.k.a. Raycast) to compute the intersections, or did you write your own intersection test?
     
  17. commodore

    commodore

    Joined:
    May 30, 2012
    Posts:
    40
    Will definitely try this when I get home. I've wanted a decal system for a while!
     
  18. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    @pixelstudio: If you are using any lightmapping for the decals, make sure that it is not always updated. But it is very likely that you have some lagging even without that.
    I am aware that the performance with interactive update could be better. The algorithm is very much optimized to produce as few vertices and triangles as possible. Even if there are a few areas that could be improved, I think it will not give noticable improvements, with the exception of multithreading, which will be extremly tricky with this algorithm. By far the easiest way to improve the performace is to use an algorithm like the one from the Bootcamp demo. It uses a lot of memory and produces a huge amount of duplicated vertices, but it is fast! A good combination would be to use the fast one in general and as the mesh is optimized, the slower one would be used to create as few geometry as possible.

    @TomasRiker: The intersection is computed on the mesh level. In the editor its is checked for each mesh's bounding box, if it intersects the projector. If that is the case, the mesh is copied into the decals mesh data structure and in there the cutting operations are performed.
    At runtime you can certainly use a custom strategy and decide which meshes should be affected by the projector. You can use raycasts to check which meshes are in the projection area. That technique is used in the demos to create the bullet holes.

    @commodore: Great! Don't forget: Feedback is always welcome! :D
     
  19. UnknownProfile

    UnknownProfile

    Joined:
    Jan 17, 2009
    Posts:
    2,311
    This looks like it will be fantastic. I'll download it when I get home. Thanks for making it free, also. it's really generous.
     
  20. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,663
    I though this has cost money far away in the past. Could this be?

    However, i'll download it tomorrow when i get the time :) Looks cool so far!
     
  21. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    @rab236: Great!

    @Mauri: There is another decal package in the asset store. But this is a 100% new implementation that has to be tested :)
     
  22. Games-Foundry

    Games-Foundry

    Joined:
    May 19, 2011
    Posts:
    632
  23. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    @gamesfoundry: Thanks for the link. I'll check it!
     
  24. Pixelstudio_nl

    Pixelstudio_nl

    Joined:
    Jun 22, 2009
    Posts:
    179
    Waiting for mesh to be generated is not a problem.
    But it's very hard to move a decal projector now, cause it's constantly regenerating the decal mesh (and perhaps looking for all objects it's affecting and such).
     
  25. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    @pixelstudio: Since I answered you the last time, I found some minor improvements, but reading your description, that is very likely not sufficient. If you are interested, you may send me your scene and I will check what the actual performance bottleneck is and maybe find an optimization that works in general. Independent of how fast the implementation ends up, there will always be scenes in which the calculation is too slow to drag projectors around...
    Have you tried to deactivate "Interactive Update" and press "Update Child Projectors" as you placed the projector? That is the intended workflow for such scenes. I read that you are aware of "Interactive Update", do you think that the way it works now should be improved?
     
  26. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Please do not post in this thread anymore and use the official Decal System Thread instead.​