要在__ ShaderLab__Unity 用于定义着色器对象结构的语言。更多信息
See in Glossary 代码中通过材质属性设置变量的值,请在 ShaderLab 代码中将材质属性名称置于方括号中。
此示例代码演示使用材质属性设置 ShaderLab Offset 命令的 units 值的语法。
Shader "Examples/MaterialPropertyShaderLab"
{
Properties
{
// Change this value in the Material Inspector to affect the value of the Offset command
_OffsetUnitScale ("Offset unit scale", Integer) = 1
}
SubShader
{
// The code that defines the rest of the SubShader goes here
Pass
{
Offset 0, [_OffsetUnitScale]
// The code that defines the rest of the Pass goes here
}
}
}
要使用材质属性在 HLSL 代码中设置变量的值,请为材质属性提供与着色器属性相同的名称。
可以在以下文章中查看此技术,其中包括正常工作的代码示例: