In this post I’ll show how to do two things: a dissolve effect and changing a material parameter through a BP during runtime in Unreal Engine 4.6
Material setup
It’s best to have the dissolving effect in a material function so it’s easily implemented in different materials. You’ll need a noise texture.
The magic happens with those If nodes, one of them creates the edges by subtracting its thickness from the dissolve amount, the other creates the opacity mask.
In this case I’ll show how to implement it to be usable with both stand alone meshes and particle systems.
Make sure that your material is set to Masked / Translucent. Either turn it on by default or make sure it’s on in your material instance.
Note that the Dissolve Amount you’ll need to start so the material is not dissolved at all may change depending on your texture, in my experience it has varied from 1 to 1.5. Tweak it accordingly. Same with Emissive Offset (which, since it’s a parameter from the MF, can only be modified in a material instance).
BP setup for using with a static mesh
You first create the Dynamic Material Instance by either manually selecting the material you want or doing a Get Material node from what you’ll be using, then it has to be Set to the mesh you want, and we run it through a Timeline.
Because I wanted to have a dissolve for it to appear and one for it to disappear I had the Event BeginPlay run it backwards (0 to 1.3), then the event that is called when I want it to disappear runs it from the start (1.3 to 0). Using the Set Scalar Parameter Value node in the Update output. Make sure you write the Parameter Name exactly as it is in your material.
BP setup for using with a particle system
Make sure the Element Index (starting from 0) is the index of the emitter you want to change the parameter for. If you are using Mesh Particles then make sure it is using the Mesh Material module in Cascade (no idea for Niagara). You can use this newly created Dynamic Material as many times as you want, you’ll only need to update the parameter once and it updates for all.
Debugging
To debug if this is working properly you can, while in PiE, select the particle system/static mesh (press F8 to be able to do that), then look at the material that it’s using, if it has the material name with some random numbers added to it then it’s successfully using a dynamic material instance. Then you can double click on its thumbnail to open it, it’ll be all greyed out, look for Scalar Parameters, open it, and look at the value of the parameter.
🍕