#Dynamic Material Instance
Step 1:
In editor, make a material that has a Texture as a propety.
a. hold down T and left click in material space to make a new texture sample
b. right click and convert to parameter
c. Give it the name “T2DParam”
d. save this new material as your master material
Step 2:
Copy the reference into a constructor
or create a MaterialInterface* UPROPERTY to set from editor on a class BP (like your player controller BP)
//~~~ BP Referenced Materials ~~~
UPROPERTY(EditDefaultsOnly, Category=Materials)
UMaterialInterface * MasterMaterialRef;
Step 3:
In code, make a material Instance of this master material. Do NOT do this in the constructor, only after post init.
UMaterialInstanceDynamic* RV_MatInst = UMaterialInstanceDynamic::Create(MasterMaterialRef, this);
Step 4:
After you make your custom T2D, assign it as a texture parameter to your material
RV_MatInst->SetTextureParameterValue(FName("T2DParam"),YourCustomT2DRef);
UMateriaInstanceDynamic.h:
/** Set an MID texture parameter value */
UFUNCTION(BlueprintCallable, Category="Rendering|Material")
ENGINE_API void SetTextureParameterValue(FName ParameterName, class UTexture* Value);
#Enjoy!
Enjoy!