Here is a simple shader code (the default code when creating a shader), which is analyzed in line with the code.
1Shader"Learnshaders/basicdiffuse" {2 Properties {3_maintex ("Base (RGB)", 2D) =" White" {4 }5 }6 Subshader {7 Tags {8 "Rendertype"="Opaque" }9Lod $Ten One Cgprogram A #pragmaSurface Surf Lambert - - sampler2d _maintex; the structInput { - float2 Uv_maintex; - }; - + voidSurf (Input in, InOut surfaceoutput o) { -Half4 C =tex2d (_maintex, In.uv_maintex); +O.albedo =C.rgb; AO.alpha =C.A; at } - - ENDCG - } -FallBack"Diffuse" -}
1. Shader "Learnshaders/basicdiffuse" {...}
2. Properties {...}
2.1 Surface Shader Property type
Float Range: Range (min, max)
Defines a float property, represented as a slider from Min to Max in the inspector.
Name ("Display Name", Range (Min, max)) = number
Color: Color
Defines a color property.
Name ("Display Name", Color) = (number,number,number,number)
Texture: 2D
Defines a 2D texture property.
Name ("Display Name", 2D) = "name" {options}
Rectangle: Rect
Defines a rectangle (non power of 2) texture property.
Name ("Display Name", Rect) = "name" {options}
Cubemap: Cube
Defines a cubemap texture property.
Name ("Display Name", Cube) = "name" {options}
Float: Float
Defines a float property.
Name ("Display Name", Float) = number
Vector: Vector
Defines a four-component vector property.
Name ("Display Name", Vector) = (number,number,number,number)
Unity Shader 21 Simple examples