目录索引
译文
数字(number)与滑条(slider)两种类型的属性允许我们在着色器中添加数值类型的变量。假设我们打算创建一个实现光照功能的着色器,“0”代表亮度为 0%,“1”代表亮度为 100% ,那么我们就可以创建一个范围为0到1的滑条类型属性来表示亮度。
声明数字与滑条类型的语法如下所示:
// name ("display name", Range(min, max)) = defaultValue
// name ("display name", Float) = defaultValue
// name ("display name", Int) = defaultValue
Shader "InspectorPath/shaderName"
{
Properties
{
_Specular ("Specular", Range(0.0, 1.1)) = 0.3
_Factor ("Color Factor", Float) = 0.3
_Cid ("Color id", Int) = 2
}
}
在上面的例子中,我们声明了三个属性,分别是名为“_Specular”的范围类型属性、名为“_Factor”的浮点数类型属性与名为“_Cid”的整型类型属性。
原文对照
These types of properties allow us to add numerical values to our shader. Let’s suppose that we want to create a shader with functions of illumination, where “zero” equals 0% illumination and “one” equals 100% illumination. We can create a range for this (e.g. Range (min, max)) and configure the minimum, maximum and default illumination values.
The following syntax declares numbers and sliders in our shader:
// name ("display name", Range(min, max)) = defaultValue
// name ("display name", Float) = defaultValue
// name ("display name", Int) = defaultValue
Shader "InspectorPath/shaderName"
{
Properties
{
_Specular ("Specular", Range(0.0, 1.1)) = 0.3
_Factor ("Color Factor", Float) = 0.3
_Cid ("Color id", Int) = 2
}
}
In the previous example we declared three properties, a “floating range” type called _Specular, another “floating scale” type called _Factor, and finally, an “integer” type called _Cid.
暂无评论内容