從頭學ShaderGraph :護盾材質
https://connect.unity.com/p/cong ... ph-5-hu-dun-cai-zhi
靈感來源於Brackeys的youtube教程,但內容更加豐富。
首先建立一個Unlit Graph,將shader設定成Transparent,要不然沒法透光。
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/d5cf8afe63814cd1961e79245479d2d53745aade4793d56c8ca153ca47bdabb3.jpg)
由於護盾需要雙面+透明,ShaderGraph又沒法關掉ZWrite。所以我做了個正反兩面的球模型,來實現雙面護盾。
護盾可以被拆解成三部分。
- 模型切割處發光
- 模型邊緣發光
- 貼圖區域發光
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/259b99bfb70eed302da6b92c9ebc1b955e1230dbe21fabbba8a8d771550c8c40.jpg)
1.模型切割遮罩
在shaderforge中,有現成的這個節點。名字叫depth blend。
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/eafd8b0e9b47419cf746b50e09b7dca50105b244da1aa53bff15c911e25562cc.jpg)
但在shadergraph搜尋Depth,只能找到Scene Depth。不過沒有關係,我們自己造。
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/43285e9de0a6f1cedafd6ba75a70effb4720c5be8101b6417ac0fe9c67ea9fe2.jpg)
用視線空間的Scene Depth減去Screen Position的alpha。(我想了半天沒搞懂是怎麼算出來的,有好心人告訴我原理嗎。)
算出來邊緣切割的遮罩,由於黑白反了,所以One minus一下。再選個護盾自發光顏色。
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/4852e570efeb5f3e19ad95eb50e39b45ff63d54810a13fb95a911aa830ce2f4c.jpg)
2.模型邊緣遮罩
標準的菲涅爾。
shadergraph有自帶的菲涅爾節點Fresnel Effect。當然你也可以自己點乘出來。
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/4a6b5d44ad0d9b730d51cd9a11f6540c9398ce3a0e5cb928175e8b6b02c736ff.jpg)
3.貼圖遮罩
需要蜂巢狀遮罩,所以做了一張六邊形的四方連續貼圖。
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/591b3b0d6cbff3595072be6903a8330a5fa658029294cff530f1554845a17e9b.png)
用滑塊做UV Tiling,time加到offset上做UV動畫。
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/cd00887ab43c52054fda2f60d7ccc3b0974969a52121c42aec095ba190cc3a85.jpg)
由於球模型,頂部和底部UV會拉伸嚴重。
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/acaa115f1eae86d09cd1ac9d196c27c7ef3bea8364fda97b4b10ad8023c74bcf.jpg)
所以在shader中用sinV做遮罩,使貼圖隻影響球中間部位。
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/87d4c2aeec56498967a60d38ea99f97f665365d815b7893e6d2d7374031a094c.jpg)
至此三個區域的遮罩製作完成。
4.顏色
純色護盾未免有些單調。於是用菲涅爾做遮罩,挑選內外兩種顏色混合
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/bfb02ab12ec1f18da1b4da682d99f14137be91327cb7ce53ee8bc6d1946beef2.jpg)
最後遮罩連線alpha,顏色連線color
本章結束,來張動圖。
![從頭學ShaderGraph :護盾材質](https://i.iter01.com/images/915860f1617807045384f75121911099d55804e3ff415ff8dbbd176d2f9773fe.gif)
都看到這裡了,點贊收藏吧。
下面是我的檔案
連結:https://share.weiyun.com/58mRhnO
密碼:thtw3e
使用方法:找個HDRP或著URP(LWRP),拖進去。我的資料夾下有預製體。
我的環境:Unity2019.3.0f1 HDRP 7.1.6 ShaderGraph 7.1.6
下面是我的artstation地址:
https://www.artstation.com/luteli
當然你也能看看我原來寫的文章
https://www.zhihu.com/people/lute-li/posts
相關閱讀:
從頭學ShaderGraph :UV與基礎材質
從頭學ShaderGraph:雪材質
作者:Lute Li
專欄地址:https://zhuanlan.zhihu.com/p/109547098
相關文章
- 從頭學ShaderGraph:雪材質
- 從頭學ShaderGraph :溶解材質
- 從頭學ShaderGraph 6:深度冰材質
- 從頭學ShaderGraph :UV與基礎材質
- 材質
- 修改材質
- Linux從頭學08:Linux 是如何保護核心程式碼的?【從真實模式到保護模式】Linux模式
- blender材質屬性:
- 材質最佳化:如何正確處理紋理和材質的關係
- OpenGL高階版本學習日誌2:光照模型&材質模型
- katana材質的製作2
- JMonkeyEngine——材質檔案備註
- ThreeJs-03材質進階JS
- 從頭開始學習VuexVue
- 韶關鋼材檢測 Q355B鑑定材質檢測
- 閃耀暖暖手遊布料材質解析
- three.js獲取物件的材質JS物件
- Linux從頭學07:中斷那麼重要,它的本質到底是什麼?Linux
- ThreeJs-05紋理材質高階操作JS
- ThreeJs-04詳解材質與紋理JS
- 一組材質面料展示模組參考
- 快快網路遊戲盾-雲安全防護中心遊戲
- 從頭開始學習vue-routerVue
- Unity Shader之雙面材質和多Pass渲染Unity
- Linux從頭學09:x86 處理器如何進行-層層的記憶體保護?Linux記憶體
- CesiumJS PrimitiveAPI 高階著色入門 - 從引數化幾何與 Fabric 材質到著色器 - 上篇JSMITAPI
- CesiumJS PrimitiveAPI 高階著色入門 - 從引數化幾何與 Fabric 材質到著色器 - 下篇JSMITAPI
- 記錄從頭學習 JAVA+selenium+testNGJava
- visualstudio著色器設計器shadergraph使用
- 【MMD x EEVEE教程】材質篇 • 替換物體反射反射
- Inconel600是什麼材質的鎳基合金
- 前端3D引擎-Cesium自定義動態材質前端3D
- 工字電感磁芯材質型別深度詳解型別
- 【caffe2從頭學】:2.學習caffe2
- 安全從記憶體保護開始,安芯網盾斬獲2020安全創客彙總冠軍記憶體
- 從頭開始的Java學習Day05Java
- 雙棧維護頭尾操作
- Threes.js入門篇之8 - 材質與紋理JS