Change the color of a part of the mesh dynamically

Hello everyone,

I would like to achieve something, but I have no idea how to do it, and especially if it is even possible.

Basically, I want a mesh to change color, but not the whole thing, just a part of it. The color change should be dynamic, so that, based on a threshold (e.g., z-location = 5), the part of the mesh above the threshold is the original color, and the part below is a different color. However, I cannot use color masks or anything static, because the threshold or the position of the mesh will change during play, so I need something dynamic.

I hope I explained myself clearly.

In general, the meshes I want to do this with are meshes with many vertices and materials with textures, including basecolor textures, but I don’t think that’s a problem. The big problem is creating this dynamic color change.

I would like to avoid using other software and do everything in Unreal. Can anyone help me? Thanks in advance.

Would something like this do:

The can be dynamic can be a per instance parameter or be driven by the MPC.

1 Like

Hi Gioele,

In Unreal you can create a “Dynamic Material Instance” (There is a node called Create Dynamic Material Instance") and then apply it to an object. You can then use the nodes called “Set Scalar Parameter Value” and “Set Vector Parameter Value” to set the value of a parameter within a dynamic material instance.

To create a parameter in a material, right click on something and press “Convert to Parameter.” Alternatively, hold S and click anywhere on the material graph for a scalar parameter.

Thank you, very interesting. My task has “evolved” slightly since the last time, so I’m asking you one more thing, maybe you can help me. In the beautiful example you provided, the color changes (and the gradient effect is really beautiful), but if I had an object with a material already applied (and the material had all the relevant textures), would there be a similar way to make it so that below a certain threshold the object keeps the textures but the color is, for example, darker?

This is also a good stuff for me to study, thanks, I’ll try to do something interesting

If your texture is in black and white, you can multiply it by a vector to change it’s colour. If you just want to make the texture darker (even a coloured one) you can simply multiply it by a number. E.G. a texture multiplied by 0.5 will result in that texture being half as bright.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.