看到多少补多少
All these matrices are float4x4 type.
NameValueUNITY_MATRIX_MVPCurrent model * view * projection matrix.UNITY_MATRIX_MVCurrent model * view matrix.UNITY_MATRIX_VCurrent view matrix.UNITY_MATRIX_PCurrent projection matrix.UNITY_MATRIX_VPCurrent view * projection matrix.UNITY_MATRIX_T_MVTranspose of model * view matrix.UNITY_MATRIX_IT_MVInverse transpose of model * view matrix.unity_ObjectToWorldCurrent model matrix.unity_WorldToObjectInverse of current world matrix.
These variables will correspond to the Camera that is rendering. For example during shadowmap rendering, they will still refer to the Camera component values, and not the “virtual camera” that is used for the shadowmap projection.
NameTypeValue_WorldSpaceCameraPosfloat3World space position of the camera._ProjectionParamsfloat4x is 1.0 (or –1.0 if currently rendering with a flipped projection matrix), y is the camera’s near plane, z is the camera’s far plane and w is 1/FarPlane._ScreenParamsfloat4x is the width of the camera’s target texture in pixels, y is the height of the camera’s target texture in pixels, z is 1.0 + 1.0/width and w is 1.0 + 1.0/height._ZBufferParamsfloat4Used to linearize Z buffer values. x is (1-far/near), y is (far/near), z is (x/far) and w is (y/far).unity_OrthoParamsfloat4x 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_CameraProjectionfloat4x4Camera’s projection matrix.unity_CameraInvProjectionfloat4x4Inverse of camera’s projection matrix.unity_CameraWorldClipPlanes[6]float4Camera frustum plane world space equations, in this order: left, right, bottom, top, near, far.灯光部分 根据LightMode 不同可用的内建数据也是不同的
Light parameters are passed to shaders in different ways depending on which Rendering Path is used, and which LightMode Pass Tag is used in the shader.
Forward rendering (ForwardBase and ForwardAdd pass types):
NameTypeValue_LightColor0 (declared in Lighting.cginc)fixed4Light color._WorldSpaceLightPos0float4Directional lights: (world space direction, 0). Other lights: (world space position, 1)._LightMatrix0 (declared in AutoLight.cginc)float4x4World-to-light matrix. Used to sample cookie & attenuation textures.unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0float4(ForwardBase pass only) world space positions of first four non-important point lights.unity_4LightAtten0float4(ForwardBase pass only) attenuation factors of first four non-important point lights.unity_LightColorhalf4[4](ForwardBase pass only) colors of of first four non-important point lights.unity_WorldToShadowfloat4x4[4]World-to-shadow matrices. One matrix for spot lights, up to four for directional light cascades.Deferred shading and deferred lighting, used in the lighting pass shader (all declared in UnityDeferredLibrary.cginc):
NameTypeValue_LightColorfloat4Light color._LightMatrix0float4x4World-to-light matrix. Used to sample cookie & attenuation textures.unity_WorldToShadowfloat4x4[4]World-to-shadow matrices. One matrix for spot lights, up to four for directional light cascades.Spherical harmonics coefficients (used by ambient and light probes) are set up for ForwardBase, PrePassFinal and Deferred pass types. They contain 3rd order SH to be evaluated by world space normal (see ShadeSH9 from UnityCG.cginc). The variables are all half4 type, unity_SHAr and similar names.
Vertex-lit rendering (Vertex pass type):
Up to 8 lights are set up for a Vertex pass type; always sorted starting from the brightest one. So if you want to render objects affected by two lights at once, you can just take first two entries in the arrays. If there are less lights affecting the object than 8, the rest will have their color set to black.
NameTypeValueunity_LightColorhalf4[8]Light colors.unity_LightPositionfloat4[8]View-space light positions. (-direction,0) for directional lights; (position,1) for point/spot lights.unity_LightAttenhalf4[8]Light attenuation factors. x is cos(spotAngle/2) or –1 for non-spot lights; y is 1/cos(spotAngle/4) or 1 for non-spot lights; z is quadratic attenuation; w is squared light range.unity_SpotDirectionfloat4[8]View-space spot light positions; (0,0,1,0) for non-spot lights.Transforms a point from object space to view space. This is the equivalent of mul(UNITY_MATRIX_MV, float4(pos, 1.0)).xyz, and should be used in its place.
These functions are only useful when using forward rendering (ForwardBase or ForwardAdd pass types).
Function:Description:float3 WorldSpaceLightDir (float4 v)Computes world space direction (not normalized) to light, given object space vertex position.float3 ObjSpaceLightDir (float4 v)Computes object space direction (not normalized) to light, given object space vertex position.float3 Shade4PointLights (...)Computes illumination from four point lights, with light data tightly packed into vectors. Forward rendering uses this to compute per-vertex lighting.The following functions are helpers to compute coordinates used for sampling screen-space textures. They return float4 where the final coordinate to sample texture with can be computed via perspective division (for example xy/w).
The functions also take care of platform differences in render texture coordinates.
Function:Description:float4 ComputeScreenPos (float4 clipPos)Computes texture coordinate for doing a screenspace-mapped texture sample. Input is clip space position.float4 ComputeGrabScreenPos (float4 clipPos)Computes texture coordinate for sampling a GrabPass texure. Input is clip space position.These functions are only useful when using per-vertex lit shaders (“Vertex” pass type).
Function:Description:float3 ShadeVertexLights (float4 vertex, float3 normal)Computes illumination from four per-vertex lights and ambient, given object space position & normal.
转载于:https://www.cnblogs.com/wbaoqing/p/8892437.html