一:标准库里的常用.cginc文件

    • HLSLSupport.cginc - (automatically included) Helper macros and definitions for cross-platform shader compilation. 
      HLSLSupport.cginc :(自动包含)跨平台着色器编译帮助宏和定义
    • UnityCG.cginc - commonly used global variables and helper functions. 
      UnityCG.cginc :常用的全局变量和辅助函数
    • AutoLight.cginc - lighting & shadowing functionality, e.g. surface shaders use this file internally. 
      AutoLight.cginc :灯光和阴影功能,例如surface shaders 内在地使用此文件。
    • Lighting.cginc - standard surface shader lighting models; automatically included when you're writing surface shaders. 
      Lighting.cginc :标准surface shader 灯光模型,当你写表面着色器时自动包含。
    • TerrainEngine.cginc - helper functions for Terrain & Vegetation shaders. 
      TerrainEngine.cginc : 地形和植被着色器的辅助函数。

二:辅助函数

Generic helper functions in UnityCG.cginc 在UnityCG.cginc中的通用辅助函数

    • float3 WorldSpaceViewDir (float4 v) - returns world space direction (not normalized) from given object space vertex position towards the camera. 
      float3 WorldSpaceViewDir (float4 v):根据给定的局部空间顶点位置到相机返回世界空间的方向(非规范化的)
    • float3 ObjSpaceViewDir (float4 v) - returns object space direction (not normalized) from given object space vertex position towards the camera. 
      float3 ObjSpaceViewDir (float4 v):根据给定的局部空间顶点位置到相机返回局部空间的方向(非规范化的)
    • float2 ParallaxOffset (half h, half height, half3 viewDir) - calculates UV offset for parallax normal mapping. 
      float2 ParallaxOffset (half h, half height, half3 viewDir):为视差法线贴图计算UV偏移
    • fixed Luminance (fixed3 c) - converts color to luminance (grayscale). 
      fixed Luminance (fixed3 c):将颜色转换为亮度(灰度)
    • fixed3 DecodeLightmap (fixed4 color) - decodes color from Unity lightmap (RGBM or dLDR depending on platform). 
      fixed3 DecodeLightmap (fixed4 color):从Unity光照贴图解码颜色(基于平台为RGBM 或dLDR)
    • float4 EncodeFloatRGBA (float v) - encodes [0..1) range float into RGBA color, for storage in low precision render target. 
      float4 EncodeFloatRGBA (float v):为储存低精度的渲染目标,编码[0..1)范围的浮点数到RGBA颜色。
    • float DecodeFloatRGBA (float4 enc) - decodes RGBA color into a float. 
      float DecodeFloatRGBA (float4 enc):解码RGBA颜色到float。
    • Similarly, float2 EncodeFloatRG (float v) and float DecodeFloatRG (float2 enc) that use two color channels. 
      同样的,float2 EncodeFloatRG (float v) 和float DecodeFloatRG (float2 enc)使用的是两个颜色通道。
    • float2 EncodeViewNormalStereo (float3 n) - encodes view space normal into two numbers in 0..1 range. 
      float2 EncodeViewNormalStereo (float3 n):编码视图空间法线到在0到1范围的两个数。
    • float3 DecodeViewNormalStereo (float4 enc4) - decodes view space normal from enc4.xy. 
      float3 DecodeViewNormalStereo (float4 enc4):从enc4.xy解码视图空间法线

Forward rendering helper functions in UnityCG.cginc
UnityCG.cginc正向渲染辅助函数

These functions are only useful when using forward rendering (ForwardBase or ForwardAdd pass types).

这些函数只有当使用forward rendering(ForwardBase 或 ForwardAdd通道类型)时才有效。

    • 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. 
      从4个点光源计算亮度,来将光照数据牢固的装入向量中。正向渲染使用此来计算逐顶点光照。

Vertex-lit helper functions in UnityCG.cginc
UnityCG.cginc中的顶点光照辅助函数

These functions are only useful when using per-vertex lit shaders ("Vertex" pass type).

这些函数只在当使用逐顶点光照着色器(“顶点”通道类型)时才有效。

    • float3 ShadeVertexLights (float4 vertex, float3 normal) - computes illumination from four per-vertex lights and ambient, given object space position & normal. 
      根据局部空间位置和法线,从4个逐顶点灯光和环境光计算亮度。

三:内置变量 http://docs.unity3d.com/Manual/SL-UnityShaderVariables.html

  • unity_SpecCube0unity_SpecCube0_HDR from the built-in shader variables. unity_SpecCube0 contains data for the active reflection probe. //unity_SpecCube0包含了现在激活的反射探头, unity_SpecCube0_HDR是其HDR颜色数据。

