宏
UNITY_UV_STARTS_AT_TOP
通常用于判断D3D平台,在开启抗锯齿的时候,图片采样可能会用到
UNITY_SINGLE_PASS_STEREO
单通道立体渲染,目前主要用于VR
UNITY_COLORSPACE_GAMMA
当前使用gamma空间,还是线性颜色空间
参数
变换相关
最常用的,估计没有不清楚的,都是float4*4
UNITY_MATRIX_MVP
model * view * projection
UNITY_MATRIX_MV
model * view
UNITY_MATRIX_V
view
UNITY_MATRIX_P
projection
UNITY_MATRIX_VP
view * projection
UNITY_MATRIX_T_MV
model * view的转置矩阵
UNITY_MATRIX_IT_MV
model * view的逆转矩阵
_Object2World _World2Object
如名
相机和屏幕相关
_WorldSpaceCameraPos
float3
摄像机的世界坐标
_ProjectionParams
float4
// x = 1 or -1 (很少用,-1说明rendering有翻转投影矩阵)
// y = near plane
// z = far plane
// w = 1/far plane
_ScreenParams
float4
用屏幕坐标除以屏幕分辨率,_ScreenParams.xy可以得到视口空间中的坐标
x is the camera’s render target width in pixels, y is the camera’s render target height in pixels, z is 1.0 + 1.0/width and w is 1.0 + 1.0/height
_ZBufferParams
float4
用于将z缓存线性化时使用
x is (1-far/near), y is (far/near), z is (x/far) and w is (y/far)
unity_OrthoParams
正交相机的相关参数
x is orthographic camera’s width, y is orthographic camera’s height, z is unused and w is 1.0 when camera is orthographic, 0.0 when perspective
unity_CameraProjection
float4*4
摄像机的投影矩阵
unity_CameraInvProjection
unity_CameraProjection的逆矩阵
unity_CameraWorldClipPlanes[6]
float4
裁剪空间下的一些参数
left, right, bottom, top, near, far
时间相关
单位是秒
_Time
float4
// (t/20, t, t*2, t*3)
_SinTime
float4
// sin(t/8), sin(t/4), sin(t/2), sin(t)
_CosTime
float4
// cos(t/8), cos(t/4), cos(t/2), cos(t)
unity_DeltaTime
float4
就是上一帧的时间,smooothdt为平滑时间&#x