Made a shader for masking objects. It renders the background color or skybox instead of the actual object and any object behind it becomes partly or completely invisible.
Maybe this explains it better…
It has some problems though…
Objects that are in front, but close to this shader has blurred edges. Also, there’s a lot of flickering when objects are close together.
This sounds sort of like the simple shader that I wrote for my portal project:
Shader "My Shaders/Portal" {
SubShader
{
// Turn off lighting, because it's expensive and the thing is supposed to be
// invisible anyway.
Lighting Off
// Draw into the depth buffer in the usual way. This is probably the default,
// but it doesn't hurt to be explicit.
ZTest LEqual
ZWrite On
// Don't draw the RGB colour channels, just the alpha channel. This means
// that nothing visible is drawn. Ideally, I would have liked to set ColorMask
// to draw nothing at all, but it doesn't seem to be possible to say anything
// like ColorMask None.
ColorMask A
Tags{Queue=Background}
// Do nothing specific in the pass:
Pass
{
}
}
}
Just tried the GrabPass shader from the docs, and it seems to do exactly the same thing. I just assumed it would just make the object invisible, not masking things. That’s why I used the Background tag to make sure I grabbed only the bg.
Neil Carter put one of these up on the WIKI a while ago which can be found here. It’s a really cool effect. I’ve been thinking lately about how to do the inverse of this effect, kind of like the “spotlight” effect in Flash but in 3D.
Yes, seen it in the wiki before but never tried it. Awesome.
Think the real problem is my scene. Things work fine when I set a simple scene up for testing, but I need to apply it to a complex setup and that’s when things start to get weird.
Here’s some graphics craziness for you while I ponder my next move
A GrabPass and Yoggy’s approach are in fact entirely different.
GrabPass operates like this: whatever is rendered before rendering the GrabPass gets rendered into a texture. Then you can use the texture. Of course this does not work nicely when you have multiple objects using the GrabPass, and it does not interact with other transparent objects in a very nice way.
Yoggy’s approach does a bit different thing - it basically renders some object that is invisible but actually “occludes” the other objects.