包含此页的版本:
不含此页的版本:
要在ShaderLabUnity 用于定义 Shader 对象结构的语言。更多信息
请参阅术语表将材质属性名称放在 ShaderLab 代码中的方括号中。
此示例代码演示了使用材质属性将unitsShaderLab 的价值Offset命令。
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
}
}
}
要使用 material 属性在 HLSL 代码中设置变量的值,请为材料属性指定与着色器在 GPU 上运行的程序。更多信息
请参阅术语表财产。
您可以在以下文章中看到此技术,其中包括工作代码示例: