@author: 白袍小道

转载说明原处

插件同步在GITHUB: DaoZhang_XDZ

 
 

最后YY需求(手滑)

1、在理清楚基础套路和细节后,自定义纹理资源,并加入到现有UE材质系统

2、制作一个简单的快速预览纹理在材质中的表现

3、输入的纹理支持GIF、RAW 、或自定义格式,统一转换到Utexture.并放入节点

 
 

效果:

一、源码和API

1、Factory:

 
 

2、FExpressionOutput 和 FExpressionInput

(Unreal的 Anim ,MAT 设计上 采用了倒着获取结果,结果的产生[理解为Node]和递归。

并将Node作为存放逻辑的部分,这个方式可以运用到其他地方如任务系统,导航点等)

 
 

UObject* UMaterialFactoryNew::FactoryCreateNew(UClass* Class,UObject* InParent,FName Name,EObjectFlags Flags,UObject* Context,FFeedbackContext* Warn)

{

UMaterial* NewMaterial = NewObject<UMaterial>(InParent, Class, Name, Flags);

 
 

if ( InitialTexture != nullptr )

{

// An initial texture was specified, add it and assign it to the BaseColor

UMaterialExpressionTextureSample* TextureSampler = NewObject<UMaterialExpressionTextureSample>(NewMaterial);

{

//这里是编辑记录

TextureSampler->MaterialExpressionEditorX = -250;

TextureSampler->Texture = InitialTexture;

//纹理类型

TextureSampler->AutoSetSampleType();

}

 
 

NewMaterial->Expressions.Add(TextureSampler);

 
 

//FExpressionInput/OutPut 是表达式逻辑节点输入的抽象

FExpressionOutput& Output = TextureSampler->GetOutputs()[0];

FExpressionInput& Input = (TextureSampler->SamplerType == SAMPLERTYPE_Normal)

? (FExpressionInput&)NewMaterial->Normal

: (FExpressionInput&)NewMaterial->BaseColor;

 
 

Input.Expression = TextureSampler;

Input.Mask = Output.Mask;

Input.MaskR = Output.MaskR;

Input.MaskG = Output.MaskG;

Input.MaskB = Output.MaskB;

Input.MaskA = Output.MaskA;

 
 

NewMaterial->PostEditChange();

}

 
 

return NewMaterial;

}

 
 

二、模拟实现:

UFUNCTION(BlueprintCallable,Category= "MaterialStudio|MatNodeLib")

static UMaterial* QuickPreviewTextureOnMaterialBNode(const UTexture* pTexture,const UMaterial* pMaterial);

 
 

其中:

Color ,Scale,Vector

 
 

第一节Over

最新文章

  1. net reactor加密源码保软件安全-net reactor使用教程
  2. java 26 - 8 网络编程之 TCP协议的练习
  3. iOS SDWebImage使用详解
  4. 2016年12月17日 星期六 --出埃及记 Exodus 21:12
  5. UI篇---RadioButton(单选按钮)
  6. string和stringbuilder的解剖
  7. URI和URL
  8. iOS SnapKit自动布局使用详解
  9. Git .gitignore文件简介及使用
  10. JavaScript函数式编程
  11. 【HNOI2016】最小公倍数
  12. 结尾非零数的奇偶性(问题来源于PythonTip)
  13. [No0000190]vim8安装教程和vim中文帮助文档Vimcdoc安装方法-Vim使用技巧(5)
  14. springboot找不到主类
  15. [阮一峰]Linux 守护进程的启动方法
  16. 怎样在js中使用EL表达式
  17. WinForm下的TabControl控件
  18. $_SERVER[]数组解析
  19. @Html.DropDownListFor默认选中项
  20. git学习——&lt;五&gt;git分支

热门文章

  1. ConcurrentHashMap 中putIfAbsent 和put的区别
  2. SignalR 教程二 服务端广播
  3. 统计 SQL Server中的 Job 情况
  4. ZooKeeper系列(1)--分布式系统的基石
  5. Oracle创建聚簇表
  6. ORACLE中查询语句的执行顺及where部分条件执行顺序测试
  7. oc中文首字母排序
  8. 卡常三连(快读快写+re)
  9. centos7 使用指定邮箱发送邮件
  10. Ansible实现主备模式的高可用(Keepalived)