CS348b2007

A Realistic, Generic Earth/Atmosphere Model - CS348B Final Project

Author

Dick Brouwer

Final Image

8.00am. Images with different sun positions can be found at the bottom of this write-up.

Overview

Rendering scenes, especially outdoors, generally involves using manually created environment maps to realistically render skylight. Especially for twilight scenes with very diverse lightning conditions no suitable tools are readily available. I want to create a generic model for rendering a realistic sky for a given position on the earth, season, time of day and atmosphere condition (e.g. foggy, polluted etc.) to replace outdoors environment maps. My model should therefore not be too computational intensive.

To accurately render skylights many atmospheric effects have to be taken into account, including:

Important papers related to these issues are: Physically Based Simulation of Twilight Phenomena, Realistic Solar Disc Rendering and A Practical Analytic Model for Daylight.

Example images of beautiful skylights are plentiful. Here are some examples of the images I would like to reproduce:

Techniques Used

1st Attempt: Divide the atmosphere in cells and layers

The most realistic way of rendering the sky is to divide the atmosphere into hundreds or thousands of different layers. Each layer is then split into different cells (see pictures). I started implementing this model but ran into some big issues:

All three reasons make this model cumbersome and slow to implement and would not be a great tool as an environment map replacement.

2nd Attempt: Analytical approximations for skylight, sunlight and aerial perspective

I modeled the scene using three different techniques. A skylight (atmosphere) mimicked the colored background and provided illumination on the whole hemisphere on the scene. A directional sunlight was implemented to further illuminate the scene. Lastly, an implementation of aerial perspective rendered the blue-ish foggy effect that occurs when objects are far away and the sky is hazy.

Skylight

The literature mentioned above describes a parametric sky model that is developed by measuring different sky intensities and colors with different sun angles and atmospheric haze combinations. The resulting data is fitted to a model that is reasonably accurate in predicting the color of the sky. Esoteric sky conditions cannot be created but for 'standard' atmospheres this works well. Turbidity is a catch-all term to describe the amount of 'haze' in the sky - replacing detailed calculations for different scattering coefficients for particles in the sky (Rayleigh and Mie scattering). Although turbidity is a great simplification of the true nature of the atmosphere, it is a practical measure of great utility. Because it does not require complex instrumentation to estimate turbidity, it is particularly well-suited for this application. The figure below gives meteorological range Rm for various turbidity values. I implemented the skylight using a infinite area light in PBRT. I created a new spectrum model, colorspace conversion and tonemapping funtions to accurately render this area light. Both will be discussed later.

Sunlight

Sunlight is modeled using a direct lightsource in PBRT. The spectral radiance is looked-up in a table for different wavelengths. Next, the radiance is attenuated by different scattering and absorption parameters (both Rayleigh and Mie scattering are implemented). Both parameters are a function of wavelength (the sky is blue because amongst others the Rayleigh scattering function is proportional to 1/lambda4).

Aerial Perspective

Aerial perspective is calculated by adding the in-scattered sunlight along a ray to the eye with the out-scattering in the atmosphere due to Rayleigh and Mie scattering. Both vary with wavelength (hence the blue-ish background fog present in scenery views). I implemented these methods by modifying the directlighting surfaceintegrator in PBRT (calculating the attenuation and adding a new spectrum class). I compared this model against PBRT's exponential fog model and they turned out to be very similar for the scenes I rendered.

Sun positioning model

Spectrum model

Because atmospheric scattering is wavelength-dependent, I had to use more spectra that PBRT uses by default (3). I choose for a spectrum from 380nm to 780nm with 10nm increments, resulting in 41 spectrum samples. I did not want to change PBRT's default spectrum number to keep the flexibility of adding different lights later on without having to specify 41 spectra values. Instead I implemented a new spectrum class just used for the skylight, sunlight and aerial perspective in my model. The new spectrum model worked well and fast and rendered the wavelength-dependency correctly.

Issues encountered

The most problematic issue I encountered was tone-mapping. The output of the sky model was chromaticity (x and z) and luminance (Y). The brightness of the sun and sky caused my images initially to be completely over-saturated. I tried to do different luminance-scaling techniques combined with color-space conversions, of which some worked better than others:

It turned out that HSV scaling was visually the most pleasing. However, it took me a lot of time to figure this out eventually. Unfortunately I did not compare these methods to PBRT's build-in tonemapping functions.

Approach

Step 1: Sun/Earth Positioning

As a first step I need to model the sun's position relative to the earth given certain input parameters. Because this calculation does not need to be dead-on accurate I can make some simplifying assumptions like using a spherical earth. This should make these calculations fairly straighforward. My input parameters would be: "Time-of-day", "Position on Earth (latitude/longitude)" and "Day-of-year (seasonal dependence)".

Next to calculating the position of the sun I need to collect data on atmospheric conditions. Some I will asume fixed (e.g. athmosphere temperature layers etc.) and others will be parameterized like humidity and aerosol distribution.

Step 2: Atmosphere Modeling

to realistically render the sky I need to calculate direct and indirect illumination of the whole atmosphere. A schematic description of the earth is depicted below:

Some different effects I will have to consider are:

Step 3: Creating Sky Environment Map

Because of the computational intensity of the above-described processes I could potentially output the skylight in an HDRI environment map for re-usage. PBRT can automatically plug-in this environment map in it's calculation and speed-up multiple renderings using the same skylight.

Project Viability

I am currently researching the extend to which I can make this model 100% physcically accurate given the complex nature of the sky. I might have to use several approximations to speed-up the rendering process and the model the atmosphere. This general model could be re-used and expanded in subsequent research however and will definately get the 'basics' of skylight rendering right.

last edited 2007-06-12 03:40:37 by DickBrouwer