The source code of the 21st tutorial of the C++ 3D Game Tutorial Series is now available in early access on GitHub!
This tutorial establishes the core infrastructure for GPU-driven water rendering by introducing a texture-based vertex displacement pipeline:
Dedicated wave uniform buffer: Introduced WaterData, containing wave resolution (wavesDisplacementTexSize), animation speed (wavesSpeed), and area dimensions. This gives the shader precise control over how wave geometry scales and moves across the surface.
Texture-driven displacement input: Added explicit binding for wavesDisplacementTexture in the water draw loop, establishing the pipeline for reading wave height/phase data directly from GPU textures during the vertex shader stage.
Time-based animation support: Added a global time variable to EnvironmentData and m_time in WorldRenderer. This uniform will be used to animate displacement textures (waves, erosion, etc.) over time in the shader.
Alpha blending for transparent surfaces: Configured a standard transparency blend state (SrcBlend = SRC_ALPHA, DestBlend = INV_SRC_ALPHA) within the graphics pipeline state, enabling proper depth sorting and preventing visual artifacts when rendering overlapping or semi-transparent water planes.
Renderer loop expansion for water components: Extended WorldRenderer::render() to query WaterComponent instances, bind their mesh buffers, update the waterCb constant buffer, set wave textures, and execute indexed draw calls, creating a streamlined draw path for animated water meshes.
You can find the full source code on GitHub here: GitHub Link
I hope you enjoy the tutorial, and thank you for all your support!