标签:
下面是一段简单的Shader代码(创建一个Shader时的默认代码),下面对照代码逐行分析。
1 Shader "LearnShaders/BasicDiffuse" { 2 Properties { 3 _MainTex ("Base (RGB)", 2D) = "white" { 4 } 5 } 6 SubShader { 7 Tags { 8 "RenderType"="Opaque" } 9 LOD 200 10 11 CGPROGRAM 12 #pragma surface surf Lambert 13 14 sampler2D _MainTex; 15 struct Input { 16 float2 uv_MainTex; 17 }; 18 19 void surf (Input IN, inout SurfaceOutput o) { 20 half4 c = tex2D (_MainTex, IN.uv_MainTex); 21 o.Albedo = c.rgb; 22 o.Alpha = c.a; 23 } 24 25 ENDCG 26 } 27 FallBack "Diffuse" 28 }
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: 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)
标签:
原文地址:http://www.cnblogs.com/x5lcfd/p/4306363.html