The goal of this project is to create dynamic water, ice, lava and fire in OpenGL 4.
# Install irrKlang (needed for audio)
cp lib/irrKlang/libIrrKlang.so /usr/lib/
# Build
mkdir cmake-build && cd cmake-build
cmake ../ -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release -j
# Run
./a-shader-of-ice-and-fire
audio/
: sound fileslib/
: external librariesmodels/
:OBJ
modelsshaders/
:GLSL
source codesrc/
:C++
source code and headers
- GLAD (using OpenGL Loader-Generator): https://glad.dav1d.de
- GLFW3 (OpenGL window manager): https://github.com/glfw/glfw
- GLM (OpenGL mathematics): https://github.com/g-truc/glm
- Assimp (Asset import): https://github.com/assimp/assimp
- STB (Image loading): https://github.com/nothings/stb
- irrKlang (Sound): https://www.ambiera.com/irrklang
- Bloom + HDR
- Lava procedural texture (Perlin customised)
- Particles (compute shader)
- Water reflection + refraction
- Water displacement mapping + tesselation
- Transition FX (Screen-Space animation)
- Snow (Perlin noise on 3 octaves)
- Ice
- Sound FX
We decided to create our own scene on MagicaVoxel to be as free as possible. However, we decided to keep the models simple, so that our work on the lava and ice would be more visible.
- The water computes its refraction and reflection. The distortion effect is made using a displacement map. It also uses the tesselation and geometry shaders to create a tiny wave effect (changin the height locally).
- The lava texture is made using Perlin noise. It also uses the tesselation and geometry shaders.
- We added HDR and bloom effects.
- Some particles are here to simulate lava ember (above the lava) and fireflies (on the water surface and gathered on the lamps). We used the compute shader and geometry shader to optimize it.
You can activate the Ice mode by pressing 'I'. The color of the lights switch to blue and the water freeze progressively. Some snow particles are falling down, and a snowy texture made wit Perlin noise on 3 octaves appears slowly on the volcano.
The transition between those 2 modes is pretty cool. It is progressive, and there is a nice 2D effect (using a FBO which renders the scene on a quad).