16 August 2008 - 12:30Caustics from a Sphere

I decided that it was probably time for a release of a graphical demo! Since I did not code up anything in relation to the participating media research I thought that this time I would do the research the other way around! This time I have done some research related to light scattering from large spheres. When considering large spheres, it is vaguely speaking possible to use geometrical optics to describe the physics of the scattering pattern. Geometrical optics is also know as ray tracing in computer graphics.

Although, the use of geometrical optics, instead of the full solution to Maxwell’s equations (known as Mie Theory in this relation), does not provide the classical exact solution to the scattering pattern, it will provide an almost correct one. The scattering pattern will contain the forward scattering known as caustics, the primary rainbow, secondary rainbow and so on.

Having computed the scattering pattern from a sphere and stored in a simple 1D table (say floating point texture), it is pretty straight forward to imagine the use in a real-time application, since the scattering of light in any direction from the sphere is now known from a single look up. Actually it is only a 1D table for a infinite distance light source. In order to handle a nearer point light source correctly, it is necessary to compute a two dimensional table, because the finite distance to the sphere excludes some possibilites of the incoming angles depending on the radius of the sphere. Also to get the entire range of rainbow colors one would have to compute the scattering for different wavelengths.

The colors of the rainbow Cornell box with point light Cornell box with infinite distant source

Demo Info

It is possible to use either the 1D or the 2D apporach in the implementation. Make sure you try both, because there is a pretty rainbow hiding! In the demo the sphere has the same properties as a large water drop and the scattering was only computed for three different wavelengths red, green, and blue. No indirect lighting was taken care of (hey it should be able to run real-time). This means that when the light source (which is modeled as being a point light source) is close to the sphere there will be a large ugly unrealistic shadow on the other side of the sphere. In addition, only light coming directly from the light source will be scattered through the sphere. In principle one could add secondary bounces.

Please, be patient with the loading time, the scattering tables are stored as simple ASCII data. The sphere itself is rendered by a combination of the reflection of light and the first bounce of light coming from the environment. The reflection is computed using the scattering tables ones again, while the light from the environment is estimated by rendering a cube map and looking up in the direction of the double refracted ray through the sphere.

Note that the reference is really enjoyable reading for folks with that sense of humor and is highly recommendable.

Download

Sphere Caustics Demo (2.4MB, Windows only)

References

[1] H.C.Van De Hulst, Light Scattering by Small Particles

No Comments | Tags: Real-Time Rendering

25 July 2008 - 9:49Analytic Approaches to Single Scattering in Participating Medias

I am proud to finally publish my article concerning analytic approaches for rendering participating medias. Enjoy!

Abstract

An analytical approach toward visualization of participating media is presented. The volume rendering equation is considered under the assumption that the in-scattering integral can be sampled as a Dirac delta function in the direction of the illuminating light source. This assumption leads to a completely general result for isotropic homogeneous single scattering medias for which the airlight integral is shown to be a special case of. In addition, the limit for which a light source positioned far away is considered, which is particularly interesting in the case of ocean rendering.

The properties of the result are investigated and an approximate model for point light sources is proposed. The presented model is shown to approximate well for thin medias with a close light source and is suitable for real-time rendering. It is capable of simulating homogeneous translucent medias with a low albedo like marble, wax, skin, and smoke.

Download
Analytic Approaches to Single Scattering in Participating Medias (0.3MB)

References
[1] GREEN, S. 2004. Real-time approximations to subsurface scattering,
http://http.developer.nvidia.com/GPUGems/gpugems_ch16.html.
GPU Gems, Chap 16.

[2] JENSEN, H. W. 2001. Realistic image synthesis using photon mapping.
A. K. Peters, Ltd., Natick, MA, USA.

[3] SUN, B., RAMAMOORTHI, R., NARASIMHAN, S. G., AND NAYAR, S. K. 2005.
A practical analytic single scattering model for real time rendering.
ACM Trans. Graph. 24, 3, 1040–1049.

[4] WENZEL, C. 2007. Real-time atmospheric effects in games revisited,
http://ati.amd.com/developer/gdc/2007/d3dtutorial_crytek.pdf.
GDC 2007.

No Comments | Tags: Real-Time Rendering, Realistic Image Synthesis

9 June 2008 - 14:41Global Relief Mapping Technique

