Unity3d shader -- fixed function shader

来源:互联网 发布:java游戏引擎制作 编辑:程序博客网 时间:2024/04/25 11:44

这种shader种类简单,效果单一
主要包含: properties, material, lighting, settexture, pass(通道)
样式:
SubShader{
[propertie]
subshader{}
[fallback]
}

值类型: color, range, 2D

此类shader必须要有pass通道
小括号代表固定值,中括号代表变量值
关键词:
pass: 通道
material:材质
diffuse:漫反射
lighting: 光照,on/off
ambient: 环境光
specular: 高光。
separatespecular on 使用高光之后必须添加
shininess: 浮点值,用于描述specular的强度,表示高光部分的集中度,一般用范围【0-8】
emission: 自发光
settexture: 纹理,参数是2D类型,可以混合多个纹理,不同的显卡能混合的纹理上限不同
combine: 合并
primary: settexture中专用的关键词,表示合并顶点光照参数,还可以乘以一个值,增加曝光度
previous: combine用,合并之前的结果,区别于primary
double,quad 双倍,四倍
例子:

Shader "Custom/CustomShader" {       Properties {              _Color ("Color", Color) = (1 ,1, 1,1 )              _Ambient ("Ambient", Color) =  (1 ,1, 1,1 )              _Specular ("Specular", Color) = (1 ,1, 1,1 )              _Shininess ("Shininess", Range(0 ,8)) = 4              _Emission( "Emission",color ) = (0.1, 0.1,0.1 ,0.1)       }       SubShader {              pass{                      color[_Color]                      material                     {                            diffuse[_Color]                            ambient[_Ambient]                            specular[_Specular]                            shininess[_Shininess]                            emission[_Emission]                     }                      lighting on                      separatespecular on              }       }}例子2:透明材质shaderShader "Custom/CustomShader" {       Properties {              _Color ("Color", Color) = (1 ,1, 1,1 )              _Ambient ("Ambient", Color) =  (0.3 ,0.3, 0.3,0.3 )              _Specular ("Specular", Color) = (1 ,1, 1,1 )              _Shininess ("Shininess", Range(0 ,8)) = 4              _Emission( "Emission",color ) = (0.1, 0.1,0.1 ,0.1)              _MainTex("MainTex", 2D)="" {}              _SecontTex("SecondTex", 2d) ="" {}              _TransparentColor("TransparentColor", color) = (1 ,1, 1,0.3 )       }       SubShader {              //队列,描述此shader属于何种类型,和渲染顺序              Tags { "Queue" = "Transparent" }              pass{                      //透明混合模式                      Blend SrcAlpha OneMinusSrcAlpha                      material                     {                            diffuse[_Color]                            ambient[_Ambient]                            specular[_Specular]                            shininess[_Shininess]                            emission[_Emission]                     }                      lighting on                      separatespecular on                      settexture[_MainTex]                     {                            combine texture * primary double                     }                      settexture[_SecontTex]                     {                            constantcolor[_TransparentColor ]                            combine texture * previous double, constant                      }              }       }}
0 0
原创粉丝点击