看到多少补多少

顶点输入类型

UnityCG.cginc Line:58

struct appdata_base {float4 vertex : POSITION;float3 normal : NORMAL;float4 texcoord : TEXCOORD0;UNITY_VERTEX_INPUT_INSTANCE_ID
};struct appdata_tan {float4 vertex : POSITION;float4 tangent : TANGENT;float3 normal : NORMAL;float4 texcoord : TEXCOORD0;UNITY_VERTEX_INPUT_INSTANCE_ID
};struct appdata_full {float4 vertex : POSITION;float4 tangent : TANGENT;float3 normal : NORMAL;float4 texcoord : TEXCOORD0;float4 texcoord1 : TEXCOORD1;float4 texcoord2 : TEXCOORD2;float4 texcoord3 : TEXCOORD3;fixed4 color : COLOR;UNITY_VERTEX_INPUT_INSTANCE_ID
};

内建一些变量

Transformations

All these matrices are float4x4 type.

   
Name Value
UNITY_MATRIX_MVP Current model * view * projection matrix.
UNITY_MATRIX_MV Current model * view matrix.
UNITY_MATRIX_V Current view matrix.
UNITY_MATRIX_P Current projection matrix.
UNITY_MATRIX_VP Current view * projection matrix.
UNITY_MATRIX_T_MV Transpose of model * view matrix.
UNITY_MATRIX_IT_MV Inverse transpose of model * view matrix.
unity_ObjectToWorld Current model matrix.
unity_WorldToObject Inverse 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.

     
Name Type Value
_WorldSpaceCameraPos float3 World space position of the camera.
_ProjectionParams float4 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.
_ScreenParams float4 x 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.
_ZBufferParams float4 Used to linearize Z buffer values. x is (1-far/near), y is (far/near), z is (x/far) and w is (y/far).
unity_OrthoParams float4 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 float4x4 Camera’s projection matrix.
unity_CameraInvProjection float4x4 Inverse of camera’s projection matrix.
unity_CameraWorldClipPlanes[6] float4 Camera frustum plane world space equations, in this order: left, right, bottom, top, near, far.

Time

     
Name Type Value
_Time float4 Time since level load (t/20, t, t*2, t*3), use to animate things inside the shaders.
_SinTime float4 Sine of time: (t/8, t/4, t/2, t).
_CosTime float4 Cosine of time: (t/8, t/4, t/2, t).
unity_DeltaTime float4 Delta time: (dt, 1/dt, smoothDt, 1/smoothDt).

Lighting

