ShaderLab 之 UNITY_INITIALIZE_OUTPUT

时间:2024-12-18 08:36:44

  在 HLSLSupport.cginc 文件中定义了此宏:

#if defined(UNITY_COMPILER_HLSL)
#define UNITY_INITIALIZE_OUTPUT(type,name) name = (type)0;
#else
#define UNITY_INITIALIZE_OUTPUT(type,name)
#endif

  只有在HLSL编译器编译时,它才工作,初始化name参数,否则编译器可能会报如下错误:

“Shader error in 'Jie/Test': 'vert': output parameter 'o' not completely initialized at line 37”