Search Unity

Question Any other approaches to adding explosive burn/dirt to a volume?

Discussion in 'High Definition Render Pipeline' started by dgoyette, Jan 10, 2021.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    An effect I'm trying to achieve is that when an explosion occurs, it should burn/darken objects nearby. Imagine a bomb going off in a room. The areas right next to the bomb would be very dark/burned, and ideally that would fade the further you get from the detonation point.

    I've tried two approach to achieving this effect, and neither look very good. I'm wondering if anyone has ideas on other approached I could take. I'm in HDRP 7 in Unity 2019.4 LTS, and unable to move this project to a newer version of Unity.

    Here are the two things I've tried.

    Decals:

    I have a few "explosion" decals. When an explosion occurs, I raycast in six direction from the explosions, and instantiate a decal at the point I hit something on a valid layer. I scale the size of the decal based on the distance from the explosion. This sometimes looks "okay". But you can see on the left side of this image that because decals don't have any angle limits, the decal looks really awkward if there is ever any curved, or not completely flat geometry. On the left here, the thick line on the floor is the decal trying to draw on the floor, but it's at a 90' angle to it.

    upload_2021-1-10_10-45-24.png



    Distance-based shader detail:

    I also tried applying the effect within a shader, where I just add some dark Detail within a certain volume of an explosion point. Here you can see the explosion point being moved, just to show the effect.

    DirtShader.gif

    This is nice because it's easy to fade out the intensity the further from the explosion center. But it has some big downsides:
    • Anything that should support burn marks needs to use this shader, or a shader to which I add support for this feature.
    • Because the shader just tests for distance to a center point, this could apply dirt through walls to surfaces on the other side. Imagine if there was another room directly behind the room I've shown here, with just 1 meter of wall between them. The walls in that room would darken because if this shader. Maybe I could improve this to determine a box volume rather than a sphere of influence...
    • Shader don't support arrays of data (as far as I know) which means I could only have one explosion active at a time. Unless there's some way to pass in multiple positions to a shader.

    Anyway, that's what I've tried. I'm curious if there's another major way I could be approaching this.
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I'm dusting off this thread, but this time I'm on Unity 2021.3. The same question remains, though. I now have angle fade on decals, which is nice. But placement of the decals remains awkward. Just wondering if anyone else has an approach they're using. I kind of wish there was a spherical decal projector.