How can I use an object as a mask in my shader?
Right now my object is unshaded and has a specific color that I can look for in my shader but there are a few limitations.
E.g. if I want to use effects like glow the object is affected and its not reliable to look for the specific color anymore.
Shader Object as maks (3D)
One way is to use a second viewport (similar to a render target). You can render just the mask object (with a solid color, or even just a full color, but with the background set to like black or white and then all other objects hidden via cull masks). Then read the texture from the second viewport and pass that in as a uniform to the real shader. Then you can mask out the object, without interference from post processing effects.
Just note that this is an expensive operation. Viewports are pretty slow in Godot. You can probably have 2 or maybe 3 at the most before it loses too much performance. In some cases, you can render the second viewport as a lower resolution, and this works for effects like mirrors and portals and stuff. But for a mask you want pixel perfect and the blur can create strange halo effects.
cybereality
I dont want to use another Viewport. And I cannot exclude an object from post processing?
7892 cybereality
I dont want to use another Viewport. And I cannot exclude an object from post processing?
Unfortunately, I do not think there is a way to tell Godot to exclude an object from post-processing. There are render layers, but then it will not show up at all if it does not have the render layers as the Camera.
Can I get SCREEN_TEXTURE before post processing is applied? This would be enough in my case.
No, I don't believe so. The user-created full screen shaders run after everything else in the rendering pipeline.