使用Amplify Shader Editor优化特效Shader

ASE相对于Shader Forge生成的代码更加干净, 用于制作特效的再合适不过,以下是使用ASE优化一个SF制作特效的经过:
## 分析美术用SF制作的Shader
懒得装SF, 直接分析代码可知这个溶解效果大致有以下部分组成:

  • 使用Grab的扭曲
  • 4个Step指令 + 3个lerp指令组成的溶解
  • 时间变量控制的UV动画
  • 2张贴图 + N个uniform变量
  • 顶点色

沟通去掉部分功能

由于这个特效核心需求是实现刀光的溶解消失,因此可去掉一部分功能

  • 使用Grab的扭曲 (太快看不清楚)
  • 4个Step指令 + 3个lerp指令组成的溶解 (需要精简)
  • 时间变量控制的UV动画 (可以用动画组件做UV动画)
  • 2张贴图 + N个uniform变量 (酌情精简)
  • 顶点色 (有A通道,不需要)

在ASE中重新创建Shader

1 Sahder Forge会生成很多实际不使用的代码,先要手动清理掉这部分代码
2 清理后的代码可读性依然很差,花时间在ASE重建如下:

优化节点

ASE可视化Shader编程的最大优点就是能实时看到当前节点的运算结果,下面开始优化:

  1. 首先使用新旧练个shader调成一样,用作优化是做对比,保证优化完后效果基本一致

  2. 首先是4个step,这样互换AB,结果其实就是反向,使用OneMinus代替

  3. 继续, 乘法的结果总是黑色的,这些节点都浪费了

另一组Lerp的结果也一样是浪费的↓

  1. 修复bug, 改用合适的混合模式

  2. 最后效果跟原来美术做的一样, 但性能提升极大!

跟原Shader相比

  • 去掉了grab
  • 2个Step指令 + 0个lerp指令组成的溶解
  • 动画控制UV
  • 2张贴图 + N个uniform变量 (酌情精简)
  • 去掉了顶点色和法线语义等无用的代码

<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">

 
 
 
 

转载于:https://www.cnblogs.com/CloudLiu/p/10446599.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
NEW! Support for Lightweight SRP NEW! Multi-Pass on Templates NEW! Compatibility with Unity 2018 NEW! Xbox One/PS4/Switch Support NEW! Texture Array Creator tool NEW! Terrain support NEW! Shader Templates • Lightweight PBR SRP • Lightweight Unlit SRP • Post-Process effects • Alpha-Blended particles • Sprite • Unlit • UI New Samples • SRP Lightweight 2D Fractal • Projectors • XRay • Single Channel Masking by Sarah Akers and David Marshall • Stylized Skybox by BOXOPHOBIC • Melting by Gil Damoiseaux New Shader Functions • Detail Albedo • Fetch Lightmap Value • Lerp White To New Template • Lightweight Unlit SRP New Nodes • Transform Position • Transform Direction Latest Improvements • Amplify Shader Editor now supports Lightweight SRP v1.1.10 via templates. • Support for Specular workflow into Lightweight PBR SRP template. • Templates can now be Multi-Pass. • Amplify Shader Editor is now compatible with Unity 2018. • Official support for Xbox One/PS4/Switch. • Texture Array Creator tool now also creates 3D Textures. • Can create terrain shaders, completely from within ASE without external editing required. • Improved templates loading behavior after hot code reload. • Pragmas, Defines and Includes are now set over a single reorderable list. • Blend, Cull, Stencil, Color Mask and Depth options can now reference properties. • Properties now can have custom attributes. • Improved editor rendering pipeline leading to huge performance boost. • Reduced editor memory allocations resulting on a low Garbage Collector impact. • Editor more snappy and responsive when auto panning and zooming. • Multiple fixes over various nodes, editor and samples. Learn more: Amplify Wiki Discuss here: Unity Forum Thread Shader Samples: Full List The Editor will continue to be improved in future updates, there are a lot more features currently in development. Notable Features • Full source-code • Support for Xbox One/PS4/Switch • Custom Node API • Shader Templates • Shader Functions • Multi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值