How would I create this effect in Godot? [X-Ray Vision]
Alright, I'm not looking for shader tutorials or help with shaders in general. I'm coming from Unity and I've been wanting to try Godot for some time now. However, while there is a lot of things to love about Godot there's also some questions I have about creating more complex rendering effects. For instance, how would I go about and create this effect in Godot as easily as possible:
From what I can tell there's no stencil buffers in Godot neither are there any type of material overrides/replacement shaders. So how do you do specific effects like these? The most crucial part of the effect is that it only shows up when the renderer is occluded by a foreground object.
I have some ideas about rendering out the environment and characters to separate viewport with different materials to hack together my own mask, but that seems so convoluted. How do you approach effects like these in Godot? What is the best way to do replacement shaders?
Posted Feb 3, 2020, 9:40 PM UTC
You could add another material, then disable the material Depth Test and design a shader like this: https://imgur.com/a/6fjyRRu
Well, damn that actually works, thanks! Actually easier than the Unity version.
You are welcome, I was surprised too!
That is a really cool way of doing it, love how you put it together in a visual shader.
Also the new fresnel node that was added in 3.2 would easily enhance this shader to do an outline like in the original video.
The fresnel effect does look good! https://gfycat.com/hideousklutzykakarikis
https://i.imgur.com/W94xbRL.png
Ah, that fresnel effect is one Nintendo uses a lot in recent games. I never knew what it was called!
Yeah its a neat effect, its basically inverting the result of a dot product of two vectors. If one of those vectors is the normal in view space and the other is view direction, you get the outline effect, but there are tons of other uses for it.
What does this do, create a yellow overlay (because of no depth test) that cuts in only when at a certain distance?
A yellow overlay if behind something.
Ooh, so the depth just checks if it has anything in front of it?
Yes!