- Home /
Question by
sillanstudios · Jun 01, 2015 at 05:05 PM ·
shadermaterialtransparencyalphacg
Add transparency to mask shader
Hey Guys,
I'd appreciate it if someone could help me out. I want to add transparency to the main texture of this shader:
Shader "MaskedTexture"
{
Properties
{
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
_Color ("Main Color", Color) = (1, 1, 1, 1)
_Mask ("Culling Mask", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range (0,1)) = 0.1
}
// _MainTex ("Color (RGB) Alpha (A)", 2D) = "white"
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Lighting Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
AlphaTest GEqual [_Cutoff]
Pass
{
SetTexture [_Mask] {combine texture}
SetTexture [_MainTex] {combine texture, previous}
}
}
}
I really don't know how to get it to work. Thanks!
Comment
Answer by etopsirhc · Sep 08, 2016 at 10:06 PM
clamp( CutOffColor, CutOutColor, InputColor)
this will display the CutOutColor anywhere the InputColor is less than the CutOffColor so a cut off of (1,1,1,_CutOff) with a cut out of (1,1,1,0) will always display the color of InputColor but will change the alpha to 0 if it's below the _CutOff.
(untested, no guarantees)