Unityshader's shader Classification "shader Information 2"

Source: Internet
Author: User

About Shaderlab, from my personal understanding, there should be three different types.

  1. Fixed function Shader

Fixed rendering pipeline shader, based on the fallback used for advanced shader in the old video card, is the Shaderlab language, which belongs to the real Shaderlab language, and the difference between the shader we normally see.

  2, Vertex and Fragment Shader

The programmable rendering pipeline, which contains vertex Shader and fragment Shader, which is the vertex shader and fragment shader (Shader). The vertex shader automatically gets some information about vertices based on your own definition. Using the CG/HLSL syntax, small partners should usually notice that sometimes in shader there will be a "unitycg.cginc" declaration, which is unity to do us a good library, you can imagine the C language program in the include,c# Programmers can imagine a using reference to the beginning of a code file that an Android programmer can think of as an import reference at the beginning of the code.

  3. Surface Shader

Unity's own most admired shader type, using Unity's pre-fabricated lighting model for lighting operations. also use CG/HLSL.

  

Unity's three shader contrast the same point:

1, must start from the shader of the only root, that is, the call function explained in this series of data 1.

2, the properties parameter part, the function and the grammar is identical, does not have any difference, did not have the case.

3, the specific functions are in the subshader to achieve, if there are multiple subshader, then the machine will not be all executed, but only a maximum of one, the execution method is from the beginning from the bottom to run the hardware can support the first Subshader, This is done primarily to accommodate different types of graphics cards.

4, can be labeled tags, that is, tags block, such as tags {"rendertype" = "Opaque"} LOD 200 and lighting on, and so on, the specific use of these we elaborate later.

5, the end can be used fallback to the use of spare tire shader, spare tire meaning that if all subshader are not supported by the hardware, will go to use fallback designated shader.

6, can deal with basic functions, such as light reflection specular reflection and so on. However, vertex fragment shaders and surface shaders can implement advanced features not implemented by fixed pipelines, such as the effects of UV-based calculations.

  

 Unity's three shader contrast different points:

1, fixed pipeline and vertex fragment shader Subshader below also have pass{} channel, but the surface shader has already packed the concrete content in the illumination model, therefore cannot add pass{} channel.

2, fixed pipeline after each sentence code there is no semicolon, but the v&f shader sur shader Every code must be added to the semicolon, this design may be more symbolic code farmers expectations.

3, the core structure is different,

The core of the fixed pipeline:

material{} and settexture[_maintex]{}

V&f coloring of the core:

Cgprogram //statement using CG language

#pragma vertex vert //declaring vertex functions vert

#pragma frament Frag //Declare fragment function Frag

#include "unitycg.cginc" //Import Unity's CG library

Endcg

The core of Surface shader:

Cgprogram //statement using CG language

#pragma surface surf Lambert //Declare a surface shader function surf and use Unity's own lighting model and vertex functions

Lambert is a lighting model function that comes with unity, and we can also use our own lighting model functions, and use our own vertex functions to write

Surface finish function Lighting model function vertex processing: function
#pragma surface surf Lsylightmodel vertex:vert
Perform order vertex processing functions, surface processing functions, lighting model functions, color values

Endcg

    

Unityshader's shader Classification "shader Information 2"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.