- 最后登录
- 2014-10-23
- 注册时间
- 2011-7-19
- 阅读权限
- 90
- 积分
- 81303
- 纳金币
- -1
- 精华
- 11
|
We'll start with a very basic shader:
下面开始介绍一个基础的shader范例:
Shader "Tutorial/Basic" {
Properties {
_Color ("Main Color", Color) = (1,0.5,0.5,1)
}
SubShader {
Pass {
Material {
Diffuse [_Color]
}
Lighting On
}
}
}
Shader "Tutorial/Basic" {
Properties {
_Color ("Main Color", Color) = (1,0.5,0.5,1)
}
SubShader {
Pass {
Material {
Diffuse [_Color]
}
Lighting On
}
}
}
This simple shader demonstrates one of the most basic shaders possible. It defines a color property called Main Color and assigns it a default value of rose-like color (red=100% green=50% blue=50% alpha=100%). It then renders the object by invoking a Pass and in that pass setting the diffuse material component to the property _Color and turning on the vertex lighting.
这个shader范例只是众多shader中最基本的一个,它定义了一个颜色性质,名称为Main Color,并指定了玫瑰色的效果(red=100% green=50% blue=50% alpha=100%),在调用时会跳过Diffuse的材质设定(_Color)并开启顶点光源
To test this shader, create a new material, select the shader from the drop-down menu (Tutorial->Basic) and assign the Material to some object. Tweak the color in the Material Inspector and watch the changes. Time to move onto more complex things!
要测试这个shader,你可以建立一个新的材质,并于Shader下拉菜单选择(Tutorial->Basic),再把这个新材质指定到物件上,拖拉材质检视器的颜色表并查看其变化。是时候研究更复杂的事情了!
Basic Vertex Lighting
If you open an existing complex shader, it can be a bit hard to get a good overview. To get you started, we will dissect the built-in VertexLit shader that ships with Unity. This shader uses fixed function pipeline to do standard per- vertex lighting. |
|