Final Project by Larry Kyrala for CS 175: Introduction to Computer Graphics Professor: Hanspeter Pfister Harvard University Fall 2010

Snowflake

a snowflake simulator

Description

What exactly are you planning to implement? What is the basic functionality of your application? Which extensions will you consider? Be as specific as possible. Bullets are fine — you should order the features of your program in terms of importance (most important feature first, etc.)

Kenneth Libbrecht at CalTech has done some amazing research on the physics of snowflake formation. The image to the left links to an animated gif showing time-lapse photography of a lab-grown snowlake.

Since viewing the formation of snowflakes in the wild isn't possible currently, I thought an interesting graphics project would be to simulate the growth of snowflakes as they fall.


Controls

keys:
  ESC                 - quit
  0   zero            - cycle through 5 "real life" snowflakes
  
  1-5                 - various procedural generators. (described in html)
  
  1                   - 'flower' generator.
  2                   - 'mosaic' generator.
  3                   - 'lineart' generator.
  4                   - 'outside-in (sushi-roll) lineart' generator
  5                   - 'random barycentric triple' generator
  
  R                   - reset generator
  
  A                   - 'auto' camera; smooth rotation around snowflake
  
  []  square brackets - adjust polarization
  <>  angle brackets  - adjust spectrum bias for polarization
  -=  minus/equals    - adjust thickness of interface/refraction factor

mouse:
  LEFT MOUSE DRAG   - rotate the camera
  RIGHT MOUSE DRAG  - rotate the snowflake
  MOUSE WHEEL       - zoom in/out on snowflake

Features


Implementation

Original Storyboard and Concept

Frames:

  1. (not implemented) The scene starts out with a lone lamp at a country path with snow drifts (the scene is surrounded with an environment map like the one above).
  2. Overlayed on this is a 3D partical system of snow falling at normal speed (sprites or fuzzy points) and (not implemented) title graphics
  3. (partially implemented) pressing a key focuses on a single point and time slows to microseconds so you can see the flake form from the point... the background is a diffuse gradient blend in order to see the polarization effects.
  4. (implemented as 3 random params, but no controls) also available are temperature and humidity controls. varying these has an effect on what kind of flakes form, or the formation of existing flakes.
  5. (different controls) arrow keys flip to another (new) flake, leaving the old one.
  6. (not implemnted) user can also zoom out and see the flake fall to the ground, then hold on a long shot until the next flake zoom.

Image References:

OBJ file (courtesy of my sister Andrea who is an animator)


Code

About the FBO textures

All snowflake generators are shapes rendered into an offscreen frame buffer object in GL_BLEND mode, and as such they accumulate any primatives rendered to the surface. Because the accumulated buffer is interpreted as a heightfield, these shapes also have depth.

The generators have a prebuilt limit on the number of frames they are allowed to "grow". This is normalized in frame time to a range from 0 - 1.0 which then is used to define the radius of growth at a given frame time. This radius may then be multiplied times any of the random parameters, modulated, or otherwise transformed. In addition, a random number for the symmetry is chosen and any frame draw operations are rotated and repeated along these lines to produce a symmetrical effect.

I attempted another kind of generator using a Laplacian convolution filter (edge detection filter) under the idea that recursive applications of this filter would "grow" the edge of the snowflake. Indeed, I found out later that Laplacians are involved in actual diffusion physics, so this might have been a good approximation. I was planning to use this in combination with a hexagonal bias (like a lens flare) to encourage growth along symmetry lines. Although there are many examples of GLSL convolution filters, I couldn't get the shader to work in my specific context in time. Something for the future.

About the GLSL snowflake shader

The snowflake GLSL shader does a combination of interesting things to achieve its effect.

About the background snow flurry particle system

Snow particles use GL_POINTS along with the linear + exponential ATTENUATION parameter to generate larger points closer to the camera and smaller dots farther away. The particles have a downward impulse so they fall, and a xz impulse from a Perlin noise texture to simulate drifts and turbulence. I got the Perlin noise idea from Robert Hodgins particle system sample in the Cinder SDK. It's a simple precached way of generating psuedo turblence without CFDs.

About the controls and UI paradigm

The mouse controls for the camera rotation and object rotation are what I call a "ball on paper" model of interaction. Imagine a ball that has a center fixed in space that can rotate but not move. Now imagine that this ball rests on a sheet of paper on a desk. Moving your mouse on the screen (x,y) with a button down is akin to moving the paper. Moving the paper would rotate the ball about it's center.

This has a couple advantages over other approaches, such as "trackball" quaternion controls or raw euler angles:

Media

The "real-life" snowflakes were produced via the following process using GIMP:

  1. stock image selected from Libbrecht's collection
  2. resize to 512x512
  3. created a mask layer
  4. desaturate: lightness
  5. color: invert
  6. levels: gamma = 0.35
  7. brightness: +40
  8. selective gaussian blur: 5.0 radius, 5 max delta.

Experience

Your level of experience or knowledge of the application area and the type of development / languages / toolkits you think will be required. Add a description of the responsibilities of each team member (or add their name to each feature bullet).

Experience:
veteran multimedia systems and application programmer. (C++/Win32)
Target platform:
Windows 7 VS2010 C++ 32/64 bit
Libraries:

References


Kim, Theodore, Micheal Henson, and Ming C. Lin. "A Hybrid Algorithm for Modeling Ice Formation." . 28 Nov. 2010. <http://gamma.cs.unc.edu/HYBICE/>.

Libbrecht, Kenneth. SnowCrystals.com. 28 Oct. 2010. <http://www.its.caltech.edu/~atomic/snowcrystals/>.

---. "The physics of snow crystals." Reports on Progress in Physics. 68 (2005) 855-895. <http://www.its.caltech.edu/~atomic/publist/rpp5_4_R03.pdf>.

Wikipedia contributors, 'Procedural modeling', Wikipedia, The Free Encyclopedia, 4 August 2010, 01:29 UTC, <http://en.wikipedia.org/w/index.php?title=Procedural_modeling&oldid=377040651> [accessed 28 October 2010]

---, 'Thin-film interference', Wikipedia, The Free Encyclopedia, 29 September 2010, 02:33 UTC, <http://en.wikipedia.org/w/index.php?title=Thin-film_interference&oldid=387652589> [accessed 28 October 2010]