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

Artifacts at hight exposures #6

Closed UnivEngineer closed 7 years ago

UnivEngineer commented 7 years ago

Hello! I am using your reference implementation during many years in SpaceEngine. Recently implemented a HDR rendering with autoexposure, and encountered with a major problem. Assuming at daytime we have exposure of 10, at dawn it increases to ~1000, and at a night it increases to ~10^5. At such large exposure, one can observe following problems:

1) A blocky artifacts near the horizon, which fades abruptly as sun goes deeper under horizon (see this pictrure). Size of those blocks can be reduced by increasing SCATTERING_TEXTURE_NU_SIZE four times. Step between "fades" can be reduced by increasing SCATTERING_TEXTURE_MU_S_SIZE four times, but even this is not enough. This is a bad solution, because memory requirements and precomputation times grows absurdly. Maybe changing the mapping parametrization could help? I also thinking of changing linear texture filtering to cubic, but it is more costly.

2) Orange glow on horizon (the "last sunset step") does not fade away even when sun zenith angle is 120. From space it is look like a silverglow of the atmosphere where it must not be visible (picture). This problem can be solved by increasing kMaxSunZenithAngle to 180, but does this makes resolution of the scattering texture in MuS worse?

3) Color distortions are visible soon after sunset. See this picture. Sometimes thing on the left became green.

4) Sharp edge is seen from space.

5) Not related to abovemantioned, but this implementation has seams at horizon.

Thanks for advise!

msomeone commented 7 years ago

issue #1 can be cheaply imporved a lil with "Quintic" texture filtering (google Inigo Quilez)

ebruneton commented 7 years ago
  1. can be solved by using single precision instead of half precision in the precomputed textures (requires "only" 2x memory). I added an option for that in the model and in the demo.

  2. single precision instead of half precision also solves "the orange glow not fading away". The silverglow from space is solved with kMaxSunZenithAngle set to 120 (whether you use single or half precision, although it is more accurate with single precision). The demo now uses 102 with half precision, or 120 with single precision. You can see on the example views (keys 1-9) that single vs half and 102 vs 120 make almost no difference at "normal" exposures.

  3. using single precision also solves color distortion issues at high exposures.

  4. using single precision also reduces a lot this issue. However, there are still some visible steps / bands.

  5. I removed the hack from the initial implementation (cf lines 96-119 in earth.glsl in PrecomputedAtmosphericScattering2.zip) in the new implementation, as I thought the horizon seams were much less of an issue with the new implementation. You can apply this hack to the new implementation if you want.

UnivEngineer commented 7 years ago

Thanks. Artifacts indeed became less noticeable, but not gone completely. I also tried the trick from the post 2, but it doesn't work - some bands are visible. Probably because it doesn't take into account mipmapping, while scattering code needed it. I tried different pieces of code, with no success. pic1 pic2

ebruneton commented 7 years ago

I'm closing this issue as I don't think there is anything more I can do about it.