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

confused with mapping mu_s in single scattering #38

Closed tingxia1028 closed 3 years ago

tingxia1028 commented 4 years ago

I don't understand why the formulation like that, can you explaint that to me in your free time and i would appreciate it. Length d_min = atmosphere.top_radius - atmosphere.bottom_radius; Length d_max = H; Number a = (d - d_min) / (d_max - d_min); Number A = -2.0 atmosphere.mu_s_min atmosphere.bottom_radius / (d_max - d_min); Number u_mu_s = GetTextureCoordFromUnitRange( max(1.0 - a / A, 0.0) / (1.0 + a), SCATTERING_TEXTURE_MU_S_SIZE);

ebruneton commented 3 years ago

This is an ad-hoc function satisfying the properties we want for this mapping: mapping from [mu_s_min, 1] to [0, 1], with a large slope near the horizon (mu_s ~ 0) to get more texture samples near the horizon.

plot

Other formulations are possible, as long as they have these properties.

The value for A was using an approximation, and thus mu_s_min was not mapped exactly to 0. I changed this with https://github.com/ebruneton/precomputed_atmospheric_scattering/commit/d9954923ccd810be2d4443268a182bcb96544c1e, which also adds some comment explaining the properties of the mapping.