Search Unity

Resolved Improvements to decals

Discussion in 'SRP Dev Blitz Day 2022 - Q&A' started by PaulMDev, Sep 28, 2022.

  1. PaulMDev

    PaulMDev

    Joined:
    Feb 19, 2019
    Posts:
    72
    Decals are pretty great already but would still like to see stuff like :
    -pixel displacement
    -better workflow when using a texture atlas
    -complex projection shape (maybe to project a 360 texture all around the center point or to curve around an angle)
    -a way to paint a mask on the decal or something similar.

    Is this actually possible to do ? and if yes would it ever be added to Unity ?
    Or maybe these are just bad ideas, i don't know...
     
  2. Jonas-Mortensen

    Jonas-Mortensen

    Unity Technologies

    Joined:
    Jan 3, 2020
    Posts:
    110
    Hey @PaulMaget. Happy Blitz Day!

    Shader Graph is here to save you!
    Whenever you are using the Decal System I would advise to do a custom shader with the Shader Graph decal target. Decals are so different in the way the data is packed and what features they need so we decided to rely on shader graph as much as possible.

    Pixel Displacement
    Shader Graph has two displacement nodes (Parallax Mapping and Parallax Occlusion mapping) which are made exactly for this. I've attached a photo were I use it for the cracks in the ground

    Texture Atlas
    Could you explain a bit more what you are struggling with? The decal projectors have settings for offset and tiling so that should allow for you to atlas your decals and set per projector UVs.

    Complex Shapes
    Shadergraph is great for this as well. With the Position node (set to object mode) you get a position of the projected fragment within the bounds of the projector. This means that you could project anything within the bounds using any projection you'd like (as long as you know the math for it). In the URP package samples we did something similar by faking spot light cones using decals. Maybe take a look at that? In any case I think this is a great idea for it's own sample that I will try to add.

    Mask Paint
    Could you explain the use case a bit more? Just so I know what you are trying to achieve :)

    Decals.gif
     
  3. PaulMDev

    PaulMDev

    Joined:
    Feb 19, 2019
    Posts:
    72
    Thank you for answering !
    I'm not working on any project that uses decals so this is more a feedback about the workflow. (but thank you for sharing some workaround, I didn't know all of them)

    Yes I should probably use shader graph more often, still I don't understand why pixel displacement is not part of the default decal shader.
    Also cool gif, I love it ! Great example of what's possible with decals.

    It's technically possible to use decals with a texture atlas but having to manually change the offset is tedious, having something in the UI for that would be nice.

    I didn't know this was possible, I'll look into it.

    I'm talking about a way to erase a part of the decal by painting a mask on it, this would allow more variety and have decals more connected with the world around them (like if want a puddle to go around an object without having to make a new decals just for this puddle).
    I also thought about a decal paint tool that I've seen in an Outlast Trial BTS :

    I think that it's an Unreal tool and I don't know exactly how it works. But having that in Unity would be very useful.
     
  4. florianBrn

    florianBrn

    Joined:
    Jul 31, 2019
    Posts:
    53
    Hey! Just chiming in to ask if there's any chance we'd get Depth Offset on decal shaders graphs? Some effects would really benefit from this.
     
  5. Jonas-Mortensen

    Jonas-Mortensen

    Unity Technologies

    Joined:
    Jan 3, 2020
    Posts:
    110
    @PaulMaget
    I think you will be really happy with what shadergraph has to offer. We could very well had put displacement on the default decal material but my experience with "uber" materials like this is that there is always something missing. Also when it get's around to compiling those uber shaders they take a long time because of the variants introduced by all the features supported by the shader. In shadergraph you are in full control and get minimum built time because of it.

    Having more automated workflows for decal atlases would be nice. Not something I see us getting in the near future though. Same goes for the mask. Once URP has migrated fully to render graph (a backend refactor, not a new graph tool) it will be easier to modify URP frame resources meaning you could do your own custom draw tool that "erases" on the DBuffer.
     
    PaulMDev likes this.
  6. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Hi,

    Is this decals use sample available in github or asset store sample projects ?

    Thanks
     
  7. EWimsett

    EWimsett

    Joined:
    Feb 16, 2017
    Posts:
    11
    Bump, keen to check the sample also