I am writing a shader for unity3d and I want to specify the properties of the shader in i.e like -
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 input a boolean value how can i do it 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 this doesnt work I am not able to get the boolean property "_isBending" and I get a Error instead in the line
_isBending("is Bending",bool) = true
In Unity, you write shader programs using the HLSL programming language.
Create your new shader by right clicking in the Assets window and selecting Create->Shader->Standard Surface Shader. Figure 5: Creating a new shader. You may name the shader whatever you wish, but the remainder of this writing will refer to this shader as MyShader.
Shaders are small scripts that contain the mathematical calculations and algorithms for calculating the colour of each pixel rendered, based on the lighting input and the Material configuration.
To use Shader Graph you must first create a Shader Graph Asset. In Unity a Shader Graph Asset appears as a normal shader. To create a Shader Graph Asset you click the create menu in the Project Window and select Shader from the dropdown. From here you can create either a PBR or Unlit Shader Graph Asset.
[MaterialToggle] _isBending("is Bending", Float) = 0
or
[Toggle] _isBending("is Bending", Float) = 0
At least you will have a visual toggle button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With