https://github.com/wendtpiotr/procedural-lorenz-attractor
An interactive Lorenz attractor simulator in Unity, designed to explore chaos, the butterfly effect, and velocity dynamics in a visually intuitive way.
https://github.com/wendtpiotr/procedural-lorenz-attractor
chaos-theory lorenz-attractor physics-simulation rk4-algorithm unity3d
Last synced: 12 days ago
JSON representation
An interactive Lorenz attractor simulator in Unity, designed to explore chaos, the butterfly effect, and velocity dynamics in a visually intuitive way.
- Host: GitHub
- URL: https://github.com/wendtpiotr/procedural-lorenz-attractor
- Owner: wendtpiotr
- License: mit
- Created: 2025-10-28T18:11:21.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-10-28T18:30:10.000Z (7 months ago)
- Last Synced: 2025-12-14T09:30:02.740Z (6 months ago)
- Topics: chaos-theory, lorenz-attractor, physics-simulation, rk4-algorithm, unity3d
- Language: C#
- Homepage:
- Size: 83 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ Lorenz Attractor Visualizer

An interactive **Lorenz attractor simulator** in Unity ๐ฎ, designed to explore chaos, the butterfly effect, and velocity dynamics in a visually intuitive way.
https://github.com/user-attachments/assets/76d7efe5-4e04-4267-96d2-44bbb219e8cf
https://github.com/user-attachments/assets/95d4b545-8f63-478f-89a7-17e371ebb23c
---
## ๐ฌ Features
- **Numerical Integration:** Uses **RK4** (Runge-Kutta 4th order) for accurate time evolution of the Lorenz system.
- **Dynamic Mesh Rendering:** The attractor trail is drawn with a **Mesh** rather than a LineRenderer for performance (even with 25k+ points).
- **Per-Point Velocity Coloring:**
Visualize instantaneous **velocity magnitude** along the trail using a customizable **Gradient** ๐จ.
- **Butterfly Effect Mode ๐ฆ:**
Slight rounding of initial conditions demonstrates **sensitive dependence on initial conditions** โ chaos in action!
- **Compare Two Attractors:**
Spawn multiple attractors (normal vs. butterfly-effect) to observe **divergence over time**.
- **Orbit Camera:**
Smooth, mouse-controlled orbit camera that automatically centers on the active attractor points.
---
## โ๏ธ Usage
1. **Setup Attractor:**
- Create a **ScriptableObject** (`LorenzAttractorSettings`) for each attractor.
- Configure:
- `timeStep`
- `initialPosition`
- `maxPoints`
- `velocityGradient`
- `enableButterflyEffect` โ
to apply rounding to initial conditions.
2. **Add Attractor to Scene:**
- Attach `LorenzAttractor.cs` to a GameObject.
- Assign the corresponding `LorenzAttractorSettings`.
3. **Camera Setup:**
- Attach `OrbitCamera.cs` to your main camera.
- Set `target` to one of the Lorenz attractor GameObjects.
- Enable `Use Dynamic Center` to follow the attractor trail.
4. **Visual Exploration:**
- Drag the mouse to rotate the camera.
- Scroll to zoom in/out.
- Watch attractors diverge in real time, colored by velocity magnitude.
---
## ๐ Scientific Notes
- The Lorenz system is defined by:
\[
\begin{cases}
\frac{dx}{dt} = \sigma (y - x) \\
\frac{dy}{dt} = x (\rho - z) - y \\
\frac{dz}{dt} = xy - \beta z
\end{cases}
\]
with typical parameters:
`ฯ = 10`, `ฯ = 28`, `ฮฒ = 8/3`.
- **Butterfly Effect:** Small differences in initial conditions (here via rounding) grow exponentially, illustrating chaotic dynamics.
- **Velocity Visualization:**
Each vertex is colored according to the **magnitude of its instantaneous derivative**, showing where the system moves faster or slower in 3D space.
---
## ๐งฉ Scripts
- `LorenzAttractor.cs` โ Generates and updates the attractor mesh in real-time.
- `LorenzAttractorEquationsSolver.cs` โ Implements RK4 integration and derivative calculation.
- `LorenzAttractorSettings.cs` โ ScriptableObject storing parameters, including butterfly effect option.
- `OrbitCamera.cs` โ Smooth orbit camera centered on the attractorโs active points.
---
## ๐ Demo Ideas
- Spawn two attractors:
- One normal
- One with butterfly effect enabled
- Observe divergence over time ๐ฆ.
- Experiment with gradient coloring to highlight **high-velocity regions**.
- Increase `maxPoints` for high-resolution trails.
---
## ๐ป Requirements
- Unity 2023+ (or compatible version)
- Standard 3D pipeline
- Optional: HDRP/URP for improved visuals