feat: add water surface rendering with mesh generation and shaders#95
Merged
ViTeXFTW merged 2 commits intofeat/terrain-renderingfrom Feb 23, 2026
Merged
Conversation
…peline, renderable) Adds the full water surface rendering pipeline for map-based PolygonTrigger water areas: - src/render/water/water_mesh.hpp/.cpp: Polygon-to-GPU-mesh conversion using ear-clipping triangulation. Converts PolygonTrigger points (map cell coords) to world-space flat water surfaces. Generates UV coordinates for texture scrolling. - src/render/water/water_renderable.hpp/.cpp: IRenderable implementation for water surfaces. Manages GPU buffers for all water polygons from a map file. Supports INI-driven water appearance (WaterSettings), per-frame time-based UV animation, and alpha-transparent rendering after terrain. - shaders/water.vert/.frag: Two-layer scrolling UV water shader. Vertex shader outputs two UV sets at different scroll rates/directions for a cross-ripple effect. Fragment shader blends both samples and applies configurable opacity. - src/lib/gfx/pipeline.hpp: Added WaterPushConstant (waterColor, time, uScrollRate, vScrollRate, uvScale) and PipelineCreateInfo::water() factory (alpha blend on, depth write off, two-sided, WaterVertex format). - tests/water/test_water_mesh.cpp: 31 unit tests covering coordinate conversion, ear-clip triangulation (convex/concave, CW/CCW), polygon generation, bounding box correctness, and terrain-scale consistency. https://claude.ai/code/session_015VJkdyPaCy7vByfWHZ17Zz
Owner
Author
Greptile SummaryThis PR implements complete water surface rendering for the Vulkan W3D viewer, converting map polygon triggers into triangulated meshes with animated dual-layer UV scrolling shaders. Key accomplishments:
The implementation is production-ready with excellent code quality, following all project style guidelines from Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 806161d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds complete water surface rendering support to the engine, including mesh generation from map polygon triggers, GPU buffer management, and animated water shaders with scrolling UV effects.
Key Changes
Water Mesh Generation (
src/render/water/water_mesh.hpp/cpp)triggerPointToWorld()converts map trigger coordinates to world space with proper scaling (MAP_XY_FACTOR for XZ, MAP_HEIGHT_SCALE for height)earClipTriangulate()implements polygon triangulation supporting both convex and concave polygons, with automatic CCW winding correctiongenerateWaterPolygon()converts PolygonTrigger data into flat water meshes with averaged height, computed bounds, and normalized texture coordinatesgenerateWaterMeshes()processes all water triggers from a map and computes total boundsWater Renderable (
src/render/water/water_renderable.hpp/cpp)IRenderableinterface for integration with the rendering systemShaders
Pipeline Configuration (
src/lib/gfx/pipeline.hpp)WaterPushConstantstruct for time, scroll rates, color, and UV scalePipelineCreateInfo::water()factory with proper vertex layout (position + texCoord), descriptor bindings, and alpha blending configurationTesting (
tests/water/test_water_mesh.cpp)Notable Implementation Details
https://claude.ai/code/session_015VJkdyPaCy7vByfWHZ17Zz