Decal / location based opacity masking question(s)

Hey,

I’m currently working on a damage system for the ships in our game. Meaning that I’m looking to find a way to project a hole or some kind of damage texture onto the surface of a ship model at the location where the ship is hit by a cannon ball.

I’ve been looking for about 2 days now and what I have found and tried so far is location based opacity which is itself a great trick, but the problem with it is that it’s always a sphere (a box and cylinder are possible too though). But what I would like is to use a custom black and white texture as mask. I have tried using “get UV’s from collision” but I can’t seem to get that to work. I retrieve the uv’s from a raycast and then inject them into 2 scalar parameters that feed the uv’s for the mask texture, but it doesn’t work no matter what I try.

The other thing I’ve tried is decals, but these are very limited in their use and their projection is just never the way it should be. I can actually retrieve the normal of the hit surface and use this to “align” the decal properly, but this only works when the hit surface is a big flat side, as soon as there is any other geometry around it the decal will still stretch and look ugly. So as far as I see it, decals are not an option. If there was some kind of wrapping feature that would make them viable again, but as of now that doesn’t seem to be the case.

So, are there any other ways to achieve something like this? Or is it simply not possible?

I have, however, found a VERY interesting video of RyanB showing how he uses a position texture that he somehow rendered instead of using the “uv from collision” node. I have no idea how you render out position textures of a meshes and how you use those textures in material. I’m guessing the colors on the textures are somehow representing v2 coordinates but how exactly, no clue. Does anyone know more about this approach?

One other thing I’m wondering about is that world to uv coordinates or raycast hits to uv coordinates is great and all, but what as far as my simple mind can fathom I still see the issue of the fact that a uv coordinate is still a single corodinate (point), wouldn’t rendering a mask at said point also apply it to neighbouring UV islands of the unwrap, meaning that the mask would not only appear on the location itself but also on other random parts of the mesh? How would you go about fixing that? I guess you’d have to somehow detect the edge of a UV island and make sure the mask doesn’t render past that, but God that sounds incredibly complex. xD

Any help, tips or ideas would be very appreciated.

In the Asset Sharing forum there’s an example of damage mask stuff in the Realtime Simulation and Volume Modelling Experiments Livestream Plugin Content thread. It uses render targets though so I’m not sure how performant it is and you would probably have to find some clever way to find the impact location. Shouldn’t be too hard though, the original version was done with a line trace: Character Damage using Render Targets in UE4 - YouTube You could also use textures this way for the damage part of the shader.

There’s also the L4D2 wound system but I haven’t seen an example of that in UE4.

Yeah, that’s the video I was talking about. But I have no idea how to do that. Anyway, I’m waiting for DON’s mesh painting addon which pretty much has everything I need. :stuck_out_tongue:

I said that there’s a plugin that has the shaders/setup already, you can open them and see how it’s done.