x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[C++] Make Dynamic Material Get Parameters instead of Setting them

Hi,

Is it possible to make the Dynamic Material Instance Get the parameters instead of Setting them?

I already know how to set parameters and I already know Parameter Collection.

I have a different problem that I explain in this post:

https://answers.unrealengine.com/questions/601178/dynamic-parameter-collection-for-dynamic-materials.html

Thanks.

Product Version: UE 4.16 Preview
Tags:
more ▼

asked May 17 '17 at 10:32 AM in C++ Programming

avatar image

Bionic Ape
124 16 19 24

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first
 float OutValue = 0;
 YourMaterialInstanceRef->GetScalarParameterValue(FName(TEXT("ParmeterNameHere"), OutValue);

Same for the other Parameter types:

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Materials/UMaterialInstance/GetScalarParameterValue/index.html

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Materials/UMaterialInstance/GetVectorParameterValue/index.html

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Materials/UMaterialInstance/GetTextureParameterValue/index.html

If you want to get Values of a Collection:

 float OutValue = 0;
 UMaterialParameterCollectionInstance* Instance = GetWorld()->GetParameterCollectionInstance(CollectionRef); //UMaterialParameterCollection*
 bool bFoundParameter = Instance->GetScalarParameterValue(FName(TEXT("ParmeterNameHere"), OutValue);

Same for GetVectorParameterValue()

Make sure to check your Pointers before accessing them I left out the checks for simplicity

more ▼

answered May 18 '17 at 08:34 PM

avatar image

Nachtmahr
6.9k 143 26 172

avatar image Bionic Ape Jun 02 '17 at 11:49 AM

Sorry for the late reply.

Thanks for your answer. But I think I didn't explain myself.

I need to have a set of Dynamic Material Instance that use a Parameter Collection.

An example is a character that has 20 Dynamic Material Instances of which 8 of them use ParameterCollectionA and 14 of them use ParameterCollectionB and 4 of the Dynamic Material Instance don't use neither of those.

At the same time, each Dynamic Material Instance might not use all the parameters of the ParameterCollection.

Can be multiple instances of the characters and each character is responsible to set their ParameterCollections.

How can I solve that?

avatar image emperor_katax Oct 05 '17 at 12:02 PM

Can you please check my link? I have same issue with GetVectorParameterValue

https://answers.unrealengine.com/questions/712817/conversion-from-flinearcolor-to-flinearcolor-error.html

tnx

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question