Hi there, we need some help with the performance using the Decal Projectors in HDRP.
Basically if you shoot an enemy, blood comes out, and then it paints the floor red. That works perfectly using the decal projector. But the performance drops massively from each shot, which is quite weird considering I read that some people made tests with 500 decal projectors and saw basically no drop in FPS. Sadly this isn’t our case, we start with about 130 FPS and after a couple of shots (10-20 decal projectors) and end up with 80 FPS on a 1080 Ti.
I wrote a coroutine to delete the decals after 10 - 20 seconds, and that works, but feels like a cheap solution to a clearly much bigger issue (if in the timespan of the 10-20 seconds the Player rams the entire level then he would be at 0 FPS lol, of course I could clamp the max decals but where’s the fun in that).
This are the settings on the HDRP asset:

We tried using the default Unity Shader and then made a custom one using Amplify Shader Editor, performance was the same.
The texture used for the blood was compressed to basically pixel art just for testing in the import settings (32x32 on high compression) and no change in FPS.
We are using Unity 2019.4.1f1 with HDRP 7.3.1 (the one that’s 2019.4 verified).
Thanks!
Okey, I found the cause of the problem, but now I need a solution to a new issue.
When a blood decal spawns, we create a new material to it based on the one that the decal projector has, and re-apply it, so we can change its color, size (a noise inside the shader to make it look like its “spreading”), and other cool effects.
Sadly by only doing the new material part Unity dies in performance (I assume that it makes super performance optimizations since all of the decals share the same material).
Of course we can’t really skip this part since if we change 1 of the blood properties all of the others get changed equally (blood that was disappearing now reappears due to a new one getting spawned since they are sharing the material).
How can we edit the properties of the decal material without having to create an instance of it each time we spawn a new one?
I’m thinking of Material Block Property but I can’t find a way to use that on a Decal Projector.
Did you find a solution for this? There’s a lot of cases where being able to modify the material property block for decals would be useful!
We haven’t and at the moment we’ve stopped trying. The blood is functional at the moment and the only effect we added is a global one that acts on the shared material. If anyone finds a solution we are still listening!
Great improvement!
Will it be backported to 2021.2? Doesn’t seem like a big change
Yes, it will be backported in both 2021.2 and 2020.3
That’s excellent to hear! Thanks! We are actually planning on perhaps moving to URP to support the Nintendo Switch, and seeing the title of the PR makes me wonder if same performance issue happens there since this fix applies only to HDRP.
1 Like
That shouldn’t be needed for URP as they are using another kind of system for decals
1 Like
Wow now that’s what I call a result! 13.39->2.60 ms!
3 Likes
Si just to be clear, we can’t use property blocks on decals right? Any workaround?
i used decal projectors also for blood and did an object pool. basically we can spawn for ex 100 unique materials in the start of the game and pull them when we need. hope it helps. also consider using timers not coroutines maybe it will help (not sure but worth trying)