Unity 内置Shader变量、辅助函数等的更多相关文章

  1. unity 内置shader

    几个有用的Unity 内置shader: (一)Standard RenderingMode:Opaque为实体渲染,更改Color的透明通道不会有影响:Cutout会把图片的透明通道显示出来,非严格 ...

  2. Unity内置shader 下载

    Unity内置shader  4.3.1 版本的  其他版本可以自己修改名称 下载地址 http://download.unity3d.com/download_unity/builtin_shade ...

  3. osg内置shader变量

    uniform int osg_FrameNumber:当前OSG程序运行的帧数: uniform float osg_FrameTime:当前OSG程序的运行总时间: uniform float o ...

  4. CESIUM内置shader变量和函数[转]

    cesium中内置了一些常量.变量和函数,在vs和fs中可直接使用. 内置uniform 内置uniform主要置于AutomaticUniforms类里面,该类私有未开放文档. czm_backgr ...

  5. unity, 内置shader下载地址

    在unity的download页面上能找到Built in shaders的下载连接.

  6. 【Unity Shaders】使用CgInclude让你的Shader模块化——Unity内置的CgInclude文件

    本系列主要參考<Unity Shaders and Effects Cookbook>一书(感谢原书作者),同一时候会加上一点个人理解或拓展. 这里是本书全部的插图. 这里是本书所需的代码 ...

  7. Unity内置的shader include files

    Unity内置的shader include files:这些文件都以.cninc结尾, HLSLSupport.cginc:自动包含,一些跨平台编译相关的宏和定义. UnityShaderVaria ...

  8. unity, 查看内置shader源码

    1,建一个球体. 2,建一个材质,将材质拖到球体上. 3,在材质的shader下拉列表中选择想查看的内置shader,点材质栏右上设置按钮->Select Shader 进入shader面板. ...

  9. GLSL语言内置的变量详解

    GLSL语言内置的变量,包括内置的顶点属性(attribute).一致变量(uniform).易变变量(varying)以及常量(const),一方面加深印象,另一方面今天的文章可以为以后的编程做查询 ...

随机推荐

  1. MyBatis学习总结(5)——实现关联表查询

    一.一对一关联 1.1.提出需求 根据班级id查询班级信息(带老师的信息) 1.2.创建表和数据 创建一张教师表和班级表,这里我们假设一个老师只负责教一个班,那么老师和班级之间的关系就是一种一对一的关 ...

  2. jquery-fakeloader插件的使用

    jquery-fakeloader插件示例代码 link rel="stylesheet" href="../../Content/fakeLoader.css" ...

  3. CentOS进入图形界面

    CentOS进入图形界面 学习了: http://www.centoscn.com/CentosBug/osbug/2014/0831/3620.html http://bbs.csdn.net/to ...

  4. bzoj1019: [SHOI2008]汉诺塔(动态规划)

    1019: [SHOI2008]汉诺塔 题目:传送门 简要题意: 和经典的汉诺塔问题区别不大,但是题目规定了一个移动时的优先级: 如果当前要从A柱子移动,但是A到C的优先级比A到B的优先级大的话,那就 ...

  5. Idea配置文件的读取

    开发过程中遇到配置文件读取问题,因此记录以后运用的到. 配置文件位置: 配置文件内容: default_size = 100 grid_size = 20 delayTime = 200 配置文件读取 ...

  6. 模仿百度首页“元宵节汤圆”动图,并实现360°不停旋转(CSS3的animation动画效果)

    模仿百度首页“元宵节汤圆”动图,并实现360°不停旋转(CSS3的animation动画效果) 效果图: 切图地址: https://ss1.bdstatic.com/5eN1bjq8AAUYm2zg ...

  7. java中对象和对象引用的区别

    1.何谓对象? 在Java中有一句比较流行的话,叫做“万物皆对象”,这是Java语言设计之初的理念之一.要理解什么是对象,需要跟类一起结合起来理解.下面这段话引自<Java编程思想>中的一 ...

  8. 752. [BJOI2006] 狼抓兔子

    ★★★   输入文件:bjrabbit.in   输出文件:bjrabbit.out   简单对比时间限制:1 s   内存限制:162 MB Description   Source: Beijin ...

  9. python 3.x 学习笔记7 ( 模块 (修))

    1.定义:模块:用来从逻辑上组织python代码(变量.函数.类.逻辑:实现一个功能),本质就是.py结尾的python文件包:用来从逻辑上组织模块的,本质就是一个目录(必须带有一个__init__. ...

  10. eclipse用tomcat发布网站的目录

    用eclipse添加的tomcat发布网站时,在tomcat安装目录中的webapps时找不到发布的网站.这是由于eclipse的默认配置,把项目发布到别的文件夹中了.如果想发布到webapps里面, ...