- Home /
DepthMask shader with gradient alpha
Hi there,
I have a depth mask shader to mask out certain areas on a texture.
This works fine, but I would want it to gradually go from no masking to full masking. So I thought I could just add an overlay texture to get this effect.
As you see here it works fine as long as they're not overlapping
So my question, is there a way to do the gradient alpha through the shader instead, to avoid the overlapping problem? Thanks!
And here's the shader I'm using:
Shader "Alpha Test Depth Mask" {
Properties {
_MainTex ("Texture", 2D) = ""
}
Category {
Tags {Queue = Background}
ColorMask 0
SubShader {Pass {
GLSLPROGRAM
varying lowp vec2 uv;
#ifdef VERTEX
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
uv = gl_MultiTexCoord0.xy;
}
#endif
#ifdef FRAGMENT
uniform lowp sampler2D _MainTex;
void main() {
if (texture2D(_MainTex, uv).a > 0.99)
discard;
}
#endif
ENDGLSL
}}
}
}
Seems like the masking stops working if I set it to that.
Your answer
Follow this Question
Related Questions
Depth mask with alpha / adding alpha to frag grabpass shader 0 Answers
Masking objects with alpha gradient at intersection 0 Answers
Changing material color´s alpha in self iluminated shader 1 Answer
Scripting Shader: How to control Alpha with slider? 1 Answer
Alpha self illum. shader issue 0 Answers