Pages

Thursday, March 20, 2008

Terrain Rendering and Atmospheric Scattering

Terrain has always been an interest of mine, ever since I loaded my first 8-bit raw heightmap. And last summer I decided to dive into Atmospheric Scattering after reading Ysaneya's developer journal over on gamedev for quite some time.

So I read ATi's paper and looked at their demo and set out to work. Now, I'm not math genious (having only taken calculus and linear algebra), but implementing atmospheric scattering is not for the faint of heart. However, after about a month I had a pretty good working implementation based on the Hoffman and Preetham paper.

Then I started on the water rendering component. There were two articles in Shader X3/4 that were of great help when it came to getting the color just right.

After a couple of months I had a pretty good looking demo. The terrain wasn't anything special, it was just broken down into a quadtree, so I was only able to render 2048x2048 terrain. In order to do this I made the water be at half the height of the terrain and culled the non-visible areas when i was above/below the water, so I was effectively only rendering half of the terrain when I was above/below the water line.

Anyways, on to the pictures:
Scene details:
  • 1024x1024 terrain with multi-texturing and aerial perspective
  • Sky dome with sun and skylight scattering
  • 2048x2048 water plane(size not number of vertices)
  • Bloom post processing
  • Written in c# and managed directx









And a video of it in action:



The water has realistic coastal coloring, soft edges when it intersects the terrain, under water fogging, and depth fogging.

This summer I plan to rewrite the whole application in c++. I also want to extend the terrain rendering with geomipmapping, fix the huge sun, and add volumetric clouds. I had tried implementing volumetric clouds using mega particles, but didn't turn out too well in a dense cloud field. Worked really well for volcanic or nuclear plumes though. More on this in a later post.

7 comments:

YOSH said...

Dang that looks complicated. I'm a Graphic Designer and I have no idea how you CGI guys do what you do!

Charles Humphrey said...

Thats nice man, puts my volumetric clouds to shame, going to have to read that paper and have a go at an XNA version :)

Kyle Hayward said...

Thanks for the comment yosh. It takes lots of hours.

I think your volumetric clouds will go pretty good with my demo when you've finished them Charles ;)

acid2 said...

This is lovely! What data set are you using on the terrain? Also, what type of mapping are you doing on the water - just scrolling normal maps, or is it something more like Perlin noise?

Looks great!

Kyle Hayward said...

Thanks!

The heightmap is the coastal heightmap that I got from Introduction to 3D Game Programming with DirectX 9 a while back. So it's probably just a randomly generated terrain using something like Bryce.

You're correct, the ripples are just 2 scrolling normal maps combined together.

Ultrahead said...

Great work.

[I'm also a reader of Ysaneya's blog for a long time now and he's doing an fantastic job]

Kyle Hayward said...

Yeah, Ysaneya's project is pretty amazing.