Download

Hitmask Multithread

Hello everyone,

I wasn’t sure if I should post here or in the programming section but I will start here in hope to find more infos.

I managed to get something similar to what Ryan has shown during the GDC regarding the dynamic hitmasks (video: https://www.youtube.com/watch?v=Jz050a2OMXE).
I tried to go more in depth and add more effect to it. Right now, I have bullet hole and burning type damage working properly. I can merge both at the same time for example for explosion damage type.

The problem is, I am trying to implement a flamethrower.
The way I apply damage right now is everytime one of the projectile hit the character, it captures the UV map with a SphereMask and update the render target with the new texture using the node “Capture” of the SceneCapture2D.
It become really heavy on performance when too many projectile hit at the same time (I assume that there is too much scene capture done in the same frame?).

You can clearly see the fps drops on this video when the flames’ projectiles hit the character:
https://youtube.com/watch?v=9hHRkhDgv4k

I was wondering if any of you guys have an idea on how I would be able to do these tasks in a separate thread or a way to optimize it.

Hoping you guys would be able to help me :slight_smile:
Edit: ok I watched the video again and it looks like youtube interpolate between frames or something because the frame drop isn’t really visible. But trust me, there is a huge framedrop

Hello, can you please make a step-by-step tut? because im also trying to make as the GDC showing, but i cant get it work.

Multi-Threading it further won’t help you much. The data has to be written to the render texture, which involves locking and unlocking the data which in a roundabout way interrupts the render thread.

To be honest, my approach would be to avoid using projectiles altogether - and instead apply damage in a cone-shape around the weapon, using a single particle system to represent the flame. This is not only miles better for performance, but it’s also more tune-able. Each time you apply damage in the cone, you determine the hit location on the target and draw a material to the render target.

You want to keep that render target as small as possible (at a guess, less than 256x256 IMO unless you only have one or two characters).

Scene Capture is also a crazy expensive way of doing this, if that’s really what you’re doing. Writing a material directly into a render target will be considerably faster.
https://www.youtube.com/watch?v=1Z-V1Buk6z8

EDIT: Just realised the date of the OP…

Hello, guys.
I get it work for my TPS, but the character change material to damaged immediately after one shot, and it change material on whole mesh-not only the hit position. How to fix it, can you help?