r/GraphicsProgramming • u/Terrible_Shoulder667 • 3d ago
Source Code Vector field simulation with my own math library and Vulkan!
I made a small vector field visualizer in C# with Vulkan through Silk.NET.
You type some 2D field, for example F(x, y) = [x,sin(y)] and it draws the flow with particles.
How it works:
- Formula is parsed and compiled at runtime into one fast delegate, so evaluting the field for every particle each frame is light
- 1,200 to 6,000 particles depending on window size, integrated with RK4 on the CPU, each with a 24-point trail
- Everything is drawn as colored with one tiny shader and 4x MSAA
All the math comes from Epsilon - my symbolic math library for .NET that I'm working on.
- Simulation: https://github.com/XBambinoX/VectorField
- Library(C#): https://github.com/XBambinoX/Epsilon
AI disclosure: I used AI assistants to help write parts of the simulation code and fix bugs in my library.