标题: [Unity 组件参考手册]iOS:着色器参考 [打印本页] 作者: . 时间: 2013-2-21 17:08 标题: [Unity 组件参考手册]iOS:着色器参考 Shaders in Unity can be written in one of three different ways:Unity中的着色器能通过以下三种方法中任选其一来书写: as surface shaders, 表面着色器
as vertex and fragment shaders and 顶点和片段着色器
as fixed function shaders. 固定功能着色器The shader tutorial can guide you on choosing the right type for your needs.着色器教程能引导你选择你所需要的正确类型。Regardless of which type you choose, the actual meat of the shader code will always be wrapped in a language called ShaderLab, which is used to organize the shader s***cture. It looks like this:不管你选择何种类型书写,着色器代码的内容最终会被一种用来描述着色器结构的叫做ShaderLab的语言包装起来,如下所示:Shader "MyShader" {
Properties {
_MyTexture ("My Texture", 2D) = "white" { }
// other properties like colors or vectors go here as well
// 其他属性如颜色或者向量将依次排列于此
}
SubShader {
// here goes the 'meat' of your
// - surface shader or
// - vertex and program shader or
// - fixed function shader
// 这里将是放置由你所选的着色器类型所决定的特定格式的着色器代码内容
}
SubShader {
// here goes a simpler version of the SubShader above than can ***n on older graphics cards
// 当你的着色器运行在一个较古老的显示卡时所使用的简化兼容版本
}
} We recommend that you start by reading about some basic concepts of the ShaderLab syntax in the sections listed below and then to move on to read about surface shaders or vertex and fragment shaders in other sections. Since fixed function shaders are written using ShaderLab only, you will find more information about them in the ShaderLab reference itself.我们建议你通过阅读下列的关于ShaderLab的语法的基础概念的章节中来开始你的学习,然后再读其他章节中关于表面着色器或顶点片元着色器的内容。fixed function shaders 只存在于ShaderLab的环境中,你能在参考中找到更多关于它的信息。The reference below includes plenty of examples for the different types of shaders. For even more examples of surface shaders in particular, you can get the source of Unity's built-in shaders from the Resources section. Unity's Image Effects package contains a lot of interesting vertex and fragment shaders.以下的参考包括了不同着色器类型的丰富例子。特别是有许多详细的表面着色器的例子,你能通过 Resources section 获取Unity内置着色器的源代码。Unity's Image Effects 包包含了大量有趣的顶点和片元着色器。 顶点着色器与片段着色器
三维空间中任何复杂的模型都是由若干个三角形组成的,顶点(Vertex)就是指这些三角形的顶点,而片段(fragment)就是指三角形的填充区域。Read on for shader reference, and check out the shader tutorial as well!在阅读着色器参考的时候,配合阅读shader tutorial会更好。 ShaderLab syntax: Shader
ShaderLab syntax: Properties
ShaderLab syntax: SubShader
ShaderLab syntax: Pass
ShaderLab syntax: Color, Material, Lighting
ShaderLab syntax: Culling & Depth Testing
ShaderLab syntax: Texturing
ShaderLab syntax: Fog
ShaderLab syntax: Alpha testing
ShaderLab syntax: Blending
ShaderLab syntax: Pass Tags
ShaderLab syntax: Name
ShaderLab syntax: BindChannels
ShaderLab syntax: UsePass
ShaderLab syntax: GrabPass
ShaderLab syntax: SubShader Tags
ShaderLab syntax: Fallback
ShaderLab syntax: other commands
Writing Surface Shaders
Surface Shader Examples
Custom Lighting models in Surface Shaders
Surface Shader Lighting Examples
Writing vertex and fragment shaders
Accessing shader properties in Cg
Providing vertex data to vertex programs
Built-in state variables in shader programs
GLSL Shader Programs
Advanced ShaderLab topics
Unity's Rendering Pipeline
Performance Tips when Writing Shaders
Rendering with Replaced Shaders
Using Depth Textures
Camera's Depth Texture
Platform Specific Rendering Differences
Shader Level of Detail
ShaderLab builtin values
【来源:互联网】
更多精彩教程,尽在web3D纳金网http://www.narkii.com/college/