Lightning Simulator

Cory Mayer | CPE 471 Final Project | Zoe Wood

Demo

Description

My final project was to create a 3D animated lightning storm. The lightning bolts are procedurally generated, and have a bloom effect applied to make them look more realistic. Lightning strikes randomly and forms different patterns using a recursive alorithm. When the lightning strikes it illuminates the scene around it using the Phong lighting model.

Goals

Technologies

Bloom Effect

The bloom effect is created by using multiple render targets to render the entire scene to two framebuffers in one pass, with one buffer containing the unmodified output and the other containing only colors above a brightness threshhold. The "bright color" framebuffer is then passed through a multi-pass gaussian blur filter implemented with shaders, and the resulting blurred "bright color" buffer is recombined with the original buffer using additive blending. For smooth real-time rendering I set the gaussian blur to 3 passes, but the bloom effect was not very noticable with a small amount of blur. The images below show the scene rendering with a 30-pass gaussian blur (low framerate).

Bright Color Buffer Resulting Scene Blurred bright buffer                                                    Resulting scene Bloom Close-up
Bloom close-up

Recursive Algorithm

I designed a rescursive algorithm to generate the lightning structure that calculates new points based on the dot product between the new vector and the down vector. Once a valid point is found the algorithm recurses on the end of the new vector and the midpoint. There are various parameters available including the levels of recursion and decay factor for the bolt length.

Phong Lighting

The Phong lightning model is used to calculate the light on the objs as well as the ground plane. There is support for multiple light sources- a dim directional light illuminates the scene as well as a point light generated for each lighning strike. Alpha blending is used to fade out the lightning bolts after they strike.

References