Based on Jos Stam's paper, Real-Time Fluid Dynamics for Games.
For a quick video showcase, please see https://vimeo.com/1102785370?fl=pl&fe=vl
- Quad Rendering:
- Full-screen quad rendering from a texture.
- ImGui Integration:
- Fully integrated ImGui interface.
- Fluid Simulator Header:
- Header file for the fluid simulator based on the reference paper.
- Density and Velocity Step
- Two-step fluid simulation.
- Texture Conversion
- Velocity and Density fields are converted into renderable textures.
- The density field is rendered, and users can display the velocity field texture by holding the C key.
- Density Injection
- Users can add density in real time by holding the left mouse button.
- Velocity Injection
- Users can add velocity by dragging their mouse in the desired direction while holding the right mouse button.
- The distance dragged increases the injected velocity's magnitude.
- Velocity Vector Field
- The velocity vector field can be visualized by holding the V key.
- The magnitude of the arrows shows the magnitude of the velocity at that grid point.
- Arrows are instance rendered and placed, oriented, and scaled in a vertex shader (velField.vert.glsl).
- Boundaries
- Users can add boundaries to the fluid simulation grid by pressing the left mouse button and the left shift at the same time.
- Boundaries can be removed by pressing the right mouse button and left shift at the same time.
- Boundaries can be colored through an ImGUI color picker, leading for some artistic possibilities in the scenes.
- Custom Scenes
- We have created three custom scenes (and an empty one) to showcase different fluid situations.
- Further scenes can be easily created similarly, and we encourage users to do so.
- For inspiration, look at crosswindscene.cpp, whirlwindscene.cpp, and waterfountainscene.cpp.
- OpenGL Integration:
- Import
<glad/glad.h>and<GLFW/glfw3.h>for OpenGL functionality.
- Import
- GLM Integration:
- Import
"glm_includes.h". This header conveniently includes multiple GLM headers.
- Import
- Project Structure:
- Header files are located in
$(ProjectDir)\includes. - Source files are located in
$(ProjectDir)\src.
- Header files are located in
- Adding New Files:
- Right-click the project in the Solution Explorer.
- Select "Add Item."
- Ensure the files are added to the correct directories (
includesfor headers andsrcfor source files).
- 3D.
- Memory Management:
std::vector<float>is used instead of raw pointers (float*) to avoid manual memory management.
- Main Loop Integration:
- Call
FluidSimulator::Tick()from the main update loop.
- Call
- Time Management:
FluidSimulatorcan internally use a clock to determine the time delta (dt) betweenTick()calls.
- Sorry I didn't get as far as I hoped, but good luck and thanks y'all!