- Home /
Cut out shader with geometry depth and alpha
Hello, I'm trying to do a shader like shown on image: alt text The shader I've found on the forums cuts out everything on camera till background. But I would like it to cut only the depth of the box that have the material applied. So I want to see a geometry beneath. But also be able to apply the masking texture. Could you please help me with the shader that would do what I would like? I'm totally noob in shader language but I guess it's an easy thing for somebody who knows them well :).
Here is the shader:
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
}}
}
}
Hi, idk if you already found this but maybe this is what you want or at least it helps someway. http://unitycoder.com/blog/2012/02/22/x-ray-cutout-shader-with-mouse/
Hi, that could be it, but you can't define your own alpha mask. Here you use the X,Y,Z,W coordinates. What I need ins$$anonymous$$d is 'apply material to the geometry and make it work'. But that might be a good starting point for other answers!
Hi Galfaroth, found any solution yet? I am currently stuck with the same issue, and would love some guidance :)