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"

Adjusting a boolean parameter in a material instance in code?

I'm trying to override a boolean parameter in a material instance in an editor plugin.

Texture parameters can be overridden without problems with SetTextureParametervalueEditorOnly, but... there's no such thing for boolean parameters.

I've tried the following by looking at PreviewMaterial.cpp, and it does update the UMaterialInstance in VS's watch window, but doesn't get reflected in the final version that gets saved it seems... What am I missing?

 bool testBool = false;  // throwaways for checking purpose
 FGuid testGUID;
 if (sourceMaterial->GetStaticSwitchParameterValue(FName("WorldVertexTransition"), testBool, testGUID)) 
     // do we have the switch bool?
     // grab all material params, including those of the source
     FStaticParameterSet updatedParams;
     for (int paramIdx = 0; paramIdx < updatedParams.StaticSwitchParameters.Num(); paramIdx++)
         if (updatedParams.StaticSwitchParameters[paramIdx].ParameterName == FName("WorldVertexTransition"))
             // Flip the boolean to what we need and override it...
             updatedParams.StaticSwitchParameters[paramIdx].Value = switchBlend;  
             updatedParams.StaticSwitchParameters[paramIdx].bOverride = true;
     // does this do anything? Doesn't seem so
     newMaterial->bHasStaticPermutationResource = true;  
     // this does absolutely nothing, even though it should!
     newMaterial->UpdateStaticPermutation(updatedParams, true); 
     // next one doesn't help either

alt text This is the material parameter I'm trying to adjust, and I'm totally okay with it needing to be recompiled or whatever if necessary.

Product Version: UE 4.10
more ▼

asked Jan 30 '16 at 03:14 AM in C++ Programming

avatar image

92 8 19 24

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

1 answer: sort voted first

Actually, seems to do what it needs to after a night of not touching it. Need to remove line 20 or it'll somehow turn the FMaterial::GetRenderingThreadShaderMap() call the engine does into a null object, though. (24 is just superfluous)

more ▼

answered Jan 31 '16 at 07:36 AM

avatar image

92 8 19 24

(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