Built-in shader variables 内置的着色器变量
来源:互联网 发布:日事清类似软件 编辑:程序博客网 时间:2024/05/22 04:48
Built-in shader variables 内置的着色器变量
Unity provides a handful of built-in global variables for your shaders: things like current object’s transformation matrices, light parameters, current time and so on. You use them in shader programs like any other variable, the only difference is that you don’t have to declare them - they are all declared inUnityShaderVariables.cginc
include file that is included automatically.
Unity为你的着色器提供了一些内置的全局变量:比如当前对象的转换矩阵、光线参数、当前时间等等。像其他变量一样,你在着色程序中使用它们,唯一的区别是你不需要声明它们——它们都被声明为inunityshader变量。cginc包括自动包含的文件。
Transformations - 变换
All these matrices are float4x4
type. 所有这些矩阵都是 float4x4 类型。
Current 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
模型视图矩阵的逆转置
Current model matrix
当前的模型矩阵。.
_World2ObjectInverse of current world matrix
逆模型矩阵。.
Camera and screen 摄像头和屏幕
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.
这些变量将对应于渲染的摄像机。例如,在阴影图渲染中,他们仍然会参考相机组件值,而不是用于影子地图投影的“虚拟摄像机”。
World 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
x是1.0(或-1.0,如果当前渲染的是一个翻转的投影矩阵),y是摄像机的近平面,z是摄像机的远平面,w是1/far平面。.
_ScreenParamsfloat4x
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
x是相机的渲染目标宽度以像素为单位,y是相机的渲染目标高度为像素,z为1.0+1.0/宽度,w为1.0+1.0/高度。.
_ZBufferParamsfloat4Used to linearize Z buffer values. x
is (1-far/near), y
is (far/near), z
is (x/far) and w
is (y/far)
用于线性化Z缓冲区的值。x是(1/接近),y是(法/近),z是(x/很远),w是(/远)
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
x是正形相机的宽度,y是正相机的高度,z是未使用的,当相机正正的时候,w是1.0,当透视时是0.0。.
unity_CameraProjectionfloat4x4Camera’s projection matrix
Camera’s 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
摄像机截头平面世界空间方程,按这个顺序:左、右、下、上、近、远。.
Time
Time since level load (t/20, t, t*2, t*3), use to animate things inside the shaders
从水平负载(t/20,t,t 2,t 3)开始,用在着色器里面的动画。.
_SinTimefloat4Sine of time: (t/8, t/4, t/2, t)
正弦的时间: (t / 8,t/4,t/2 t)
Cosine of time: (t/8, t/4, t/2, t)
余弦的时间: (t / 8,t/4,t/2,t)。.
unity_DeltaTimefloat4Delta time: (dt, 1/dt, smoothDt, 1/smoothDt)
三角洲时间:(dt,1/dt,沙冰,1/平滑dt)。.
Lighting - 灯光
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):
前向渲染(转发和转发类型):
Light color
光的颜色。.
_WorldSpaceLightPos0float4Directional lights: (world space direction, 0). Other lights: (world space position, 1)
方向灯:(世界空间方向,0).其他灯:(世界空间位置,1)。.
_LightMatrix0 (declared in AutoLight.cginc)float4x4World-to-light matrix. Used to sample cookie & attenuation textures
World-to-light矩阵。用于对饼干和衰减纹理进行取样。.
unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0float4(ForwardBase pass only) world space positions of first four non-important point lights
(前进基地仅通过)前4个非重点点灯的世界空间位置。.
unity_4LightAtten0float4(ForwardBase pass only) attenuation factors of first four non-important point lights
(仅通过)前4个非重要点光源的衰减因子
(ForwardBase pass only) colors of of first four non-important point lights
(向前进)前4个非重点点灯的颜色。.
Deferred shading and deferred lighting, used in the lighting pass shader (all declared in UnityDeferredLibrary.cginc):
递延阴影和递延照明,用于照明通过材质(所有UnityDeferredLibrary.cginc中声明):
- 类型
- 数值
Light color.
- 灯光颜色
World-to-light matrix. Used to sample cookie & attenuation textures
World-to-light矩阵。用于对饼干和衰减纹理进行取样。.
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.
球的谐波系数(由环境和光探测器所使用)是为前、预通和递延传递类型设置的。它们包含了由世界空间标准评估的第三次订单(见来自unitycg.cginc.的着色)。这些变量都是半类型、unityshar和类似的名称。
Vertex-lit rendering (Vertex
pass type):
vertexlit渲染(顶点传递类型):
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.
最多有8盏灯为一个顶点通型设置,总是从最亮的一个开始排序。因此,如果您想要同时呈现两个同时受到两个灯光影响的对象,您可以只在数组中获取前两个条目。如果光线对物体的影响比8小,其余的颜色就会变成黑色。
View-space light positions. (-direction,0) for directional lights; (position,1) for point/spot lights
对空间光的位置。(方向,0)方向灯;(位置1)点/点灯。.
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
淡attenuation因素。因为spotAngle(x是- 1 / 2)or for non-spot灯;因为是1 / 4)或(spotAngle / 1 for z是non-spot灯;quadratic attenuation;w is squared light range。.
unity_SpotDirectionfloat4[8]View-space spot light positions; (0,0,1,0) for non-spot lights
视图-空间聚光灯的位置;(0,0,1,0)非聚光灯的位置。.
Fog and Ambient
Sky ambient lighting color in gradient ambient lighting case
天空在环境lighting颜色in gradient lighting case环境。.
unity_AmbientEquatorfixed4Equator ambient lighting color in gradient ambient lighting case
在梯度环境照明中,赤道环境照明颜色。.
unity_AmbientGroundfixed4Ground ambient lighting color in gradient ambient lighting case
在梯度环境照明中,地面环境照明颜色。.
UNITY_LIGHTMODEL_AMBIENTfixed4Ambient lighting color (sky color in gradient ambient case). Legacy variable
环境照明颜色(在渐变环境中的天空颜色)。遗留的变量。.
unity_FogColorfixed4Fog color
雾的颜色。.
unity_FogParamsfloat4Parameters for fog calculation: (density / sqrt(ln(2)), density / ln(2), –1/(end-start), end/(end-start)). x is useful for Exp2 fog mode, y for Exp mode, z and w for Linear mode
雾计算的参数:(密度/sqrt(ln(2))、密度/ln(2)、-1/(结束开始)、结束/(结束开始))。x对于用于线性模式的进出口模式,y表示模式,z和w是很有用的。.
Various
Level-of-detail fade when using LODGroup. x is fade (0..1), y is fade quantized to 16 levels, z and w unused
当使用LODGroup时,细节级别会降低。x是淡色(0.1),y被逐渐量化为16个级别,z和w未被使用。.
- Built-in shader variables //内置的着色器变量
- Built-in shader variables 内置的着色器变量
- Unity Shader 内置变量(Built-in shader variables)
- nginx built-in variables (nginx 内置的变量)
- Built-in shader helper functions //内置的着色器辅助函数
- Built-in shader variables
- Built-in shader variables
- RobotFramework内置变量:Built-in Variables(转载)
- Built-in shader include files //内置的材质包含文件
- Unity3D Built-in Shader,unity3d内置shader详解1
- Unity3D内建参数文档翻译与解析——Built-in shader variables
- 为bash添加内置命令(built-in)的方法
- shader内置常量变量
- shader 内置变量
- unity shader 内置变量
- shader内置变量
- shader着色器变量——uniform、attribute和varying
- 着色器Shader,Alpha的混合
- UVa11137
- maven项目管理工具
- JavaScript学习——DOM获取元素
- php 限制用户接口请求频率
- L
- Built-in shader variables 内置的着色器变量
- Codeforces Gym 101190 NEERC 2016 B. Binary Code
- 自定义组合控件textview
- 【1011】判素数
- sqlserver2008的安装
- muduo网络库学习(二)对套接字和监听事件的封装Channel
- angularJs 正 到 排序
- rest服务理解以及restful api
- 基于java的设计模式的代理模式