ebruneton / precomputed_atmospheric_scattering

This project provides a new implementation of our EGSR 2008 paper "Precomputed Atmospheric Scattering".
BSD 3-Clause "New" or "Revised" License
908 stars 120 forks source link

Artefacts on rendering of sphere #26

Open LocalStarlight opened 6 years ago

LocalStarlight commented 6 years ago

As I mentioned before, I'm working on porting this for Unreal Engine. The rendering of the sky and planet seem to be working ok, but I'm having a strange issue with the rendering of the sphere (or indeed any object). I seem to be getting rendering artefacts on the sphere in line with the horizon behind it:

atmospheredemo_ue4_01

I wondered if this was a purely UE4 thing, so I went back to the demo to see if there was anything going on there, and there does seem to be something similar. Here is an image from the demo, with the relevant part inset with increased contrast to improve visibility of the problem (look at the picture in full size to see it better):

atmospheredemo_screengrab_01

The issue is certainly more pronounced in the UE4 version, but there does seem to be some basis in the demo code as well.

The issue is coming from both the transmittance and in_scatter contributions. Changing the code to this removes the problem:

float3 sphere_radiance = kSphereAlbedo * (1.0 / PI) * (sun_irradiance + sky_irradiance);
return sphere_radiance;

But adding this line back in makes the issue visible: sphere_radiance = sphere_radiance * transmittance + in_scatter;

I have tried bringing in the transmittance and in_scatter separately, and the issue is visible in both, though in slightly different ways.

Why is a foreground object picking up rendering artefacts from the horizon behind it?

I am happy to share the UE4 version if that would help, but since there does seem to be something going on with the demo code itself, perhaps you have some idea what could be causing this?

ebruneton commented 6 years ago

The small artefacts in the demo are due to a combination of causes:

A lot is made in the implementation and in the choice of the texture coordinate mappings (cf Fig. 3 of the paper) used for the 4D tables to minimize the artefacts, but they can't be completely eliminated*.

(*) except by using some hacks, which were used in the previous implementation, but were not reintroduced here because the artefacts are much smaller with the new implementation.

LocalStarlight commented 6 years ago

Thanks so much for the explanation, it makes sense.

I think I need a hack for UE4, because the artefacts are a little too noticeable. Will investigate the previous implementation, thanks.

I have another question. I've noticed that at certain angles when viewing from space, there is a relatively steep jump in brightness at a certain point:

atmospheredemo_screengrab_02

I've failed to figure out where this is coming from. I wondered if it's to do with the resolution of the textures, but I've tried bumping up the resolution of all of them and it doesn't seem to make any difference.

What is the cause of this, and is there some way to create a less harsh transition at this point?

Fewes commented 5 years ago

Hi, I was wondering if you ended up finding a solution to this? I am working on a Unity port myself and have run into the same issue, but the artifacting is much more severe:

Scattering artifacts Scattering artifacts

ebruneton commented 5 years ago

See https://github.com/ebruneton/precomputed_atmospheric_scattering/pull/32

Ralith commented 4 years ago

Has anyone actually solved this? I've attempted all the posted solutions and nasty sparkling artifacts and inappropriate glows still remain from certain viewpoints.

lvvvmd commented 2 years ago

See #32 Hi ebruneton, could please review my solution to this issue? functions.glsl At line 1857 or just search "Hack to avoid rendering artifacts", you will see these codes: // Hack to avoid rendering artifacts when the sun is below the horizon. single_mie_scattering = single_mie_scattering * smoothstep(Number(0.0), Number(0.01), mu_s); And just replace by // Hack to avoid rendering artifacts when the sun is below the horizon. single_mie_scattering = single_mie_scattering * 0.01; // smoothstep(Number(0.0), Number(0.01), mu_s); And then you can solve the problem.