Changing MaterialParemterCollection Value via Blueprint

I’m trying to change the opacity of a static mesh at runtime, so after doing some research, I came actoss MaterialParameterCollections. I’ve set up a scalar parameter for the opacity, 1.0 by default

and hooked up a material expression scalar parameter to the opacity option in the material I want to change.

19710-materialdefualt.jpg

Changed the blend mode to Translucent (which cause the mesh to have a lower opacity even at 1.0 for some reason. Same goes for additive.) and in the level blueprint, on F key press, I call Set Scalar Parameter Value with my collection and parameter name that I created as well as 0.0 as the parameter value.

When I run this however, nothing happens, but it does pass through the function still. I’m lost at trying to debug this. I’ve tried doing some more research online, but am coming up short on finding a solution.

Are you using 4.5.0 or 4.5.1? Apparently there was an with Material Parameter Collections in BP’s in 4.5.0 so you’ll need to download 4.5.1 if that is the case.

Are you able to show a screenshot of the setup? I also had some issues with MaterialParameterCollections not working correctly from a blueprint.

If you try to lower the opacity will it not change as well, or is this only that it will not become fully opaque?

One with MaterialParamterCollections I found is that you need to re-run any changes that are made in the construction script when the Begin Play event is fired from the event graph. Any changes made are lost when a play session begins or ends.

Also have you tried using a regular material instance parameter instead of the collection parameter, and if so did it work correctly?

Oh, it is the parameter node you are using. You need to use a Collection Parameter instead of a Scalar Parameter.

I’m running 4.5.1.

Uploaded the screenshots.

If I change the opacity in the material editor and apply it, it does change, but not when I try to do the same thing from blueprint. A weird I experience though is that on Translucent and Additive Blend Mode, the mesh will never 100% visible at 1.0, but rather slightly opaque.

Since I’m using the level blueprint, I don’t believe I have access to a construction script.

I also have not tried using a regular material instance parameter as I’m new to working with materials and the first thing I learned was MaterialParameterCollections.

Ok looking at your blueprint setup, you have a MaterialParameterCollection being set with your Value variable, however in the material you have a MaterialInstance parameter connected to the Opacity slot.

To fix this, in your Material delete the parameter currently plugged into the Opacity slot, and replace it with a “CollectionParameter” (see image).

Drag that node onto the canvas, then in the details panel set “Collection” to the name of your parameter collection, and “Parameter Name” to Opacity (which will be in the list when clicked).

You could also switch your blueprint to use the instance parameter, but since you have the collection set up already, the above method will be easier.

Hope that helps! :slight_smile:

I am not sure the exact reason why that happens, but the current implementation of translucent surfaces in the engine does have some issues. Epic is currently working on implementing a Forward Rendering pass for translucency that will greatly improve the quality of translucent surfaces. However in this case where you wan’t to be able to go fully opaque, I am not entirely sure if this is a limitation of the current Deferred Rendering technique, or actually the intended behavior for a translucent material.

So I’m not positive what the best approach would be to get a fully opaque translucent material at the moment, you could always switch the mesh material to another material that is opaque when a key is pressed, but it depends on the object and how smoothly you want to transition between materials.

That fixed the opacity so thanks for that! Any idea why using the Translucent or Additive don’t render the mesh at 100% opaque when the value is 1.0? When I change the blend mode to Opaque, it renders fully, but then I can’t change the opacity.

Yeah that fixed the blueprint, but for some reason my mesh still renders with a lower opacity that 1.0 when it is set to 1.0 using Translucent and Additive blend modes.