Unity3D Shader官方教程翻譯(一)

xy849288321發表於2013-02-21
Shader Reference
著色參考


Shaders in Unity can be written in one of three different ways:

Unity3D著色器,可以寫在三種不同的方式之一:

assurface shaders,
asvertex and fragment shaders and
asfixed function shaders.
表面著色,
頂點和片段著色器和
作為固定功能著色


Theshader 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 structure. It looks like this:


無論您選擇哪種型別,實際的shader程式碼肉總是會被裹在被稱為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 run 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在下面列出,然後轉移到其他章節中有關表面著色或頂點和片段著色器讀取的部分語法的一些基本概念開始。由於固定功能著色器編寫只能使用ShaderLab,你會發現更多的關於他們的資訊在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 theResources section. Unity'sImage Effects package contains a lot of interesting vertex and fragment shaders.



下面的參考,包括大量的著色不同型別的例子。更多的在粒子系統中使用的表面著色的例子,你可以查閱Unity3D內建的Shader獲得更多資訊。Unity3D的影像效果包中包含了很多有趣的頂點和片段著色器。


Read on for shader reference, and check out theshader tutorial as well!
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


由www.J2meGame.com精心原創,轉載請說明。http://www.j2megame.com/html/xwzx/ty/3301.html

相關文章