Unity3D教程寶典之Shader篇:第二講Fixed Function Shader

原文地址http://blog.sina.com.cn/s/blog_471132920101d5of.html

Shader第二講
:Fixed Function Shader
Fixed function shader簡介: 屬于固定渲染管線 Shader, 基本用于高級Shader在老顯卡無法顯示時的情況。使用的是ShaderLab語言,語法與微軟的FX files 或者NVIDIA的 CgFX類似。例一:
顯示單一顏色下面我們來看第一個例子,顯示單一顏色,注釋寫得挺詳細了,照著格式寫即可。Function Shader" title="【風(fēng)宇沖】Unity3D教程寶典之Shader篇:第二講Fixed Function Shader" style="margin: 0px; padding: 0px; border: 0px; list-style: none;">//根Shader
Shader "Custom/1_1color" {
// 屬性
Properties {
//定義一個顏色
_Color ("Main Color", Color) = (1,.5,.5,1)
}
// 子shader
SubShader {
Pass {
Material {
//顯示該顏色
Diffuse [_Color]
}
//打開光照開關(guān),即接受光照
Lighting On
}
}
}

例二:顯示一張貼圖Function Shader" title="【風(fēng)宇沖】Unity3D教程寶典之Shader篇:第二講Fixed Function Shader" action-data="http%3A%2F%2Fs15.sinaimg.cn%2Fmw690%2F47113292td0e101ae8f0e%26690" action-type="show-slide" style="margin: 0px; padding: 0px; border: 0px; list-style: none;">Function Shader" title="【風(fēng)宇沖】Unity3D教程寶典之Shader篇:第二講Fixed Function Shader" style="margin: 0px; padding: 0px; border: 0px; list-style: none; width: 135px; height: 180px;">Shader "Custom/1_2show1texture" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Color("Main color",Color) = (1,1,1,1)
}
SubShader {
Pass
{
Material
{
Diffuse[_Color]
}
Lighting on
SetTexture[_MainTex]
{
//combine color部分,alpha部分
// 材質(zhì) * 頂點顏色
Combine texture * primary,texture * constant
}
}
}
}

例三:兩張貼圖疊加****Function Shader" action-data="http%3A%2F%2Fs9.sinaimg.cn%2Fbmiddle%2F47113292td0e150c65108%26690" action-type="show-slide" style="margin: 0px; padding: 0px; border: 0px; list-style: none; width: 330px; height: 297px;">Function Shader" style="margin: 0px; padding: 0px; border: 0px; list-style: none;">Shader "Custom/1_3merge2texture" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_MainTex2 ("Tex2 (RGB)", 2D) = "white" {}
_Color("Main color",Color) = (1,1,1,1)
}
SubShader {
Pass
{
Material
{
Diffuse[_Color]
}
Lighting on
SetTexture[_MainTex]
{
// 第一張材質(zhì) * 頂點顏色
Combine texture * primary
}
SetTexture[_MainTex2]
{
// 第二張材質(zhì) * 之前累積(這里即第一張材質(zhì))
Combine texture * previous
}
}
}
}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容