博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Unity内置的shader include files
阅读量:6963 次
发布时间:2019-06-27

本文共 1938 字,大约阅读时间需要 6 分钟。

Unity内置的shader include files:这些文件都以.cninc结尾,

  HLSLSupport.cginc:自动包含,一些跨平台编译相关的宏和定义。

  UnityShaderVariables.cginc:自动包含,常用的全局变量。

  UnityCG.cginc:常用的全局变量和函数。
  AutoLight.cginc:光影相关帮助函数,surface shader内部使用此文件。
  Lighting.cginc:surface shader自动包含,定义了标准的光照模式。
  TerrainEngin.cginc:地形和植被shader相关的帮助函数。

UnityGC.cginc数据结构:

  appdata_base / appdata_tan / appdata_full / appdata_img

UnityGC.cginc通用帮助函数:

  float3 WorldSpaceViewDir (float4 v):
  返回从顶点位置到camera位置的世界空间(world space)的朝向,not normailzed。
  参数v:object space vertex position,即顶点的局部空间坐标。
  float3 ObjSpaceViewDir (float4 v):
  返回从顶点位置到camera位置的局部空间(object space)的朝向,not normailzed。
  参数v:object space vertex position,即顶点的局部空间坐标。
  float2 ParallaxOffset (half h, half height, half3 viewDir):
  parallax normal mapping时计算UV offset。
  fixed Luminance (fixed3 c):
  颜色转换亮度(灰度)。

  // Converts color to luminance (grayscale)  inline fixed Luminance( fixed3 c )  {    return dot( c, fixed3(0.22, 0.707, 0.071) );  }

  fixed3 DecodeLightmap (fixed4 color):

  解码lightmap颜色值,根据不同平台返回RGBM或dLDR。
  float4 EncodeFloatRGBA (float v)/float DecodeFloatRGBA (float4 enc):
  编码/解码[0, 1)float <--> 8bit/channel RGBA,注意1.0的编解码会有问题。
  EncodeFloatRG (float v)/DecodeFloatRG (float2 enc):
  编码/解码[0.0,1.0)float <--> 8bit/channel RG,注意1.0的编解码会有问题。
  float2 EncodeViewNormalStereo (float3 n):
  float3 DecodeViewNormalStereo (float4 enc4):
  编码/解码view space noramls <--> 2D 0..1 vector
  Decode函数是对nec4.xy进行解码。

UnityGC.cginc前向渲染帮助函数:(只有在前向渲染时有用,ForwardBase或ForwardAdd pass types)

  float3 WorldSpaceLightDir (float4 v):
  计算world空间光照方向,从顶点位置到光源位置,not normalized。
  float3 ObjSpaceLightDir (float4 v):
  计算object空间光照方向,从顶点位置到光源位置,not normalized。
  float3 Shade4PointLights (...):
  计算四个点光源的光照,前向渲染中会使用此函数来计算逐顶点光照。

UnityGC.cginc和vertex-lit相关的帮助函数:(只有在使用per-vertex lit时有用,Vertex pass types)

  float3 ShadeVertexLights (float4 vertex, float3 normal):
  计算顶点光照,来自4个per-vertex light和ambient。
  参数vertex和normal:局部空间的位置和法线。

转载地址:http://adzsl.baihongyu.com/

你可能感兴趣的文章
java经纬度距离换算,根据距离算经纬度差值
查看>>
关于nginx环境下bootstrap中font-awesome图标不显示的问题
查看>>
java并发之CountDownLatch
查看>>
mysql 删除重复数据
查看>>
PHP等比例缩放图片
查看>>
Linux下Eclipse+CDT的搭建
查看>>
python的tab键补全
查看>>
DevOps系列——公司Docker测试,打版,发布实战
查看>>
SQLITE3 使用总结
查看>>
python3学习之md5加密
查看>>
spring中MessageSource的配置使用方法3--ResourceBundleMessa
查看>>
Python在同一位置刷新显示进度信息
查看>>
解决获取微信用户信息 48001错误
查看>>
js操作单选框
查看>>
说说内存可见性
查看>>
oracle的内存spa与pga
查看>>
百度发力智能终端 百加异军突起
查看>>
《TableStore最佳实践:轻松实现轨迹管理与地理围栏》
查看>>
网络基本功(四):细说路由(上)
查看>>
我的友情链接
查看>>