Open david4shure opened 1 month ago
How big is it? How far are you looking at it from? It looks like the distances you're using are simply too large.
I don't remember seeing that in the default scene 🤔 Which version of Godot is it? Which version of the plugin?
If you're looking from very far away in Godot 4.2 (in terms of ratio atmosphere height / distance, not absolute distance), it's possible that the depth buffer becomes too imprecise and starts doing this. Having a small near distance or a high far distance in your camera can affect this too. There is a sphere depth factor
property meant to counteract this effect as you get further and further away, which blends depth to a procedural sphere instead of the depth buffer, though it's not a silver bullet as it might affect how it looks, and might still break at an even higher distance. In the space game I used the plugin into, I also combine that property with a change of near clip distance in camera settings while flying into space, which increases depth precision.
In Godot 4.3, reverse-Z was implemented and that problem isn't happening. However, it needs a manual change in the atmosphere shader because Godot didn't expose a REVERSE_Z
preprocessor symbol, which would have allowed us to handle it automatically...
Yep, I am not using Godot 4.3 as its curently an RC. The strange behavior seems to be exaggerated on larger objects. I see what you mean about the z-near and z-far. The trouble I am having is that I am trying to make a very large earth that looks nice from far away, and that I can zoom my camera into and look at the sky as if I was on the ground, and to do this well I need to create a sufficiently large earth. Is something like this possible with the current godot version?
How big is it? How far are you looking at it from? It looks like the distances you're using are simply too large.
I don't remember seeing that in the default scene 🤔 Which version of Godot is it? Which version of the plugin?
If you're looking from very far away in Godot 4.2 (in terms of ratio atmosphere height / distance, not absolute distance), it's possible that the depth buffer becomes too imprecise and starts doing this. Having a small near distance or a high far distance in your camera can affect this too. There is a
sphere depth factor
property meant to counteract this effect as you get further and further away, which blends depth to a procedural sphere instead of the depth buffer, though it's not a silver bullet as it might affect how it looks, and might still break at an even higher distance. In the space game I used the plugin into, I also combine that property with a change of near clip distance in camera settings while flying into space, which increases depth precision.In Godot 4.3, reverse-Z was implemented and that problem isn't happening. However, it needs a manual change in the atmosphere shader because Godot didn't expose a
REVERSE_Z
preprocessor symbol, which would have allowed us to handle it automatically...
Is something like this possible with the current godot version?
Depends what you mean by "current". As for the hows and whys, see what I said. It all boils down to depth precision at large scales (double-precision builds of Godot will not fix that, it doesnt use doubles in shaders or the depth buffer). If your planet is one single bigass sphere mesh that you scaled to the size of the Earth, you're pretty much guaranteed to get depth buffer issues in general, it's not just the atmosphere. When dimensions of a single object are too large in relation to other things, it makes floating point precision issues way worse. You may have to either work at smaller scales, split the model in chunks that have lower scale, or do other things I mentionned. This demo video was done in Godot 4.2, without double-precision, using a combination of those techniques (so in 4.3 it's even supposed to be better).
Just stressing this important note though, if you are using the shader in 4.3, uncomment this line.
If you did use Godot 4.3, then I have no idea how you got that to happen with the demo scene. I tried opening it like you said, and I didn't see it happen. I only saw it in 4.2, and even then, it was not as pronounced and I had to look from really far. You may send a minimal test project where it happens, but currently I don't have other solutions to your problem beyond everything I described.
Thanks for your detailed response Zylann, much appreciated. If I can repro this in the default scene with gotdot 4.3, I will let you know how and give you a project that you can play with that demonstrates this. I think in my original post I scaled it up, without really understanding why it would affect things with the depth buffer / camera z near / far like you explained.
Btw, thank you for building this! Its really awesome work.
Do you know of any learning resources for being more intelligent about how to handle large scales (rather than using a big sphere like I did)?
I am just looking at the default scene, and I see strange behavior when viewing the atmosphere from a distance.