如何在 Unity3D CGprogram 着色器中设置布尔属性



我正在为 unity3d 编写着色器,我想指定着色器的属性,即 -

Shader "GraphicsQuality/MediumScan" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1)
    _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
    _MainTex ("Base (RGB) RefStrGloss (A)", 2D) = "white" {}
    _BumpMap ("Normalmap", 2D) = "bump" {}
    _RimColor ("Rim Color", Color) = (0.48,0.78,1.0,0.0)
    _RimPower ("Rim Power", Range(0,8.0)) = 3.0
}

但是这些属性用于颜色、范围、浮点数等,但我想输入一个布尔值,我该怎么做,我尝试了类似的东西-

Properties{
    _MainTex ("Particle Texture", 2D) = "white" {
    _isBending("is Bending",bool) = true
}
SubShader{
        Pass{
            CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag
                sampler2D _MainTex;
                bool _isBending;
.......continuing

但这不起作用,我无法获得布尔属性"_isBending",而是在行中出现错误

  _isBending("is Bending",bool) = true
[MaterialToggle] _isBending("is Bending", Float) = 0

[Toggle] _isBending("is Bending", Float) = 0

至少你会有一个可视的切换按钮。

Unity 着色器属性不支持布尔值。要解决此问题,请尝试改用浮点数。有关详细信息,请参阅此页面:http://docs.unity3d.com/Documentation/Components/SL-Properties.html

相关内容

  • 没有找到相关文章

最新更新