Is it possible to assign a UTexture2D to a material at runtime?
来源:互联网 发布:qq输入法mac 编辑:程序博客网 时间:2024/05/17 07:57
https://answers.unrealengine.com/questions/29271/is-it-possible-to-assign-a-utexture2d-to-a-materia.html
动态材质可以实时更改参数。
但是只能在c++代码或BP中创建以及应用到模型上。
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);
0 0
- Is it possible to assign a UTexture2D to a material at runtime?
- Is it possible to alias a branch in Git?
- This view is not constrained vertically: at runtime it will jump to the left unless you add a vertic
- Is it possible to display icons in a PopupMenu?PopupMenu中显示图片是否可能
- Is it possible to simulate a new addressing scheme for MANETs using GNS3 ?
- Is it possible to implement IPv6 on a virtual interface (eth0:1 interface) in Linux?
- Adding Controls to a DataGrid at Runtime
- Append items at runtime to a dropdownlist
- Is it possible to use a checkbox in a split button list instead of the gear icon?
- 学语言最好的方法是尽量多地联系使用它。(The way to learn a language is to practice using it as often as possible.)
- 如何为VS创建排序并移除不必要的命名空间引用-Is it possible to create a shortcut for removing unused usings into a class?
- ind the integer A such that pow(A,N) is as close as possible to B
- Cannot assign a TFont to a TFont
- Cannot assign a TFont to a TFont!!
- cannot assign a tfont to a tfont
- It isn't possible to write into a document from an asynchronously-loaded
- Is it possible to set font for entire Application?
- How To: Assign a Macro to a Button or Shape
- Bitmap+android:tint
- 《统计学习方法》笔记(6):逻辑斯谛回归&最大熵模型
- DEBUG——redhat下安装eclipse&debug redis源码
- SQLHelper.cs
- ZeroMQ 的模式
- Is it possible to assign a UTexture2D to a material at runtime?
- iar无法编译
- WAY STUDIO 依路 舵机机器人 动作开发环境入门
- 借用一下界面
- 大数据、数据挖掘、机器学习与模式识别的关系
- logstash+es+kibana+redis搭建
- Tutorial: Import Data Into Neo4j
- iOS近场通信(蓝牙开发,WIFI开发)
- Android开发小结