Simulating 2D Gravity with Compute Shaders in Godot

Subscribers:
529
Published on ● Video Link: https://www.youtube.com/watch?v=z7sLY9e5cy8



Game:
Gravity (1990)
Duration: 0:00
2,272 views
89


A code walkthrough for a 2D N-Body particle sim experiment, in Godot 4, using GLSL compute shaders.

Learning new stuff is great! Don't hesitate to let me know if you see bugs or have advice on how to improve it.

Open Source available on GitHub: https://github.com/ThePathfindersCodex

00:00 Particle Sim Overview
04:35 GDScript Code
14:34 GLSL Compute Shader Code
23:52 Gaps and Issues
27:47 Bring It All Together

Purpose:
TECH DEMO and CODE WALKTHRU - code overview for the project covered in earlier shader experiments videos
HANDS ON CODE LEARNING - code available on GitHub to try yourself

Stuff covered:
a GLSL compute shader with more than one pass
using typed packed arrays in Godot
using a subviewport for zoom-like effects
pairwise 2D Newtonian gravity and collision detection/resolution in the shader during the sim pass 1
manually rasterizing circles to draw all dots during the draw pass 2
a roll-your-own performance graph in it's own subviewport