Shader Reference:着色器相关

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

Unity中的着色器可以用三种不同的方式来写:

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,

无论您选择哪种类型,着色器代码的实际内容总是用一种称为ShaderLab的语言包装,

which is used to organize the shader structure. It looks like this:

用于组织着色器结构。它看起来是这样的:

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:从这儿开始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.

我们建议您从阅读下面列出的ShaderLab语法的一些基本概念开始,然后继续阅读在其他部分的surface shaders或vertex and fragment shaders。

 Since fixed function shaders are written using ShaderLab only, you will find more information about them in the ShaderLab reference itself.

由于固定的函数着色器只使用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 the Resources section.

下面的参考资料包含了许多不同类型着色器的例子。对于更多的表面着色器示例,您可以从参考资料Resources section中获得Unity内置着色器的源代码。

Unity’s post-processing effects allows you to create many interesting effects with shaders.

Unity的后期处理效果允许你用着色器创建许多有趣的效果。

 

Read on for shader reference, and check out the shader tutorial as well!

继续阅读有关着色器的参考资料,并检查着色器教程以及!

 

See Also:另请参阅

posted @ 2018-09-17 11:34  前进的yoyocool  阅读(252)  评论(0编辑  收藏  举报