Built-in shader variables
来源:互联网 发布:淘宝淘口令在哪里设置 编辑:程序博客网 时间:2024/05/24 01:18
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 in UnityShaderVariables.cginc
include file that is included automatically.
Transformations
All these matrices are float4x4
type.
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.
x
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 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._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.Time
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):
Deferred shading and deferred lighting, used in the lighting pass shader (all declared in UnityDeferredLibrary.cginc):
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.
Fog and Ambient
Various
- Built-in shader variables
- Built-in shader variables
- Unity Shader 内置变量(Built-in shader variables)
- Built-in shader variables //内置的着色器变量
- Built-in shader variables 内置的着色器变量
- Unity3D内建参数文档翻译与解析——Built-in shader variables
- Unity3D Built-in Shader详解一
- Unity Built-in Shader详解二
- Unity Built-in Shader详解三
- Unity3D Built-in Shader详解一
- Unity3D Built-in Shader详解一
- nginx built-in variables (nginx 内置的变量)
- RobotFramework内置变量:Built-in Variables(转载)
- Unity3D Built-in Shader,unity3d内置shader详解1
- Cg shader with all built-in vertex input parameters
- Built-in shader include files //内置的材质包含文件
- Built-in shader helper functions //内置的着色器辅助函数
- 2.3 Built-in Exceptions
- sklearn——朴素贝叶斯文本分类4
- iOS页面图层性能和页面卡顿的原因
- 安全性测试AppScan工具使用实战
- Java程序性能分析工具Java VisualVM(Visual GC)—程序员必备利器
- 深入浅出搜索架构引擎、方案与细节
- Built-in shader variables
- adb工具如何连接手机安装apk
- adb工具如何连接手机安装apk
- Java字符串处理知识点
- linux每天一小步---touch命令详解
- 使用Genymotion安卓apk报错解决方法
- 评分弹窗(只要用SeekBar来实现的)
- appium实现的一个简单的测试用例
- 回文串专题