Closed MaximeDup closed 5 years ago
From Unreal Engine:
Thanks for this! It seems you ported and adapted the hack from the initial implementation? In your change 'a' is no longer used and it seems you just clamp 'mu' to some value just above the horizon?
I tried a simplified version with
--- a/atmosphere/functions.glsl
+++ b/atmosphere/functions.glsl
@@ -1806,6 +1806,14 @@ RadianceSpectrum GetSkyRadianceToPoint(
Length d = length(point - camera);
bool ray_r_mu_intersects_ground = RayIntersectsGround(atmosphere, r, mu);
+ // Hack to avoid rendering artifacts near the horizon, due to finite
+ // atmosphere texture resolution and finite floating point precision.
+ if (!ray_r_mu_intersects_ground) {
+ Number mu_horiz = -SafeSqrt(
+ 1.0 - (atmosphere.bottom_radius / r) * (atmosphere.bottom_radius / r));
+ mu = max(mu, mu_horiz + 0.004);
+ }
+
transmittance = GetTransmittance(atmosphere, transmittance_texture,
r, mu, d, ray_r_mu_intersects_ground);
and it seems to give more or less the same results. Can you confirm?
Result were very similar, and your solution much more elegant! I ended up not using this fix after improving my texture generation during precompute phase. Current iteration: https://www.youtube.com/watch?v=wPGMbprrtDA
Screen from current UE4 version. I've read several other people implemented your latest atmosphere version in UE4, one of which gonna be sold on the marketplace. Might get better results than mine, but i'm really satisfied with mine so far!
Impressive work! Since you don't need the patch in the end, I will not commit it.
I ended up not using this fix after improving my texture generation during precompute phase.
Can you elaborate on what changes were necessary? Are they something that could be upstreamed here?
I'd still love to have some clarity here. What's the proper solution to the severe artifacts that can occur?