Built-in shader include files 包括内置shader文件 - Unity Shader Reference 系列10

Built-in shader include files 包括内置shader文件

本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>)
仅作为个人学习使用,不得作为商业用途,欢迎转载,并请注明出处。
文章中涉及到的操作都是基于Unity2018.2版本
参考链接:https://docs.unity3d.com/Manual/SL-BuiltinIncludes.html

Unity contains several files that can be used by your shader programs to bring in predefined variables and helper functions. This is done by the standard #include directive, e.g.:
Unity包含几个文件,你的着色程序可以使用它们来引入预定义的变量和帮助函数。这是由标准#include指令完成的,例如:

CGPROGRAM
// ...
#include "UnityCG.cginc"
// ...
ENDCG

Shader include files in Unity are with .cginc extension, and the built-in ones are:
Shader包括文件是.cginc扩展名,内置文件有:

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

These files are found inside Unity application ({unity install path}/Data/CGIncludes/UnityCG.cginc on Windows, /Applications/Unity/Unity.app/Contents/CGIncludes/UnityCG.cginc on Mac), if you want to take a look at what exactly is done in any of the helper code.
这些文件可以在Unity应用程序(在Windows上,{Unity安装路径}/Data/CGIncludes/UnityCG.cginc;Mac上,/Applications/Unity/ Unity.app /Contents/CGIncludes/UnityCG.cginc )中找到。如果您想要查看可在任意帮助代码中找到这些文件到底做了什么。

HLSLSupport.cginc
This file is automatically included when compiling CGPROGRAM shaders (but not included for HLSLPROGRAM ones). It declares various preprocessor macros to aid in multi-platform shader development.
在编译CGPROGRAM shaders(但是没有包含HLSLPROGRAM)时,会自动包含这个文件。它声明了各种预处理器宏来帮助多平台着色器的开发。

UnityShaderVariables.cginc
This file is automatically included when compiling CGPROGRAM shaders (but not included for HLSLPROGRAM ones). It declares various built-in global variables that are commonly used in shaders.
在编译CGPROGRAM shaders(但是没有包含HLSLPROGRAM)时,会自动包含这个文件。它声明了在着色器中常用的各种内置全局变量。

UnityCG.cginc

This file is often included in Unity shaders. It declares many built-in helper functions and data structures.
这个文件通常包含在Unity着色器中。它声明了许多内置的帮助函数和数据结构。

Data structures in UnityCG.cginc

  • struct appdata_base: vertex shader input with position, normal, one texture coordinate.
  • struct appdata_tan: vertex shader input with position, normal, tangent, one texture coordinate.
  • struct appdata_full: vertex shader input with position, normal, tangent, vertex color and four texture co
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值