Rendering Pipeline Overview
Core Rendering Classes
GameRenderer
The main renderer that orchestrates the entire rendering pipeline (GameRenderer.h:15):LevelRenderer
Manages world rendering including chunks, entities, and tile entities (LevelRenderer.h:35):LevelRenderer maintains separate state for each split-screen player, allowing up to 4 simultaneous viewports.
Chunk Rendering System
Chunk Structure
The world is divided into 16×16×16 render chunks:Chunk Flags
Global flags track chunk state across all viewports:Chunk Rebuild
Chunks are rebuilt on background threads:Dirty Chunk Management
Platform-Specific Rendering
PlayStation 3 SPU Tasks
PS3 uses Synergistic Processing Units (SPUs) for parallel rendering tasks:LevelRenderer_cull: Frustum cullingLevelRenderer_zSort: Transparent sortingLevelRenderer_FindNearestChunk: Nearest chunk selectionGameRenderer_updateLightTexture: Light map generationChunkUpdate/TileRenderer_SPU: Chunk mesh generation
SPU tasks run on the PS3’s Cell architecture, offloading work from the main PPU thread. Each SPU has 256KB of local memory.
Rendering Layers
Geometry is rendered in multiple passes:Texture Management
TheTextures class (Textures.h:201) manages all texture loading and binding:
Texture Atlas
Blocks and items are stitched into texture atlases:Texture Formats
Platform-specific texture compression:Lighting System
Light Texture
Dynamic lighting uses a generated light texture:The light texture is a 16×16 lookup table indexed by (blockLight, skyLight) to get the final RGB color.
Smooth Lighting
Ambient occlusion for smooth lighting:Entity Rendering
Entities use theEntityRenderer hierarchy:
Sky and Weather Rendering
Sky Dome
Weather Effects
Performance Optimizations
Frustum Culling
Frustum Culling
Only render chunks visible in the camera frustum:
Occlusion Culling
Occlusion Culling
Skip rendering chunks completely hidden by opaque geometry.
Level of Detail
Level of Detail
Reduce geometry complexity for distant chunks on some platforms.
Display Lists / VBOs
Display Lists / VBOs
Pre-compiled chunk geometry for efficient rendering:
Best Practices
Minimize State Changes
Batch rendering by texture and render state to reduce GPU overhead.
Use Chunk Flags
Check CHUNK_FLAG_EMPTY before rendering to skip air chunks.
Limit Chunk Rebuilds
Rebuild max 2 chunks per frame to maintain 60 FPS.
Offload to Threads
Use background threads (or SPUs on PS3) for chunk building.
Related Topics
Overview
High-level architecture and components
Client-Server
Client-server separation and management