Unity provides a handful of built-in values for your shaders: things like current object's transformation matrices, time etc.
You just use them in ShaderLab like you'd use any other property, the only difference is that you don't have to declare it somewhere - they are "built in".
.wcontains scale for uniformly scaled objects.
In plain ShaderLab, you access the following properties by appending zero at the end: e.g. the light's model*light color is
_ModelLightColor0. In Cg shaders, they are exposed as arrays with a single element, so the same in Cg is
|_ModelLightColor||float4||Material's Main * Light color|
|_SpecularLightColor||float4||Material's Specular * Light color|
|_ObjectSpaceLightPos||float4||Light's position in object space. w component is 0 for directional lights, 1 for other lights|
|_Light2World||float4x4||Light to World space matrix|
|_World2Light||float4x4||World to Light space matrix|
|_Object2Light||float4x4||Object to Light space matrix|
xis 1.0 or -1.0, negative if currently rendering with a flipped projection matrix
yis camera's near plane
zis camera's far plane
xis current render target width in pixels
yis current render target height in pixels
zis 1.0 + 1.0/width
wis 1.0 + 1.0/height
Page last updated: 2013-09-12