I’m currently working on a project where it will be necessary to switch Materials during runtime or at least change Material Instance parameters for some texture based effects and I’m not sure how to go about it. I’d really like to ask for some opinions and help on this matter. If you have suggestions on how to achieve something like this I’m happy to hear them.
On to my “problem”:
My characters will have the ability to infuse their weapons with different Attack Elements. I wanted to combine texture effects on the weapon mesh itself as well as particle effects.
The result looks like this.
Currently I work with a skeletal mesh (the sword) and a mask texture which is used for the emissive color (the glowing of the blade). I then created a Material Function for the glow effect and placed it in the original Material of the sword asset.
After that I created a Material Instance from the Material and added it to the skeletal mesh of the sword. I control the glowing of the blade with a scalar parameter value and added a particle effect to the Sword Actor to bring the effect to life.
Right now I’m happy with how it turned out visually, but I struggle with adding more elements to it.
I thought about creating Material Instances for every Attack Element there is and then just tweak the Instance Parameters. This would mean that I have to store the Material Instances somewhere and swap them out during runtime when the Attack Element changes.
The question is, is this a feasible idea or will this lead to performance problems? I could either use **one **material instance and tweak the parameters during runtime or I’ll just change the Material Instance which will be created beforehand for each Attack Element. But I don’t know which solution is better in terms of shader complexity and performance.
Thanks in advance and please let me know what you think and if there are other solutions all together for these kind of effects.