You can see all my setup on the picture. The material parameter collection does not see the material, even though the parameter has the same name applied. What am I doing wrong?
The material is on the left side of the preview, and it has obviously the default default material value, and not even the default material instance value.
Hello Andras2014,
So I pulled this information direction from the release notes of 4.6 and I noticed it mentions using the same names for material instance parameters.
Expose Parameters from Material Functions
Material Instance parameters are now supported in functions. This makes it really easy to expose parameters to material instances. This brings functions to parity with materials, and the same node graphs can be used in either.
The only exceptions are the function input and output nodes which are inherently function-only.
Note: Parameters within a material are set by name, so if you have two parameters named ‘wetness’ in different functions referenced by that material, they will both be overridden with the same value in the Material Instance. This can be used intentionally but if you don’t want to share the parameter, give it a unique name.
Be sure to use a unique name for your material instance parameters. Also have a look over the documentation for ‘Material Parameter Collections’ to see if you might have overlooked something.
Material Parameter Collection Documentation
.unrealengine.com/latest/INT/Engine/Rendering/Materials/ParameterCollections/index.html
Thanks,
Hello Andrew!
Thank you for your answer. I have read the whole page multiple times, the main problem was that instead of dragging the parameter collection I created the constant.
However I am able to change now the constant, I can even read the variable, (get scalar parameter value) but the texture sees the variable as 0.
The parameters are all black like in the documentation that you posted and they stay like that no matter what variable I give them.
Hey Andras2014,
In the image you posted above it shows you are using a “Scalar Parameter” named “test” in the material graph. The reason this does not work is that Scalar/Vector Parameter nodes are for MaterialInstance’s instead of a MaterialParameterCollection.
To fix this you need to delete that ‘test’ scalar parameter from the material graph only (not the collection), and replace that node with a “Collection Parameter”. You will then be able to choose the name of the parameter collection and the “test” variable in the details panel with the node selected.
Recompile the material and it should now work properly with everything else connected as shown in the image above…
Just as a note for Vector based Collection Parameters (when you start to use them) is that they are always a Float4 (4 channel vector RGBA), if you need a 3 channel vector simply use a ComponentMask node with RGB selected, or RG for a 2 channel vector.
Hope that helps!
Hello ,
Thanks for your help. With this setup I can now change the scalar parameter and if I use get scalar parameter with print string I can see, that it has been changed, but the material itself stays at 0.0. I use the same setup. If I change that parameter to a constant int the material editor, the material works.
I thought the scalar parameter works just like a constant. What am I doing wrong?
That is correct actually, one odd side effect of using a CollectionParameter is that it never live updates in the material, it will always show 0 (black) no matter what the value actually says, it must get set internally after the material is compiled.
This makes it difficult to use when you are still adjusting & tweaking parameters in the material editor, I have a large material with 40+ collection parameters and none of them get updated inside the material. I began with constants, moved to DynamicMaterialInstances (see below) and then switched them to a collection once I knew the range of values I was going to need.
If you need to be able to see the values in the material editor, it might be better to use a DynamicMaterialInstance in your blueprint and use the regular Scalar & Vector parameters.
To do this make sure you have “Context Sensitive” turned off in the BP node search menu and type “Get scalar” or “Get Vector”, you should see that there are 2 identically named nodes for each, one is meant for collections, the other for DMI’s. You will have to manually type in the name of the material parameter to use it, but this will allow you full control from both blueprint and the material editor. If you would rather go this route, this page in the documentation explains some more about this:
.unrealengine.com/latest/INT/Engine/Rendering/Materials/MaterialInstances/index.html#materialinstancedynamic
Hope that helps, you’re not doing anything wrong, it’s just how these parameters work in editor.
EDIT: When you say “the material itself stays at 0.0” do you mean the material that is shown on your hud or the material editor itself? Just realized I might have misunderstood that point. If what I wrote above is irrelevant can you post up a screenshot of your current setup? Hope I read that correctly, but let me know!
I meant that the length of the bar stays at 0. I mean the default value, that I type in the material editor. And the bar does not change no matter what I do. What even more annoying is that I have done that implementation multiple times in 4.5.1 but in 4.6 it does not work, even with the “old” set scalar parameter value with creating dynamic material instance in the construction script. I don’t know whats going on, maybe I will re-install everything, that’s strange to me.
On the picture you can see, that the material works and gets the value from the blueprint (you can see it from the “print string”), but it does not change.