Unity3D Shader官方教程翻译(一)

来源:互联网 发布:美图美妆软件 编辑:程序博客网 时间:2024/05/16 19:49
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