点此获取官方文档地址
所有的这些内置变量类型无需声明,直接使用,需要包含:UnityCG.cginc file.
Transformations
- float4x4 UNITYMATRIXMVP Current modelviewprojection matrix
- float4x4 UNITYMATRIXMV Current model*view matrix
- float4x4 UNITYMATRIXV Current view matrix.
- float4x4 UNITYMATRIXP Current projection matrix
- float4x4 UNITYMATRIXVP Current view*projection matrix
- float4x4 UNITYMATRIXT_MV Transpose of model*view matrix
- float4x4 UNITYMATRIXIT_MV Inverse transpose of model*view matrix
- float4x4 UNITYMATRIXTEXTURE0 to UNITYMATRIXTEXTURE3 Texture transformation matrices
- float4x4 _Object2World Current model matrix
- float4x4 _World2Object Inverse of current world matrix
- float3 _WorldSpaceCameraPos World space position of the camera
- float4 unity_Scale xyz components unused; .w contains scale for uniformly scaled objects.
Lighting
看作数组,末尾加下标使用
- _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
Various
- float4 _Time : Time (t/20, t, t2, t3), use to animate things inside the shaders
- float4 _SinTime : Sine of time: (t/8, t/4, t/2, t)
- float4 _CosTime : Cosine of time: (t/8, t/4, t/2, t)
- float4 unity_DeltaTime : Delta time: (dt, 1/dt, smoothDt, 1/smoothDt)
- float4 _ProjectionParams :
- x is 1.0 or -1.0, negative if currently rendering with a flipped projection matrix
- y is camera's near plane
- z is camera's far plane
- w is 1/FarPlane.
- float4 _ScreenParams :
- x is current render target width in pixels
- y is current render target height in pixels
- z is 1.0 + 1.0/width
- w is 1.0 + 1.0/height
Page last updated: 2013-09-12
点此获取官方文档地址
所有的这些内置变量类型无需声明,直接使用,需要包含:UnityCG.cginc file.
Transformations
- float4x4 UNITYMATRIXMVP Current modelviewprojection matrix
- float4x4 UNITYMATRIXMV Current model*view matrix
- float4x4 UNITYMATRIXV Current view matrix.
- float4x4 UNITYMATRIXP Current projection matrix
- float4x4 UNITYMATRIXVP Current view*projection matrix
- float4x4 UNITYMATRIXT_MV Transpose of model*view matrix
- float4x4 UNITYMATRIXIT_MV Inverse transpose of model*view matrix
- float4x4 UNITYMATRIXTEXTURE0 to UNITYMATRIXTEXTURE3 Texture transformation matrices
- float4x4 _Object2World Current model matrix
- float4x4 _World2Object Inverse of current world matrix
- float3 _WorldSpaceCameraPos World space position of the camera
- float4 unity_Scale xyz components unused; .w contains scale for uniformly scaled objects.
Lighting
看作数组,末尾加下标使用
- _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
Various
- float4 _Time : Time (t/20, t, t2, t3), use to animate things inside the shaders
- float4 _SinTime : Sine of time: (t/8, t/4, t/2, t)
- float4 _CosTime : Cosine of time: (t/8, t/4, t/2, t)
- float4 unity_DeltaTime : Delta time: (dt, 1/dt, smoothDt, 1/smoothDt)
- float4 _ProjectionParams :
- x is 1.0 or -1.0, negative if currently rendering with a flipped projection matrix
- y is camera's near plane
- z is camera's far plane
- w is 1/FarPlane.
- float4 _ScreenParams :
- x is current render target width in pixels
- y is current render target height in pixels
- z is 1.0 + 1.0/width
- w is 1.0 + 1.0/height
Page last updated: 2013-09-12
点此获取官方文档地址
所有的这些内置变量类型无需声明,直接使用,需要包含:UnityCG.cginc file.
Transformations
- float4x4 UNITYMATRIXMVP Current modelviewprojection matrix
- float4x4 UNITYMATRIXMV Current model*view matrix
- float4x4 UNITYMATRIXV Current view matrix.
- float4x4 UNITYMATRIXP Current projection matrix
- float4x4 UNITYMATRIXVP Current view*projection matrix
- float4x4 UNITYMATRIXT_MV Transpose of model*view matrix
- float4x4 UNITYMATRIXIT_MV Inverse transpose of model*view matrix
- float4x4 UNITYMATRIXTEXTURE0 to UNITYMATRIXTEXTURE3 Texture transformation matrices
- float4x4 _Object2World Current model matrix
- float4x4 _World2Object Inverse of current world matrix
- float3 _WorldSpaceCameraPos World space position of the camera
- float4 unity_Scale xyz components unused; .w contains scale for uniformly scaled objects.
Lighting
看作数组,末尾加下标使用
- _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
Various
- float4 _Time : Time (t/20, t, t2, t3), use to animate things inside the shaders
- float4 _SinTime : Sine of time: (t/8, t/4, t/2, t)
- float4 _CosTime : Cosine of time: (t/8, t/4, t/2, t)
- float4 unity_DeltaTime : Delta time: (dt, 1/dt, smoothDt, 1/smoothDt)
- float4 _ProjectionParams :
- x is 1.0 or -1.0, negative if currently rendering with a flipped projection matrix
- y is camera's near plane
- z is camera's far plane
- w is 1/FarPlane.
- float4 _ScreenParams :
- x is current render target width in pixels
- y is current render target height in pixels
- z is 1.0 + 1.0/width
- w is 1.0 + 1.0/height
Page last updated: 2013-09-12