Download

Best way to add visual effects to object / overlay materials

This post was flagged by the community and is temporarily hidden.

The question is still relevant! :thinking:

Generalize the effects to a single system so that you can describe many different effects with the same parameters.

For example, instead of having separate sections for each effect in the material, only have a single “effect” section that has a texture parameter & a color parameter, then set those parameters to the texture & color of the effect. For your example, the poisoned effect uses the texture “poisoned_tex” & the color purple, and the burned effect uses the texture “burned_tex” & the color orange. If you need them to be able to combine, you can either add another set of parameters, use a render target to combine multiple effects into a single texture in real time, or something else.

Some other options include:

  • using stencil buffer and a post process to overlay colors
  • using the decal actor
  • Adding a “shell” or "bubble geometry around the actor for the status

What I would do, though, is use a Material Function that adds any and all effects, and have this Material Function has “amount of poison,” “amount of fire,” and so on as parameters. When you add “stun” as another material effect, you simply implement that in the material function, and any material using that same function ends up getting the same update.

Did I understand you correctly: is your option similar to my second one with creating a material element/section in the mesh of each needed actor, but instead of using a static material with functions of multiple effects generate your own material in runtime with the required textures and colors?

I hardly studied the topic of post-processes, so I’ll take a look and try

I think this tool isn’t the best option for such use at all, since in any case I need to display the effect on the entire actor

again, I think it will be unnecessary complications and additional geometry

So that is similar to my first option? Although after your and midgunner66 suggestions I am more and more inclined to the second one, since when adding a new effect to a function, additional parameters will need to be added only on one material, not on all actors. But I am not at all familiar with the topic of adding sections/elements to the mesh or editing them in any way, I hope learning it will not take much time and I will be able to share my progress soon.

The end result might be similar to the first option, in that every material needs to include the “and apply effects” material function call. That’s a single node, that you add when you first make the material, which is no real extra work.

When you add new effects, you add those effects to the material function only, and all the materials that call this function, get the effect.

On each actor, as part of updating poison-ness, you then iterate through all MaterialInstanceDynamic and set the “Poison Amount” parameter to how poisoned the actor it. This, you will have to do, no matter what the implementation, so that’s no extra work.

That’s why I like the material function approach – it gives you the most bang, even with additional development coming later, for the least buck. If you want another kind of effect (particles? ribbons? animated birds-and-stars-and-spirals?) then you need to implement it some other way, of course.

1 Like

Kinda, but I think your overcomplicating things a bit. If you know your material is going to have effects ahead of time, just put some parameters in the material, then during the game, use a dynamic material instance to change those parameters to make the effect. For example, if you wanted different parts of different characters to glow and change colors, you would have a “Glow Mask” parameter that defines where the glow will be, and a “Glow Color” parameter that defines the color of the glow. Then you set those based on the character and change them during the game. To disable the effect, you just set “Glow Color” to 0.

Of course, this is only the material side; effects can also use particles, too.

Also, there’s multiple ways of achieving the same effect. You’re looking for the “best” way, but “best” is ambiguous (easiest? most flexible? most performant? most popular?) and a method that works for one effect may not work for another.

If there’s only one material, sure, there’s no difference between new parameters on the (master) material, and a material function. However, it sounds like the original poster is using multiple materials, not just material instances:

If you have a character-design-based game, it’s quite common to have material differences between different characters that are more detailed than just what you can do in a single material instance. In that case, the material function will vastly simplify the work of adding a new effect, because you only add it in one place, and all the materials that use it magically start exposing that parameter. (Which, as you indicate, should be controlled on a MaterialInstanceDynamic clone of the material, especially if there’s some chance of you having more than one instance of the same thing in the scene.)

2 Likes

midgunner66, jwatte, thank you both for your explanations and suggestions! After your answers (at the same time, as I wrote, I studied a little the topic of post-processes), I finally decided that would implement this task through an additional layer on the mesh and a separate material with effects functions in it.
When I have something that will work, I will write and share here :grinning:

2 Likes