一、變換矩陣
UNITY_MATRIX_MVP 從object space轉到 projection space(投影)
UNITY_MATRIX_MV 從object space轉到camera space
UNITY_MATRIX_V 從world space轉到camera space
UNITY_MATRIX_P 從camera space轉到projection space
UNITY_MATRIX_VP 從world space轉到projection space
UNITY_MATRIX_T_MV UNITY_MATRIX_MV 的轉置矩陣
UNITY_MATRIX_IT_MV UNITY_MATRIX_MV的逆轉置矩陣,法線的矩陣轉換需要用變換矩陣的逆轉置矩陣.
_Object2World 從object space轉到world space
_World2Object _Object2World的逆矩陣,從world space 到object space
二、Camera and screen
Name |
Type |
Value |
_WorldSpaceCameraPos |
float3 |
World space position of the camera. 相機的世界坐標 |
_ProjectionParams |
float4 |
x 值是1.0或-1.0(當為反轉的投影矩陣時) y 近截面,z遠截面,w 1/遠截面 |
float4 |
屏幕尺寸x寬,y高,z 1+1.0/width,w 1+1.0/height |
|
float4 |
Used to linearize Z buffer values. 用於線性化zbuffer |
|
unity_OrthoParams |
float4 |
正交攝像機的相關參數,w值1時是正交投影,0時是透視投影 |
unity_CameraProjection |
float4x4 |
Camera’s projection matrix. 攝像機的投影矩陣 |
unity_CameraInvProjection |
float4x4 |
Inverse of camera’s projection matrix. 攝像機的投影矩陣的逆矩陣 |
unity_CameraWorldClipPlanes[6] |
float4 |
Camera frustum plane world space equations, in this order: left, right, bottom, top, near, far. 視錐體的左右下上遠近
|
三、Time
Name |
Type |
Value |
_Time |
float4 |
Time since level load (t/20, t, t*2, t*3), use to animate things inside the shaders. |
_SinTime |
float4 |
Sine of time: (t/8, t/4, t/2, t). |
_CosTime |
float4 |
Cosine of time: (t/8, t/4, t/2, t). |
unity_DeltaTime |
float4 |
Delta time: (dt, 1/dt, smoothDt, 1/smoothDt). 幀間隔時間 |
四、forward渲染的光照變量
Name |
Type |
Value |
_LightColor0(declared in Lighting.cginc) |
fixed4 |
Light color. 光線顏色 |
_WorldSpaceLightPos0 |
float4 |
Directional lights: (world space direction, 0). Other lights: (world space position, 1). World space 光照位置,平行光的w值為0,其他光源的w值為1 |
_LightMatrix0(declared in AutoLight.cginc) |
float4x4 |
World-to-light matrix. Used to sample cookie & attenuation textures. World space轉到light space矩陣 |
unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0 |
float4 |
(ForwardBase pass only)world space positions of first four non-important point lights. |
unity_4LightAtten0 |
float4 |
(ForwardBase pass only)attenuation factors of first four non-important point lights. |
unity_LightColor |
half4[4] |
(ForwardBase pass only)colors of of first four non-important point lights. |
五、延遲光照相關變量
Name |
Type |
Value |
_LightColor |
float4 |
Light color.光照顏色 |
_LightMatrix0 |
float4x4 |
World-to-light matrix. Used to sample cookie & attenuation textures. World space轉到light space矩陣
|
六、頂點光照相關變量
Name |
Type |
Value |
unity_LightColor |
half4[8] |
Light colors. 光照顏色 |
unity_LightPosition |
float4[8] |
View-space light positions. (-direction,0) for directional lights; (position,1) for point/spot lights. View space光照位置,平行光的w值為0,其他光源的w值為1 |
unity_LightAtten |
half4[8] |
Light attenuation factors.xis cos(spotAngle/2) or –1 for non-spot lights;yis 1/cos(spotAngle/4) or 1 for non-spot lights;zis quadratic attenuation;wis squared light range. 光照衰減值 |
unity_SpotDirection |
float4[8] |
View-space spot light positions; (0,0,1,0) for non-spot lights. View space聚光燈位置
|