創作內容

18 GP

【筆記】Surface Shader - 4. Lighting - Lighting Model and SurfaceOutput

作者:樂小呈│2020-07-07 17:13:26│巴幣:36│人氣:460
Surface Shader 筆記
4. Lighting - Lighting Model and SurfaceOutput

光照模型和 Surface Output
使用不同的光照模型,會允許 SurfaceOutput使用額外的輸出值

Light Model


模型 Lambert
> #pragma surface surf Lambert

void surf (Input IN,inout SurfaceOutput o)
{
    o.Albedo = _Colour.rgb;
}


模型 Blinn - Phong
允許鏡面反射值 (Specular)和光澤度 (Gloss)
> #pragma surface surf BlinnPhong
_SpecColor ("Colour",Color) = (1,1,1,1)
_Spec ("Specular", Range(0,1)) = 0.5
_Gloss ("Gloss", Range(0,1)) = 0.5

void surf (Input IN,inout SurfaceOutput o)
{
    o.Albedo = _Colour.rgb;
    o.Specular =  _Spec;
    o.Gloss = _Gloss;
}
註: 屬性 _SpecColor,被定義在 Unity文件中,為 BlinnPhong的高光顏色,不能再次定義也不需要再指定給 SurfaceOutupt,宣告屬性即有效果


模型 Standard (PBR)
允許使用金屬值 (Metallic)和平滑度 (Smoothness)
> #pragma surface surf Standard
_Metallic ("Metallic" , Range(0,1)) = 0.0

void surf (Input IN, inout SurfaceOutputStandard o)
{
    o.Albedo = _Color.rgb;
    o.Smoothness = tex2D (_MetallicTex,IN.uv_MetallicTex).r;
    o.Metallic = _Metallic;                     
}


模型 StandardSpecular (PBR)
允許鏡面反射值 (Specular)和平滑度 (Smoothness)
> #pragma surface surf StandardSpecular

_MetallicTex ("Metallic (R)", 2D) = "white" { }
_SpecColor ("Specular" , Color) = (1,1,1,1)
void surf (Input IN, inout SurfaceOutputStandardSpecular o)
{
    o.Albedo = _Color.rgb;
    o.Smoothness = tex2D (_MetallicTex,IN.uv_MetallicTex).r;
    o.Specular = _SpecColor.rgb;                     
}

註: Unity 有預設的兩種使用物理渲染照明 (PBR)的材質球 Standard 和 Standard (Specular setup)


改了標題,用 Surface Shader 會比較好
因為這些部分是 Surface Shader的筆記,之後的 Vertex Shader又是另一部份了

下一篇就是光照部分的重頭戲了,自訂模型
但我會在研究好一些東西後才發

今天也在重構程式,道具效果的部分重構完了
嗚嗚用來雲端同步的 Unity Collab壞了

引用網址:https://home.gamer.com.tw/TrackBack.php?sn=4841388
All rights reserved. 版權所有,保留一切權利

相關創作

同標籤作品搜尋:Shader|筆記

留言共 0 篇留言

我要留言提醒:您尚未登入,請先登入再留言

18喜歡★angus945 可決定是否刪除您的留言,請勿發表違反站規文字。

前一篇:【筆記】Surface ... 後一篇:【專案】ACG Baha...

追蹤私訊切換新版閱覽

作品資料夾

ilove487奇幻小說連載中
《克蘇魯的黎明》0669.日本甚囂塵上的謠言看更多我要大聲說昨天11:52


face基於日前微軟官方表示 Internet Explorer 不再支援新的網路標準,可能無法使用新的應用程式來呈現網站內容,在瀏覽器支援度及網站安全性的雙重考量下,為了讓巴友們有更好的使用體驗,巴哈姆特即將於 2019年9月2日 停止支援 Internet Explorer 瀏覽器的頁面呈現和功能。
屆時建議您使用下述瀏覽器來瀏覽巴哈姆特:
。Google Chrome(推薦)
。Mozilla Firefox
。Microsoft Edge(Windows10以上的作業系統版本才可使用)

face我們了解您不想看到廣告的心情⋯ 若您願意支持巴哈姆特永續經營,請將 gamer.com.tw 加入廣告阻擋工具的白名單中,謝謝 !【教學】