In which direction is the development of relief mapping techniques heading?

Techniques for visualizing surfaces of highly detailed geometry without exploiting the bandwidth to the stress limits by passing a huge amount of primitives down the graphics pipe have been a research topic for quite a while. Currently, techniques such as bump mapping, parallax mapping, and parallax occlusion mapping seem to be the standard techniques that are present in every pipeline of a 3D engine on the market today. Among newer detailed surface techniques we find a large group of relief mapping techniques:

- Per-Pixel Displacement Mapping with Distance Function (GPU GEMS 2)
- Interval Mapping
- Cone Step Mapping
- Relaxed cone step mapping For Relief Mapping (GPU GEMS 3).

All these techniques are based on fixed point iteration schemes (sometimes called ray tracing), which are solved numerically in order to find the actually displacement/offset of the texture coordinates for each pixel. Such approaches are of course much more accurate than the approximations techniques bump mapping and parallax mapping. The advantage of viewing the problem as a fixed point problem is that the problem can be mapped directly onto the pixel shader, which is intuitive and easy!

However, I think techniques which consider the problem more globally will occur in the future. A global approach will solve for all pixels at once and then use the solution to render. I am of course working on such an approach, which most likely will be called inverse mapping. The technique has some relation to my previous post “The Inverse Function Theorem”. The meaning with this post was however to discuss some of the advantages/disadvantages of global approaches versus the fixed point schemes (I will denote the fixed point schemes local schemes from now on), and write about the idea of using mapping techniques for skybox rendering. First a list of some significant advantages and disadvantages:

Advantages: coherent solution, no artifacts, no iteration in pixel shaders, better solutions of deep surfaces, more general computing minded, only needs to be recomputed when the viewpoint changes.
Disadvantages: same time complexity, no culling.

Obtaining a global coherent solution will not contain artifacts as seen in for example the local approach cone step mapping, where solutions sort of blend around the edge of ridges on the surface. The solving technique will differ much from the fixed point techniques and does not match the fix graphical pipeline as well as the these, however GPU’s are beginning to support better languages for general purposes (I am especially referring to CUDA), which the first robust implementation most likely will be targeted towards. One disadvantage is the lack of culling. It is hard to do know which pixels that should be culling since the solution is obtained independent of what is going on in the color buffer, where as the local approaches are performed directly into the color buffer and culling is therefore easy.

I have done some simple CPU and shader implementations which executes fine! I have included a sample picture and a movie of a parabolic cylinder surface, which are rendered using my technique. The white dot shows the position of a point light. Animation Clip (17MB)

Parabolic Cylinder Surface

The time complexity of the global technique seems to be very similar to the local approaches - but it provides much better quality of the rendering. Furthermore, it should be noted that both local and global techniques lack the support of multiple depth maps, which is a research problem for itself. Allowing multiple depth maps enables the possibility of the surface to fold in the depth direction.

Using a global mapping technique for skyboxes

Everyone that has tried to play an ordinary open scenario FPS game have noticed that the levels of the game are cut off at some point in space. Standing at this cut off boundary one can often see what is called the skybox. My favorite example of a skybox can be found in Half Life 2 Episode 2 (see picture), where the background is not a simple static background, but contains dynamical elements which helps making it a part of the whole scenario. Another good example is the skyboxes used in the game Riddick EFBB – which the Swedish developers Starbreeze actually acquired out of house, but never the less it is some real nice artwork.

Half Life 2 Episode 2

Now, imagine having a technique that could present as much geometry you would like at the far distances of the scenario. This technique could be the global mapping technique! It will be able to handle such things and will provide backgrounds of same quality as the rest of the scene! This means that city scenes could render houses of the same quality in the far distances and open spaces with a lot of vegetation could be rendered at the same quality in the far distances. Imagine such techniques in games like: Assassins Creed, Alan Wake, Far Cry 2, GTA IV, the city seen in the Half Life screen, Hitman, The Witcher, to name a few. Of course, the technique that I have discussed have some immediate technical problems, such as the resolution of surface details (normal map, depth maps), the requirement of multiple depth maps, and some difficulties with dynamic environments. But seen in the light of the skybox and LOD techniques (seen in far cry) that are the standards today – this idea would certainly be a step forward!

No Comments | Tags: Real-Time Rendering