Greetings! I come from the UE2/3 era where you could spawn a decal and “attach” it to a specific actor to make the decal only project on that actor.
In UE4, I can’t seem to find a way to do this. I’m spawning tire track decals and attaching them to the mesh that represents my terrain, but when I drive over them, they project onto the wheels of my vehicle as well. Searching forums/answerhub, I see similar complaints going back years of people having problems like bullet decals projecting onto characters when they get close to a wall.
The recommended solution seems to always be to turn off “receive decals” on the mesh you don’t want decals to project onto. This should work for my specific case right now.
But I’m wondering for later on: say I wanted to support applying other decals to my vehicle. Is there no way at all to attach a decal to an actor to make it only project on that actor? Is this a side-effect of deferred decals? Or is the engine just lacking in this area right now?
You can by using the CustomStencil to mask the decal so it only affects objects with a specific CustomDepth stencil value. Any other actors with “Render CustomDepth Pass” enabled and a different stencil value won’t be affected by the decal. This way you can have multiple decal materials, each one targeting a different stencil value:
Remember to set r.customdepth.order to 0 in your DefaultEngine.ini file if you’re using dbuffer decals, otherwise they won’t read the correct customStencil values.
You must reorder the node succession. Check screenshot for ref. First add the value from the Divide node to the Bitmask input, then the result of the bitmask to the B input of the Multiply node (the one that doesnt have connection), and lastly drag the result from the Multiply node to the Opacity input.