Reputation: 111
I have a shader for bending a tunnel into a curvy path. But when i'm inside that tunnel, i want the walls of the tunnel to be see-through (transparent), so that i could see the skybox and other things outside the tunnel.
I have transparency settings already coded in my shader, but that's not working. Here's my code. Please take a look,
Shader "WorldBend/Bend_Unlit_Segments"
{
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_Emission ("Emissive Color", Color) = (0,0,0,0)
_MainTex ("Base (RGB)", 2D) = "white" { }
_Transparency ("Transparency", Float) = 0.25
}
SubShader
{
Tags {"Queue"="Transparent" "RenderType"="Transparent" }
LOD 100
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Name "BASE"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "BendEffect.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _Emission;
float4 _Color;
float4 _Transparency;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(BendEffect(v.vertex));
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord) * _Color;
col.a = _Transparency;
return col + _Emission;
}
ENDCG
}
}
}
Upvotes: 0
Views: 4108
Reputation: 72
_Color ("Main Color", Color) = (1,1,1,1)
The color value here is in RGBA format, the fourth value ("A") is the alpha channel which sets the transparency. 1 means opaque, 0 means transparent. Values in between, well, works just like the other RGB values.
Upvotes: 1