**CSE168 Rendering Algorithms**

**Assignment 4/Project**

**Ocean Surface Modeling and Rendering**

The objective of this project has been to explore and implement models for:

1. Ocean surface

2. Light transport to the ocean surface

3. Light transport inside the ocean volume

4. Light arriving at the eye from the ocean surface & volume

**Surface Modeling**

The mathematical model which has been used to create the ocean's surface in this project was presented by Jerry Tessendorf [1] in SIGGRAPH course notes. This model utilizes Fast Fourier Transform (FFT) to determine the height of different points on a 2D grid on the surface. The ocean properties have been studied for a long time and a number of models have been developed. The course notes mentioned use a statistical technique to model the surface which is the sum of a very large number of waves traveling in different directions. At any point the effect these waves is summed using FFT. Each wave is characterized by a wave number and its frequency is chosen as a gaussian random number with mean 0 and standard deviation 1 and the spectrum used is Phillips Spectrum. Here is an example of the ocean surface generated using this algorithm.

*Figure 1. Ocean surface model created in MATLAB.*

**Light Transport from Sky to Ocean Surface**

The light transport model chosen for the project was presented by Preetham, Shirley and Smiths in the paper "A Practical Analytic Model for Daylight"[2]. The reason for using this model is that it incorporates wavelength dependent behavior in addition to simulating illumination due to sun, sky (the ambient illumination) and the aerial perspective. Since this model used wavelengths to represent light, it can simulate effects like color shift in the evening or during haze. Though this model assumes that there are no clouds, I believe that it provides a fairly realistic representation of illumination reaching the earth's surface. It incorporates light scattering and attenuation due to water vapors, ozone, dust particles and other gases in the atmosphere. It required the geographic parameters like latitude, longitude, time of day and day of year to generate sun's position and then it computes the light reaching the atmosphere and subsequently the earth's surface. For the purpose of this project only the sun and sky illumination models have been used. Some basic source code for the implementation was available[] and which has been extended and used in this project.

**Light Transport to the Ocean Floor**

In order to simulate the transport of light inside water volume another model has been used. This was presented by Premoze and Ashikhmin[3]. This model also considers the fact that different wavelengths are scattered and scattered differently inside the water volume. This model takes the radiance reaching the surface of the ocean from the sun and the sky and determines how much of this light will reach the ocean floor. Once that is known, it computes how radiance will be emitted back to the viewer taking into account the scattering and absorption due to water volume having other particles.

Over all here is how the radiance reaching the eye is computed: First the viewer ray's hit point with the water surface is determined. At this point the Fresnel reflectivity is computed and the radiance from the sky being reflected into this direction is determined. The refracted ray is traced and its intersection with the ocean floor gives the point from where additionally radiance is sent towards the eye. Now the radiance from the sun and radiance from the sky (from a number of different directions using MC) is computed. Part of this radiance passes through the surface and reached the ocean floor. There is attenuation and scattering on this path. Now radiance reaching the surface of the ocean and subsequently to the eye from the ocean floor is computed. The sum of this and the radiance reflected form the surface is gives the total radiance reaching the eye from this point on the ocean surface.

A number of simplifications have been done to make this model simpler e.g. the radiance reaching the ocean floor is not considered to be refracted along the path and the ocean floor is considered plain. Also the color shift due to the aerial perspective has been ignored.

*Figure 2. The best result at the time or rendering competition.*

**Problems faced**

The hardest problem faced during this project has been conversion of the radiance (SPD) into RGB color values. Most of the efforts spent searching and trying different ideas have been fruitless and consequently, I am unable to show a nice image representing the effort that has gone into this project.

**Coming Back to Life**

After the rendering competition I luckily found a code snapshot from the previous night when things were not so bad. After making some changes I started getting the images I had seen before. Here they are for different times of day:

*Figure 3. Early during the day.*

*Figure 4. Notice a "missing" triangle - showing that its dark on the other
side of the world.*

*Figure 5. Late evening time.*

While rendering these images, I have used a "hack" to keep the image viewable. The way it works is that when the XYZ chromaticity values are computed from the SPD, these values are not immediately converted to x,y, and z, instead they are stored as is and the maximum is compared with each pixel and updated when necessary. After the whole image has been generated and the X, Y and Z values saved, the maxXYZ is used to scale them to x, y and z and then converted to RGB. Additionally a scale factor is used (100 for these images) so that the pixel intensities are visible.

I am not sure if this hack has any real basis, it just worked for me after trying other schemes/hacks for a number of days.

I discovered some code [4] for the daylight model which I have used. I did add a number of missing pieces which were not available. In addition to that I have used the xyz to rgb conversion provided at [5].

**References:**

[1] Jerry Tessendorf. "Simulating Ocean Water". SIGGRAPH 2004 Course Notes.

[2] A. J. Preetham, Peter Shirley, Brian Smits. "A Practical Analytic Model for Daylight". SIGGRAPH 1999.

[3]** **Simon Premoze & Micheal Ashikhmin. "Rendering Natural Waters".
Computer Graphics forum. Volume 20, number 4 (2001), pp189-199.

[4] http://www.cs.utah.edu/vissim/papers/sunsky/

[5] http://www.fourmilab.ch/documents/specrend/