feat: complete phase 3 implementation for terrain atlas and terrain blend#93
Merged
ViTeXFTW merged 2 commits intofeat/terrain-renderingfrom Feb 23, 2026
Merged
Conversation
Implements the remaining Phase 3 sub-steps for terrain rendering: Step 3.2 - Terrain texture atlas: - Add terrain_atlas.hpp/cpp with TileUV, TerrainAtlasData structs - decodeTileIndex/decodeQuadrant for tileNdxes bit encoding (top 14 bits = source tile, bottom 2 bits = 32x32 quadrant within 64x64 tile) - computeQuadrantUV splits a tile's UV into 4 sub-quadrants - computeTileUVTable builds UV table from BlendTileData textureClasses - buildProceduralAtlas for testing without game assets Step 3.3 - Terrain blend system: - Add terrain_blend.hpp/cpp with 12 gradient alpha patterns - BlendDirection enum (6 directions + inverted variants) - blendDirectionFromInfo maps BlendTileInfo fields to direction - cellHasBlend detects cells requiring blend layer rendering Step 3.4/3.5 - Terrain shaders and pipeline update: - terrain.vert: add inAtlasCoord (location 3) passed through to fragment shader - terrain.frag: sample atlas texture using fragAtlasCoord when useTexture==1 - pipeline.hpp: terrain() preset updated to 40-byte stride with 4 vertex attributes (position, normal, texCoord, atlasCoord) Step 3.6 - Cliff texture mapping: - generateChunkFromBlendData uses non-shared vertices (4 per cell) to allow correct per-cell atlas UV assignment - cliffAtlasUV helper resolves CliffInfo per-corner UVs for cliff cells - generateTerrainMeshFromBlendData wraps all chunks Step 3.8 - TerrainRenderable integration: - loadWithBlendData uses atlas-aware mesh generation - initPipelineWithAtlas creates GPU atlas texture via TextureManager - hasAtlas() / atlasTextureIndex_ member replacing placeholder type - setLighting respects useTexture based on atlas presence Tests: - tests/terrain/test_terrain_atlas.cpp: atlas UV decode, quadrant, UV table, buildProceduralAtlas (28 test cases) - tests/terrain/test_terrain_blend.cpp: pattern generation, blend direction mapping, cellHasBlend (22 test cases) - tests/gfx/test_pipeline_create_info.cpp: updated for 40-byte stride - tests/map/test_lighting_parser.cpp: fix missing #include <cstring> All 19 test suites pass (100%). https://claude.ai/code/session_01ADLdYWAcHMTCEJ3z9nDGjv
Owner
Author
This comment was marked as outdated.
This comment was marked as outdated.
Owner
Author
Greptile SummaryThis PR implements comprehensive terrain atlasing and blend pattern generation support for the C&C Generals Zero Hour map renderer, enabling proper texture atlas creation and UV coordinate handling for terrain tiles and cliff faces. Key Accomplishments
Code QualityThe implementation follows the project's coding standards with proper RAII patterns, const correctness, and TDD approach. The bit-packing logic correctly extracts tile indices (bits 2-15) and quadrants (bits 0-1) as specified in the format documentation. UV coordinate calculations properly normalize to [0, 1] range for atlas sampling. Confidence Score: 5/5
Important Files Changed
Last reviewed commit: ba2c57e |
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 comprehensive support for terrain atlasing and blend pattern generation, enabling procedural texture atlas creation and proper UV coordinate handling for terrain tiles and cliff faces.
Key Changes
New Terrain Atlas System (
terrain_atlas.hpp/cpp)New Blend Pattern System (
terrain_blend.hpp/cpp)Terrain Mesh Enhancements
atlasCoordfield toTerrainVertexfor proper texture mappinggenerateChunkFromBlendData()function to generate terrain chunks with blend tile and cliff datagenerateTerrainMeshFromBlendData()to create complete terrain meshes with blend supportTerrain Renderable Updates
loadWithBlendData()method to load terrain with blend tile informationinitPipelineWithAtlas()to set up rendering with texture atlasesShader Updates
inAtlasCoordinput andfragAtlasCoordoutput for atlas-based texturingTest Coverage
Implementation Details
https://claude.ai/code/session_01ADLdYWAcHMTCEJ3z9nDGjv