Unity surface shader, vertex, fragment shader

1. Surface shader: Surface shader is a type of shader code unique to Unity, and the surface shader is defined in SubShader. Surface shaders require very little code to write, and Unity handles some of the details automatically. But the essence of the surface shader is the same as the vertex and fragment shader. When we define a surface shader, Unity will convert it into a vertex and fragment shader behind the scenes. Although using the surface shader Unity will do a lot of processing work, making the development easier, but its disadvantages are also obvious, such as: very low flexibility, unable to control the details of rendering, etc.

2. Vertex and fragment shaders: Vertex and fragment shaders are defined in the Pass block in SubShader. Writing vertex and fragment shaders is more complicated, but the flexibility is higher, and we can control more details.
 

3. ToggleOff : Switch attribute
For example:
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 0.0
 

[NoScaleOffset]
The material panel does not display UV offset

[HDR]_EmissionColor("Color", Color) = ( 0, 0, 0, 0 )

[HideInInspector]
Hidden properties in the display panel

4. Tag
Tags { "Queue" = "Transparent " }

Geometry (default)   Applicable to most opaque objects
Background - backgrounds, general sky boxes and the like use this tag, and are rendered first
AlphaTest - if Shader wants to use the AlphaTest function, use this queue for higher performance
Transparent - this rendering queue is useful in Shader after AlphaTest Those that go to Alpha Blend, or those that are not written in depth should be placed in this queue
 

5. Depth write, depth test
// ZWrite On
// ZTest LEqual

6. Cull
// Cull has three types
// Cull Off does not cull
// Cull Back culls the back (face facing away from the camera)
// Cull Front culls the front (face facing the camera)


 


 

Guess you like

Origin blog.csdn.net/jiuzhouhi/article/details/123517303