For this project, a partner and I created a thunderstorm simulation featuring particle systems, RRT’s, and Boids. This was completed in C# using Unity. I was responsible for the rain, lighting, and clouds, however I am familiar with how Boids works. Here are a couple video examples and then some information on features, benchmarks, difficulties, and a way to see our source code!
1) Simulation with no user interaction
- Lightning bolts appear randomly every 0 to 10 seconds.
- Each lightning bolt has a random source and goal node that our RRT uses to construct a biased, downwards tree towards the goal.
- For each node and its children in the RRT, a segment of lightning is created in-between them and then scaled, rotated, and billboarded to connect the two nodes.
- A lightning bolt will continue to be calculated until it either is 600 nodes big or has reached the goal
- Watch as the Boids herd runs in fear of the lightning.
2) Simulation with user interaction
- Instead of random lightning, a lightning bolt is calculated on the click of the users mouse.
- The lightning uses the users mouse coordinates, transformed into world space, as the goal node and uses a start node in the clouds which is close to directly above the goal node
Features:
- 3D, real-time rendering
- Boids flocking simulation
- Handmade raindrop particle system
- Clouds particle system, using Unity’s built in functionality
- Lightning bolts calculated using an Rapidly-exploring random tree (RRT)
- User interaction
Benchmarks:
- 600 node lightning bolts calculated at runtime
- 1500 raindrops
- 60 FPS
Roadblocks during creation:
- While working with the raindrops and lightning, we were trying to do billboarding. It took a lot of pen-to-paper and left-hand-rule turning around to try and figure out just what math we needed. Eventually, once we finally figured it out, we deleted 20 lines of code and replaced them with one. We did learn a lot about rotations in Unity, so it worked out alright.
- When instantiating prefabs and working with positions in world space, local space, and even parent space, we often got confused and our models were not where they should have been.
Source code:
- This project was created using Unity3D.
- Source C# code can be found here