Game Development Reference
In-Depth Information
Surface shaders input structure
The input structure, Input , generally has any texture coordinates needed by the shader.
texture coordinates and must be named uv followed by a texture name (or start it with uv2
to use the second texture coordinate set).
An example of surface shader input structure is as follows:
Properties {
_MainTex ("Texture", 2D) = "white" {}
}
……
sampler2D _MainTex;
……
struct Input {
float2 uv_MainTex;
};
We can also have additional values that can be put into the Input structure, as mentioned
in the following table:
Type
Description
float3 viewDir This will contain the view direction to compute Parallax effects, rim lighting, and so on.
float4 with
COLOR semantic
This will contain an interpolated per-vertex color.
float4
screenPos
This will contain the screen space position for reflection effects. This is used by the WetStreet shader in Dark Unity, for
example.
float3 worldPos This will contain the world space position.
float3 worldRe-
fl
This will contain the world reflection vector if the surface shader does not write to o.Normal . See the Reflect-Diffuse
shader, for example.
float3
worldNormal
This will contain the world normal vector if the surface shader does not write to o.Normal .
Search WWH ::




Custom Search