Unity3d shader official tutorial translation (4) -- shader Syntax: subshader

Source: Internet
Author: User
Shaderlab Syntax: subshader
Shaderlab Syntax: subshader
 

Each shader in Unity consists of a list of subshaders. when unity has to display a mesh, it will find the shader to use, and pick the first subshader that runs on the user's graphics card.

Each shader in unity3d is composed of a series of subshaders. When unity3d displays a grid, it uses the first subshader supported by the user's video card.

Syntax

Syntax

Subshader {[Tags] [commonstate] passdef [passdef
...] }
Defines the subshader as optional tags, common state and a list of pass definitions.
The definition subshade contains optional labels, common statuses, and channel definition lists.
Details

Details

A subshader defines a list of rendering passes and optionally setup any state that
Is common to all passes. Additionally, subshader specific tags can be set
Up.

A subshader defines a list of rendering channels and selectively sets the normal state of these channels. In addition, subshade can also set specific labels.

When unity chooses which subshader to render with, it renders an object once for each pass defined (and possibly more due to light interactions ). as each render of the object is an expensive operation, you want to define the shader in minimum amount of passes
Possible. Of course, sometimes on some graphics hardware the needed effect can't be done in a single pass; then you have no choice but to use multiple passes.

When unity3d selects one subshader for rendering, it will first render one object defined by each channel (this object is probably determined by light interaction ). Since rendering every object is a very expensive operation, you have to define as few rendering channels as possible for the shader operation. Of course, sometimes some gorgeous effects on the video card cannot only use a single channel, you must use a multi-channel.

Each pass definition can be a regular pass, a use
Pass or a grab pass.

Each channel can be defined as a regular pass or use
Pass or grab pass.

Any statements that are allowed in a pass definition can also appear in subshader block. This will make all passes use this "shared" state.

Any declaration in a channel definition can also appear in the subshader block. By doing so, all channels can share these declarations.

Example
// ...SubShader {    Pass {        Lighting Off        SetTexture [_MainTex] {}    }}// ...

This subshader defines a single pass that turns off any lighting and just displays a mesh with texture named _ maintex.

This subshader defines a single channel, which closes all the lights and then displays a texture mesh named _ maintex.

 

Original at www.j2megame.com. For more information, see.

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.