Download

Directional bullet holes?

I’ve been trying to figure out a way to make destruction effects like holes and things for quite some time, but all end in headaches and roadblocks.
The newest failed attempt uses a texture render target as an opacity mask. The idea is when a shell hits the mesh it would draw to the texture, like Training Stream - Blueprint Drawing to Render Targets Overview - Sept 20 - Live from Epic HQ - Events - Unreal Engine Forums ,
then maybe add a cylindrical collision component that allows subsequent shells to pass through.

Problem is this doesn’t take into account the angle of the shot, so the question is how to draw a skewed mask based on the trace vector

MaskSkew.jpg

I’ve tried multiplying the uvs based on the trace and managed to get it to skew, but have no idea how to rotate it. I’ve also tried 3d traces in the material but they won’t draw to the render target.

A completely different way of tackling bullet holes is equally welcome :cool:

Well, You are using the Wall Normal as the Rotation. Use your Trace instead. Make sure that your decal is big enough, so it reaches the wall in all points.

It’s not actually a decal- it’s a material that offsets a radial gradient, draws it to a render target, then uses the target as the opacity mask. I don’t know how to rotate the uvs based on the location of the gradient, since using a custom rotator with skewed coordinates doesn’t work, at least from my experience.

Try to start with some primitive. Maybe capsule. Spawn it in impact location and rotate by impact normal. This will give you more visible results to understand.

I think texture’s stretching depends on dot product between surface normal and impact normal, with some limits, to prevent it’s scale to infinite value.
And it’s rotation must be calculated with surface up vector and impact normal.
You need UV rotation between 0 and 3.14 I think, so it’s just some linear formula there.

Yep that’s what I came to after some trial and error- although the impact normal just returns the surface normal, so I took the trace and projected it onto the surface normal, which I’m sure is wrong but wouldn’t know since not math genius.
Could you explain why it would be between 0 and 3.14? The custom rotator takes 0 - 1 with 1 being a 360.

I’m unsure how exactly to plug it in since the skew just multiplies the horizontal coordinates, so when it rotates the skew direction stays the same :frowning:

You could use 2D Scene Capture, along with rotating (with bullet) decals - then subtract

(1- Opacity)

and set for Material then multiply by negative

-1

Then set texture from Scene Capture into Material BP.

Why not make it so that bullets don’t penetrate under a certain angle?
Most projectiles will probably just ricochet away from the wall when seen from the angle of your screenshot.

That’s an interesting thought- can’t visualize the best way to set it up but there’s no reason that wouldn’t work, but that would only work for planes unless it were a cube capture- which would really hit performance in an actual bullet time scenario on multiple objects.

Yep that’s true, but even then they would leave a scratch mark. High velocity things that pen at a high-ish angle would leave a long-ish hole too, enough that it should ‘be a thing’.
What would really be nice is if there were a way to make 3d material traces draw to a render target, then you wouldn’t have to mess with uv skewing nonsense.

Here is my example project with all this stuff.

But you know, for me visual results of material scaling is weird. I’d rather make few holes textures, for different hit angles, and switch them.

Wow, thanks! I’ll be sure to pick apart all the math to see where I dun goofed. That puts an end to that conundrum :smiley:
Still fantasizing about 3d material traces being drawn to the render target, but this will certainly do for now.