Open Anyeos opened 9 months ago
Do you have a minimal test project that reproduces the issue, so it can be easier to investigate? This looks like the solar system demo, which is not a small project, so it's harder to figure out what causes the issue.
There is a small demo scene with clouds in the atmosphere plugin.
It works fine in Godot 4.1.3 (vanilla), and also Godot 4.2:
I'm on Windows 10 with nVidia 1060.
Also tried solar system (which requires my custom build of Godot because it uses the voxel module), works too
TL:DR clouds does not work in double precision release
Im having the same issue. While testing the solar system demo, i rescaled earth to planet.radius = 6371.0 instead of 1800.0 and enabled large_scale mode. I was amazed to see it actually worked, but when i landed and exited the ship, i could not move. So i downloaded your double precision release, and im amazed again... i can actually move around on the surface without problems but the clouds are not rendered correctly and i experience exactly the same as Anyeos described.
Unfortunately there is nothing I can do without a proper repro (minimal test project?), especially if you're also using Godot 4.2. Because everytime I try this, clouds work for me (see screenshots I posted). I can't fix something if it doesnt happen. It's really frustrating :( If you're using Godot 4.3, there is a patch for reverse-Z that should be done to make the shader work, but that's not just about the clouds so I dont know.
to replicate: run the solar system demo in godot.windows.editor.x86_64.exe and clouds work run the solar system demo in godot.windows.editor.double.x86_64.exe nd clouds do not work
If that's really the only difference then I'm very puzzled as to what is actually going on... Godot is doing something different in double precision somehow, but I don't know what it would be that affects that specific part of the shader and yet the atmosphere still renders...
I suspect this is a Godot issue: https://github.com/godotengine/godot/issues/85711
There is an argument against using INV_VIEW_MATRIX
in large worlds, however as you experienced, precision loss doesn't affect clouds, which are never rendered close enough to have noticeable artifacts (they are fuzzy so "close" makes little sense). Still, the matrix might be wrong...
Notably, for some reason, INV_VIEW_MATRIX
has its origin negated in double-precision builds. I don't know why, likely a bug.
You could try to modify the shader you're using by doing this change:
void fragment() {
bool b_discard = false;
mat4 inv_view_matrix = INV_VIEW_MATRIX;
inv_view_matrix[3][0] *= -1.0; // <-- undo origin negation
inv_view_matrix[3][1] *= -1.0;
inv_view_matrix[3][2] *= -1.0;
atmosphere_fragment(u_depth_texture, SCREEN_UV, INV_PROJECTION_MATRIX, inv_view_matrix, // <-- pass it here
VIEWPORT_SIZE, v_planet_center_viewspace, v_sun_center_viewspace, ALBEDO, ALPHA, b_discard);
if (b_discard) {
discard;
}
}
I can confirm that the snippet you provided indeed fixes the clouds :D
Thank you Zylann for such dedication to innovate and develop these tools and consepts. It is very inspirational and shows a huge potential!
I don't know how you achieve the clouds but on my case always I get some rendering of a cloud form on the other side (far in horizon) of the planet. It is like an concave mirror where you see too far and too distorted. That is how my clouds are rendered and barely I can see it.![image](https://github.com/Zylann/godot_atmosphere_shader/assets/5976100/aa426b71-3e0d-40e9-b6e4-7847ed18b554)