Download

How to call Static Switch Parameter in Blueprint?

How can I call a Static Switch Parameter from a material in a blueprint so that I can enable and disable layer materials from a blueprint rather than a material instance?

For example, I want to turn off and on layers of snow, dirt, dust, etc. from a blueprint.

I have tried calling the Switch Parameter from a Set Scalar Parameter Value node with a boolean variable converted to scalar. But it does not do anything when toggling the parameter in the blueprint.

Additionally, I’ve tried using a multiply node instead of the Switch Param and was able to call the variable plugged into the bottom of the multiply node in the blueprint through a Set Scalar Parameter Value node triggered from a boolean variable converted to a scalar. That setup enables and disables the layer from the blueprint but does not save shader complexity like a Switch Param does.

Any way to call that Switch Param successfully in a blueprint or perhaps set this up differently?

Switch Parameters are fully static so by design they cannot be changed at runtime, so you’re gonna have to set it up differently.
If you want to modify the actual parameters individually at runtime then it needs to really be dynamic which as you say, does not save shader complexity.
The alternative is to create and save different material instances with your StaticSwitches on/off and swap materials at runtime, but the maintenance of such a setup can get out of hand really quickly

Thanks for the quick reply.

I could use material instances. But you’re right. That would get cumbersome quickly. For example, I have one static mesh with five texture set variants with slightly different baked normal maps. I want to be able to swap between the texture sets and also enable and disable layers of snow, dirt, etc. as needed in the blueprint.

Swapping between material instances to choose variant A, B, etc. is easy enough and not overly cumbersome. But then making dirt, snow, etc. variants for each baked normal variant would balloon the number of material instances to out-of-control pretty quickly.

Before trying layered materials, I tried using the newer material layers feature. This worked great up until blueprints because I couldn’t figure out how to pass any variables from layer parameters to a blueprint.

Back to layered materials …

Can I swap a material function instance that stores the base diffuse, rough/spec/metallic and notmal textures from a blueprint? If so, I could create blueprints for Prop 01 Snow, Prop 01 Dirt, Prop 01 Dust, etc. and then swap the material function instance in the blueprint to select the baked normal version. Not sure if this is possible, though.

How can I add the Set Layer Visibility node to a blueprint? Been searching and pulling pins and searching but cannot find this thing.