What is the best way to temporarily overlay a mesh with another material?

Hi,

I’m looking to apply a quick white flash to a characters mesh when the character is damaged in a typical arcadey fashion, however the only way that I know this can be done is through sending a parameter to the material.

The issue is that I have lots of characters, each with lots of materials, yet I want this to be able to be applied to any of them without having to add parameter logic to every single material and control them independently, which would be horrible. This needs to be independent of the original mesh / materials of the character.

One other way that I can think of would be to duplicate the mesh, parent it to the original and somehow make sure all its bones match up, then apply a parameter-controller material to that mesh which extrudes very slightly causing it to draw in front of the original material. I think that would be much better than the first option, but still feels a bit odd, having two skeletons and all.

Is there any better way to do this?

Thanks

bumping this

Acren, Did you ever figure out the best way to do this?

What I did was make a standard character material function that receives parameters for dynamic effects and add that to all character materials that need to be affected.

So one effect might be for the damage flash mentioned in the OP, another might be for being frozen and turned to ice.

Then whatever is controlling the effect uses an interface to get the dynamic material instances and sets the parameter for that specific effect.The material function within the materials gets the parameter data and can render material effects without each individual material having to worry about it.

Perhaps not ideal if you only need some effects on some characters because it will run shader logic for all of them, but in that case you can make separate material functions for each individual effect and another for each set of effects which contains the functions for the individual effects.

Another thing you might want to look into is the new mesh decals in 4.13 but I don’t know too much about that.

Would you mind expanding on this a little? I’m having the same issue. I have one mesh with many materials attached. I’ve created a function called “DamageTaken” which takes a single float as an input, and depending on the value will output either a white or transparent colour. I have attached this function to the “Emissive colour” node on every material in the mesh… but I cannot figure out how to call these functions from within C++ without arduously iterating over each material and changing the input parameter manually. What method did you take?

Yeah, you are going to have to set the parameter on each material. In blueprint you can plug an array directly into “set parameter” node, but in C++ you might want to write a static function you can reuse for setting a parameter on an array of materials.