How to set boolean property in single3d CGprogram shader?

I am writing a shader for unity3d and I want to specify the shader properties in ie, for example -

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 } 

But these properties are for color, range, float, etc., but I want to enter a boolean, how can I do this, I tried something like -

 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 

but it does not work. I cannot get the boolean property "_isBending", and instead I get an error in the line

  _isBending("is Bending",bool) = true 
+6
source share
2 answers
 [MaterialToggle] _isBending("is Bending", Float) = 0 

or

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

At least you will have a visual toggle button.

+11
source

Booleans are not supported in Unity shader properties. To get around this attempt and use float instead. See this page for more information: http://docs.unity3d.com/Documentation/Components/SL-Properties.html

+2
source

Source: https://habr.com/ru/post/954527/


All Articles