Search Unity

Question Object to leave a wet spot on the ground

Discussion in 'Visual Scripting' started by Rocker-Marshall, May 29, 2023.

  1. Rocker-Marshall

    Rocker-Marshall

    Joined:
    Jan 24, 2013
    Posts:
    7
    Hello all,

    I have the following visual feature in mind for my game:

    I want an object to leave a wet spot on the ground it is moving on.



    Hopefully you can see from the pictures how it is meant. The implementation can be extremely simple as you can see in the pictures. A circular darkened area of the texture is enough for me. The game has no graphical demands, as it is retro.

    I already tried to solve it via spawning decals - That is way too complicated, I have a feeling. My next approach would be to have a dynamic alpha map generated, which would then be mixed with the ground texture (Splatoon-like) - here, however, I don't see any land at all in the programming and have the feeling that the textures could become too large.

    In addition, there would possibly be the case that the created circles should disappear again over a certain time. But that would only be a plus for me.

    Do you have a simpler solution (particle system?) or a good approach for me?
    I am glad about any answer.

    Many greetings
    Marcel Pabst
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    I think spawning and shrinking decals would work fine, just make sure to use object pooling for more stable performance.
    Another method would be a custom shader, where you would input the position of the wet object, and leave a trail that gets smaller over time.
    You could also generate textures on the CPU to change the metallic or other textures, which is pretty fast, especially if you use jobs and burst
     
    Rocker-Marshall likes this.
  3. Rocker-Marshall

    Rocker-Marshall

    Joined:
    Jan 24, 2013
    Posts:
    7
    Thanks for your quick answer!

    Okay, so decals would be a good solution here after all? My problem so far was that you saw the overlap of the spawned decals, but all right, then I just have to implement it correctly

    A custom shader would also be awesome. Would you have a rough approach to weave a trail in here? That sounds pretty complex to me
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    Not sure about the decal overlap. Maybe a decal shader graph or different blend modes would work well?
    For the custom shader, not sure exactly how to do this, but you can use the time node in shader graph and combine that with a position vector3 and then lerp the size or something like that? That will take some figuring out
     
    Rocker-Marshall likes this.
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,448
    Rocker-Marshall and DevDunk like this.
  6. Rocker-Marshall

    Rocker-Marshall

    Joined:
    Jan 24, 2013
    Posts:
    7
    I've tested out a lot of things, but the best solution so far has been to just make the edges of the decals very smooth so the overlap isn't seen as much. But somehow it's not a nice solution. I'll try again with the trail and shader graph :)
     
  7. Rocker-Marshall

    Rocker-Marshall

    Joined:
    Jan 24, 2013
    Posts:
    7
    It's not a terrain, it's a non-flat mesh and my current test level is about the size of Wuhu Islands from Wii Sports Resort, if that's a good benchmark :D Here it needs a tiled texture, so I think it's hard to make an alpha map that's on top of everything.

    And thanks for the links, that looks very helpful. I will check it out!
     
  8. Rocker-Marshall

    Rocker-Marshall

    Joined:
    Jan 24, 2013
    Posts:
    7

    Here you can see the current status of the effect. It is okay-ish, but you will not recognize the ground as wet. But the sharper the edges are, the more overlapping occurs
     
  9. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    Might need a custom shader/texture then
     
    Rocker-Marshall likes this.