本文为个人从Unity文档翻译所得,如要转载请注明源博客地址:http://ymdzz.blog.51cto.com/


Shader Reference 着色器参考文献


Unity中的Shader可以被写成以下三种方式:

1 surface shaders

2 vertex and fragment shaders

3 fixed function shaders


Shader指南(Shader tutorial)可以指引你选择你所需的Shader类型

不管你选择的是哪一种Shader,Shader的代码的核心部分都是被一种叫做ShaderLab的语言来编写。


ShaderLab语言用于组织Shader的结构,就像这样:

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 run on older graphics cards

}

}


推荐从阅读基本的ShaderLab语法开始来学习Shader,接着阅读关于surface shader或者vertex and fragment shaders的相关资料。而fixed function shaders是仅仅用ShaderLab来编写的,可以在ShaderLab的参考文献中查阅更多的相关信息。