In Niagara I have a “Skeletal Mesh Component Renderer” with animation and want to change it’s color, but can only set a Material Override that can’t have User Parameter.
Is there any way I can change the color via BP?
In Niagara I have a “Skeletal Mesh Component Renderer” with animation and want to change it’s color, but can only set a Material Override that can’t have User Parameter.
Is there any way I can change the color via BP?
Hi there @espr3ss0,
What you’re really looking for is a way to communicate a variable to each particle, which will need to be done inside the Niagara System since a blueprint can’t loop over each particle (well, there is something called Data Channels, but you don’t need that right now). I’ll walk you through how to do that, and if you want to then expose it to Blueprints, you can.
To make color changes within a Niagara System, you’ll want to use Dynamic Material Parameters. This is what allows Niagara to send information to mesh materials. you can create a variable-let’s call it MyColor. (If you want to later expose this to User Parameters you can just put your parameter in for the value).
Then, we’ll create a Dynamic Material Parameters module. Technically, it only accepts floats as inputs so we’ll need to specify R=MyColor.X, G=MyColor.Y, B=MyColor.Z
Then, you can use these input values within your skeletal mesh material.
Keep in mind, you can pass values in other than just color. The one I use the most is Normalized Particle Age to control effects over an individual particle’s lifetime. Also note, as you can see here, you can write to up to 4 indexes, AKA send up to 16 floats to your material.
I have already tried that, it works with a Static Mesh but not with the Skeletal Mesh Component Renderer.
Any chance you could specify how the Material is applied, is it an Override or just whatever the Material is on the SKM?
Hi again,
Yeah, just did some testing on my side and I’m seeing the same thing- no way to overwrite the color within the Niagara system.
That being said, looking at the official documentation for the Component Renderer, they recommend that you create a custom component and set any changing variables there. I tested this out on my end and it is working! I’ll walk you through it:
To create a custom skeletal mesh component, you’ll have to create a new blueprint and search for it in the “All Classes” panel
Then, in your new component, you can set any skeletal mesh settings you want (keep in mind you can also set these later in the Niagara System too) and then you’re going to need a Color variable
Now, for setting the color, you could do this through a Dynamic Material Instance, but this would cause a material to be created for each component. The more efficient solution is to use Custom Primitive Data. This allows each component to maintain its own parameter values without the extra cost associated with more instances. To set this up, in the material you’ll need to create a parameter (it can be a scalar or vector, but for a color change you’ll obviously want the vector), then in the Details of the parameter, look for the “Use Custom Primitive Data” bool and check it. This will be where your color is being set to attach it appropriately.
Back in your custom component, we’ll need to set the color on tick so it updates every frame. To do that with custom primitive data, this is the logic you’ll need, with the input being your color variable:
Now back in your Niagara system, you can replace your Component Type with your new custom component
Now you’ll have a new section under the component properties called “Default”, and in that section you should see your color variable. Use the dropdown to connect it to your Particles.Color
Now, you can adjust your particle color as normal, and each component will receive the changes.
Good luck! Let me know how this goes and if you need anything else!