灯光部分 根据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):

     
Name Type Value
_LightColor0 (declared in Lighting.cginc) fixed4 Light color.
_WorldSpaceLightPos0 float4 Directional lights: (world space direction, 0). Other lights: (world space position, 1).
_LightMatrix0 (declared in AutoLight.cginc) float4x4 World-to-light matrix. Used to sample cookie & attenuation textures.
unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0 float4 (ForwardBase pass only) world space positions of first four non-important point lights.
unity_4LightAtten0 float4 (ForwardBase pass only) attenuation factors of first four non-important point lights.
unity_LightColor half4[4] (ForwardBase pass only) colors of of first four non-important point lights.
unity_WorldToShadow float4x4[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):

     
Name Type Value
_LightColor float4 Light color.
_LightMatrix0 float4x4 World-to-light matrix. Used to sample cookie & attenuation textures.
unity_WorldToShadow float4x4[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 ForwardBasePrePassFinal 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.

     
Name Type Value
unity_LightColor half4[8] Light colors.
unity_LightPosition float4[8] View-space light positions. (-direction,0) for directional lights; (position,1) for point/spot lights.
unity_LightAtten half4[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_SpotDirection float4[8] View-space spot light positions; (0,0,1,0) for non-spot lights.

Fog and Ambient

     
Name Type Value
unity_AmbientSky fixed4 Sky ambient lighting color in gradient ambient lighting case.
unity_AmbientEquator fixed4 Equator ambient lighting color in gradient ambient lighting case.
unity_AmbientGround fixed4 Ground ambient lighting color in gradient ambient lighting case.
UNITY_LIGHTMODEL_AMBIENT fixed4 Ambient lighting color (sky color in gradient ambient case). Legacy variable.
unity_FogColor fixed4 Fog color.
unity_FogParams float4 Parameters 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.

Various

     
Name Type Value
unity_LODFade float4 Level-of-detail fade when using LODGroup. x is fade (0..1), y is fade quantized to 16 levels, z and w unused.

内建函数

Vertex transformation functions in UnityCG.cginc

Function: Description:
float4 UnityObjectToClipPos(float3 pos) Transforms a point from object space to the camera’s clip space in homogeneous coordinates. This is the equivalent of mul(UNITY_MATRIX_MVP, float4(pos, 1.0)), and should be used in its place.
float3 UnityObjectToViewPos(float3 pos)

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.

Generic helper functions in UnityCG.cginc

Function: Description:
float3 WorldSpaceViewDir (float4 v) Returns world space direction (not normalized) from given object space vertex position towards the camera.
float3 ObjSpaceViewDir (float4 v) Returns object space direction (not normalized) from given object space vertex position towards the camera.
float2 ParallaxOffset (half h, half height, half3 viewDir) calculates UV offset for parallax normal mapping.
fixed Luminance (fixed3 c) Converts color to luminance (grayscale).
fixed3 DecodeLightmap (fixed4 color) Decodes color from Unity lightmap (RGBM or dLDR depending on platform).
float4 EncodeFloatRGBA (float v) Encodes [0..1) range float into RGBA color, for storage in low precision render target.
float DecodeFloatRGBA (float4 enc) Decodes RGBA color into a float.
float2 EncodeFloatRG (float v) Encodes [0..1) range float into a float2.
float DecodeFloatRG (float2 enc) Decodes a previously-encoded RG float.
float2 EncodeViewNormalStereo (float3 n) Encodes view space normal into two numbers in 0..1 range.
float3 DecodeViewNormalStereo (float4 enc4) Decodes view space normal from enc4.xy.

Forward rendering helper functions in UnityCG.cginc

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.

Screen-space helper functions in UnityCG.cginc

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.

Vertex-lit helper functions in UnityCG.cginc

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

Unity 内建数据索引相关推荐

  1. java代码内创建mysql索引_点评阿里JAVA手册之MySQL数据库 (建表规约、索引规约、SQL语句、ORM映射)...

    下载原版阿里JAVA开发手册  [阿里巴巴Java开发手册v1.2.0] 本文主要是对照阿里开发手册,注释自己在工作中运用情况. 本文内容:MySQL数据库 (建表规约.索引规约.SQL语句.ORM映 ...

  2. 数据索引是什么?索引作用是什么?什么样的字段适合建索引?索引的优缺点是什么?

    数据索引是什么?索引作用是什么?什么样的字段适合建索引?索引的优缺点是什么? 数据库索引,是数据库管理系统中一个排序的数据结构,索引的实现通常使用B树及其变种B+树.在数据之外,数据库系统还维护着满足 ...

  3. mysql 建复合索引_关于mysql建立索引 复合索引 索引类型

    这两天有个非常强烈的感觉就是自己在一些特别的情况下还是hold不住,脑子easy放空或者说一下子不知道怎么去分析问题了,比方,问"hash和btree索引的差别",这非常难吗.仅仅 ...

  4. python生成递增序列_Python的6种内建序列之通用操作

    数据结构式通过某种方式(例如对元素进行编号)组织在一起的数据元素的集合,这些数据元素可以是数字或者字符,甚至可以是其他数据结构.在Python中,最基本的数据结构是序列(sequence).序列中的每 ...

  5. python 生成001开始的序号_你知道嘛:Python内建序列通用操作有6种实现方法(赶快收藏)...

    本文内容主要介绍了Python内建序列通用操作6种实现方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下!!! 数据结构式通过某种方式(例如对元素进 ...

  6. python内建集合模块collections功能,计数,有序,双向队列

    一.官方介绍 这个模块实现了特定目标的容器,以提供Python标准内建容器 dict , list , set , 和 tuple 的替代选择. namedtuple() 创建命名元组子类的工厂函数 ...

  7. Python学习笔记:常用内建模块2:collections

    前言 最近在学习深度学习,已经跑出了几个模型,但Pyhton的基础不够扎实,因此,开始补习Python了,大家都推荐廖雪峰的课程,因此,开始了学习,但光学有没有用,还要和大家讨论一下,因此,写下这些帖 ...

  8. Django内建模版标签和过滤器

    第四章列出了许多的常用内建模板标签和过滤器.然而,Django自带了更多的内建模板标签及过滤器.这章附录列出了截止到编写本书时,Django所包含的各个内建模板标签和过滤器,但是,新的标签是会被定期地 ...

  9. python文件输入符_python基础入门详解(文件输入/输出 内建类型 字典操作使用方法)...

    一.变量和表达式 >>> 1 + 1 2 >>> print 'hello world' hello world >>> x = 1 >&g ...

最新文章

  1. mysql 8.0配置主从同步_MySQL8.0.19开启GTID主从同步CentOS8
  2. Java编程比C编程好吗?《精通Unix下C语言与项目实践》读书笔记(15)
  3. getopt java_Java命令行界面(第28部分):getopt4j
  4. oracle set autocommit,Oracle Sqlplus SET AUTOCOMMIT
  5. linux java echo 3,Linux常用命令13 - echo
  6. DesignPattern_Java:Proxy Pattern
  7. rs232接口_RS232接口与RS485的区别
  8. 程序员是否应该创造面向 IDE 而非人类的编程语言?
  9. bp神经网络数字识别matlab_pytorch神经网络实践(1): 安装与初次使用pytorch搭建神经网络实践手写数字识别教程
  10. 中信证券显示连接服务器,我的中信证券的交易软件真不好用
  11. 英文科技论文各部分的时态和语态
  12. 永磁同步电机矢量控制(一)——数学模型
  13. 玉米生吃好还是熟吃好 各种情况分析
  14. 转载:2016.3.15 回忆录
  15. Android PC同步软件 类似 apple 的 itunes
  16. AHP层析分析法初步讲解
  17. vivo支持鸿蒙系统吗,什么手机可以刷鸿蒙系统?vivo、OPPO、三星手机刷鸿蒙系统教程...
  18. 什么是尾调用优化和尾递归?
  19. 基于AndFTP完成PC机与Android设备互传文件
  20. 编写10ms延时的子程序c语言,单片机定时器延时程序

热门文章

  1. 标准库类型String,Vector
  2. Linux文件系统的实现 (图文并茂,比较好)
  3. MacosX 下GCC编译指定版本的代码
  4. 七天学会SALTSTACK自动化运维 (3)
  5. Vue表单类的父子组件数据传递示例_vue.js_脚本之家
  6. javascript --- [小练习]变量提升、优先级综合
  7. bootstrap --- 面板
  8. Vue项目代码改进(五)—— 将侧边栏菜单改造为动态后,如何按需显示不同图标
  9. Android JNI开发系列(二)HelloWorld
  10. 小程序跨行跨列多列复杂表格实现