Game Development Reference
In-Depth Information
Type
Descripion
name ("display name", Rect) =
"name" { options }
Defines a rectangle (non power of 2) texture
property.
name ("display name", Cube) =
"name" { options }
Defines a cubemap texture property.
name ("display name", Float) =
number
Defines a float property.
name ("display name", Vector) =
(number,number,number,number)
Defines a four-component vector property.
Each property inside the shader is referenced by name (in Unity, it's common to start shader
property names with underscore). The property will show up in material inspector as Display
name . For each property a default value is given after the equals sign:
F For Range and Float properies: It's just a single number
F For Color and Vector properies: It's four numbers in parentheses
F For texture ( 2D , Rect , Cube ): The default value is either an empty string, or one of
the built-in default textures— white , black , gray , or bump .
Example
Properties {
_MainTex ("Texture ", 2D) = "white" {} // textures
_SpecColor ("Specular color", Color) = (0.30, 0.85, 0.90, 1.0) //
color
_Gloss ("Shininess", Range (1.0,512)) = 80.0 // sliders
}
Surface shaders
To use the surface shaders, you need to deine a surface funcion ( void surf(Input IN,
inout SurfaceOutput o) ) that takes any UVs or data you need as input, and fills in
the output structure SurfaceOutput . The SurfaceOutput structure basically describes
properies of the surface (that is albedo color, normal, emission, specularity, and so on).
Then, you write this code in Cg/HLSL.
Surface shader compiler then figures out the inputs that are needed, the outputs that are
filled, and so on, and generates actual vertex and pixel shaders as well as rendering passes to
handle forward and deferred rendering.
Search WWH ::




Custom Search