Download

Static Switching Between Masked and Opaque

I am trying to find a clean solution to what I think is a fairly common problem. I have a lot of objects in my game that need to transition from being opaque to being masked so that they can be faded out with dithering or dissolved.

I could of course just make everything masked, but that means the pixel shader will be invoked for things like shadows and the prepass even if all it does is return 1, and some driver-level optimizations will be forced off as well.

I could also just make an extra material instance for every object, but that is pretty tedious and adds complexity to all of my blueprints, and requires artists to maintain the correct pairing of masked and non-masked materials.

Is there some way to get the Unreal shader compiler to treat the blending mode as just another static switch permutation so I can set it like any other parameter at runtime?

You can create a material instance and set the shader mode override to masked there.
just make 1 material with the mask node connected, but with the shader mode set to opaque, then make an instance of that material and set its material type override to masked.