Godot Version
4.7.1.stable
Question
So, I’m working on a compositor effect shader, I’ve posted here before about it, and I’ve finished the hardest part of it. There is just one problem now, that I can’t even begin working out. I’ve made an MRP for the previous post, and I’ll link it here so anyone can tell me if I did anything wrong, but I’ll still try and explain my issue as best I can, regardless.
I’m making a datamosh shader. It’s a kind of mpeg corruption that sometimes happens, and it’s a great effect for glitchy scenes. However, I want it to apply only to some objects in the scene, and I did that by adding a second camera (per viewport), and only allowing that camera to see some objects in the scene, using rendering layers for that.
Now, the issue itself: I want the affected objects to still occlude behind the other geometry in the level, and to achieve that, I’m getting the depth buffer of both cameras, and comparing them with vec4(vec3(float(depth < maskdepth)), 1.0) (I also tried step(maskdepth, depth), and passing that as a mask to mix() (I’m not casting to vec4 in mix(), but I’m outputting it to screen like that).
The issue is that, instead of it outputting the expected result, a mask where it’s black by default, and white when the effect is supposed to trigger, it’s outputting a black mask with random mesh faces as white, and highlighting the faces with Z fighting when I move the camera.
This is the scene normally:
The icosphere rotates along 4 randomized axis.
With the bugged shader, it looks like this:
I can see the depth textures work exactly as intended:
Normal scene:
The main depth:
The mask depth:
The masks are working exactly as intended. They are outputting only what they can see, as described. The problem is when I combine them, it looks all buggy, and only really shows up when I move the camera.
Am I doing something wrong? Is my GPU damaged and can’t do boolean anymore? What the hecc is going on here?





