top of page
rc.jpg

RedCraft

Development Period: September 2025 - December 2025

RedCraft is a MineCraft-style voxel game, featuring procedural terrain generation, real-time lighting, physics simulation, and multiple gameplay systems. The project demonstrates expertise in graphics programming, multithreaded architecture, and multiple game systems design.

Demo

Main Features

Key Features:
Procedural World Generation | Redstone Circuit Simulation | Chunk Streaming & Persistence | Transparency Sorting | Crop & Farming System | Dynamic Weather | Player Physics

 

Basic Controls

  • Left Click: Mine/destroy blocks

  • Right Click: Place blocks

  • 1-9 Number Keys: Select block type from hotbar HUD

  • X: Cycle to next hotbar group (swap available block palette)

Procedural World Generation

DensityNoise enabled only.jpg
Stage1: Density Noise Enabled

*Sea Enabled

TYPOGRAPHY

Redcraft implements a procedural world generation pipeline with multi-stage terrain shaping, biome selection, cave carving, and feature placement.

​

In-Game Pipeline Stages: BiomesNoise Caves Water Surface Features
 

  • BiomeGenerator: 6-parameter biome selection using 2D Perlin noise layers (Temperature, Humidity, Continentalness, Erosion, Weirdness, Peaks & Valleys). Lookup tables map parameter combinations to 17 biome types including Ocean, Desert, Forest, Jungle, Snowy Peaks, etc.
     

  • TerrainGenerator: 3D density-based terrain using formula D(x,y,z) = N(x,y,z) + B(z) where B(z) is height bias. Continentalness drives height offset curves and squashing curves (PiecewiseCurve1D) to create oceans, coastlines, and inland mountains.
     

  • CaveGenerator: Three cave types using 3D noise:

    • Cheese Caves: Large spherical rooms using dual-layer 3D Perlin noise (scales 0.014 and 0.01). Two noise values blended (70%/30%) and offset; density > 0.65 carves void. Vertical stretch (0.008 z-scale) creates tall chambers.

    • Spaghetti Caves: Tunnel networks formed by intersecting two perpendicular 2D noise planes (XY-plane + XZ-plane, scale 0.025, 3 octaves). Tunnel forms where |noise1| + |noise2| < 0.18 — this mathematical trick produces naturally curving 3D passages without explicit path generation.

    • Noodle Caves: Thin winding tunnels using ridge noise (scale 0.035, 2 octaves) for chaotic shapes. Threshold < 0.08, restricted to z < 50 for deep-only generation.

    • Depth-Based Aquifer System: Layered cave filling based on elevation — lava layer (z < 15) fills all caves; deep aquifer (z 15-30) uses noise to create water-filled caves with air pockets in large chambers; mid-level caves (z 30-50) have occasional water pools; ocean biome caves below sea level fill with water but preserve air pockets via drainage noise.

    • Liquid Post-Processing: Simulates basic fluid physics — liquids fall through air blocks below; lava adjacent to water converts to stone (obsite generation). Single-pass top-down iteration ensures consistent flow behavior.

    • Surface Protection: CalculateDistanceToSurface() prevents cave openings within 8 blocks of terrain surface, avoiding unnatural exposed caverns. Depth factor reduces cave frequency near surface (100% at z=60, 10% at z=80).

Cave.jpg

Caves

SnowTaiga.jpg

SnowTaiga

​
 

  • SurfaceBuilder: Biome-specific block replacement with configurable top/filler/under layers. Desert→Sand, Snowy→Snow, Forest→Grass+Dirt. Temperature overrides freeze water surfaces to ice.
     

  • FeaturePlacer: Tree stamps selected by biome (Oak, Spruce, Jungle, Cactus), underwater plants in ocean biomes, and depth-based ore distribution (Diamond<16, Gold<32, Iron<64, Coal everywhere).
     

  • WorldGenPipeline Orchestration: Central GenerateChunk() method coordinates all stages sequentially, passing ChunkGenData (biome maps, surface heights, biome parameters) between stages. Each stage can be independently toggled via runtime flags (g_caveCarvingEnabled, g_seaEnabled, g_blockReplacementEnabled, g_treeGenerationEnabled), enabling isolated debugging. Supports alternate generation modes including FLAT_FARM for gameplay testing.

  • ImGui Debug Tools: Integrated ImGui and ImPlot panels for real-time parameter tuning without recompilation. Interactive curve editor for height offset and squashing curves, noise layer visualizers displaying Continentalness/Erosion/Temperature/Humidity/PV as grayscale maps, and sliders for all noise parameters (scale, octaves, persistence). Changes trigger immediate world regeneration for rapid iteration.

Redstone Circuit Simulation

RedCraft implements a tick-based redstone logic simulation supporting signal propagation, mechanical components, and Minecraft-accurate timing behaviors.

​

Core Architecture:

  • Tick System: Discrete simulation at 10 ticks/second (100ms intervals). m_currentTick counter drives all delayed operations. Update queue processes scheduled events in FIFO order.

  • Power Model: 4-bit power levels (0-15) with distance-based attenuation. Distinguishes between weak power (through blocks) and strong power (direct connection). IsPowered(), IsStronglyPowered(), and IsPistonPowered() provide context-specific queries.

  • Scheduled Updates: RedstoneUpdate struct pairs BlockIterator with scheduledTick for delayed processing. m_queuedPositions hashset prevents duplicate scheduling.
     

Redstone Wire:

  • 3D Connection Detection: WireConnection enum tracks NONE/SIDE/UP/DOWN per direction. Wires climb solid blocks and descend off edges, enabling vertical signal routing.

  • Power Propagation: Wire power = max(direct input, adjacent wire - 1, climbing wire - 1). GetDirectPowerInput() checks torches, repeaters, levers; GetAdjacentWirePower() and GetClimbingWirePower() handle wire-to-wire transmission.

  • Visual State: WireConnections::GetTextureIndex() encodes 4-direction connectivity into 0-15 texture atlas index for correct corner/straight/cross rendering.
     

Signal Sources:

  • Lever: Toggle on player interaction via ToggleLever(). Outputs power level 15 in attached direction when ON.

  • Button: Momentary pulse via PressButton(). Stone button = 10 ticks (1s), wood button = 15 ticks (1.5s). Auto-schedules deactivation.

  • Redstone Block: Constant power level 15 to all adjacent blocks. Cannot be turned off.
     

Signal Processors:

  • Redstone Torch: Inverts input signal. OFF when attached block is powered, ON otherwise. Burnout protection: Tracks toggle count per position; >8 toggles within 1 second window triggers temporary disable. TorchBurnoutEntry tracks timestamps and counts; CleanupBurnoutTracker() expires old entries.

  • Repeater: Configurable 1-4 tick delay (100-400ms) via CycleRepeaterDelay(). CheckRepeaterLock() detects side-locking by adjacent powered repeaters. Outputs full power (15) regardless of input strength, enabling signal refresh.

  • Observer: Detects block state changes in facing direction. NotifyObserversOfChange() triggers 2-tick pulse output via ObserverUpdate queue. Enables BUD (Block Update Detector) circuits.
     

Mechanical Components:

  • Piston Push Chain: CalculatePushList() recursively builds push/destroy lists up to 12 blocks. CanBePushed() / CanBePulled() check block types (obsidian=immovable, torch=destroyed). Sticky pistons pull single block on retract.

  • Piston Timing: Extension/retraction scheduled via tick system. GetPistonFacing() extracts direction from block metadata; SetPistonExtended() updates visual state.

  • Redstone Lamp: UpdateLamp() toggles lit/unlit state based on IsPowered(). UpdateLampLighting() triggers chunk light recalculation for proper illumination.
     

Update Propagation:

  • Neighbor Scheduling: ScheduleNeighborUpdates() queues all 6 adjacent blocks when a redstone component changes state.

  • Event Hooks: OnBlockPlaced(), OnBlockRemoved(), OnBlockStateChanged() integrate with World block modification, triggering appropriate redstone recalculations.

  • Chunk Dirtying: MarkChunkDirty() flags affected chunks for mesh rebuild when wire connections or lamp states change.

Lighting System

Lighting implementation uses a dual-channel voxel lighting with flood-fill propagation across chunk boundaries.

​

  • Sky Light Channel: Propagates downward from sky-exposed blocks (max value 15), attenuates by 1 through transparent blocks (water, glass, leaves). Direct sky columns maintain full brightness; covered areas receive reduced ambient light.
     

  • Block Light Channel: Emitted by light-emitting blocks (torch=14, lava=15, glowstone=15), spreads omnidirectionally with -1 falloff per block distance. Multiple light sources blend via max operation.
     

  • Flood-Fill Propagation: BFS-based algorithm propagates light changes across chunk boundaries using neighbor links. When a block changes, affected light values re-propagate until attenuation reaches zero. Supports both light addition (placing torch) and removal (breaking light source).
     

  • Per-Block Storage: Light values packed into single byte per block (4 bits sky + 4 bits block). Mesh vertices sample light from adjacent air blocks and bake into vertex colors for smooth gradients across faces.
     

  • Dirty Propagation: Light changes mark affected chunks dirty; recalculation completes before mesh rebuild to ensure visual consistency.

Flickering.gif
lightPropogation.png
LightPropogation1.gif
LightPropogation1.jpg

Chunk Management System Design

Efficient voxel world streaming with state machine-based lifecycle management and async I/O.

​

Chunk State Machine: Uninitialized Generating/LoadingActiveSavingDeactivated

​

  • Job System Integration: Chunk operations execute on dedicated thread pools. GenerateChunkJob (CPU-bound worker threads) handles procedural generation; LoadChunkJob and SaveChunkJob (I/O threads) handle disk operations. Load jobs automatically fall back to generation if no save file exists.
     

  • Block Data Structure: Compact 4-byte block representation optimizing memory usage for large voxel worlds.

    • Type Index (1 byte): Block type ID (0-255), indexes into BlockDefinition table for properties lookup.

    • Light Data (1 byte): Dual-channel lighting packed as high 4 bits = sky light (0-15), low 4 bits = block light (0-15).

    • Flags (1 byte): Bit-packed boolean states including IS_SKY, IS_LIGHT_DIRTY, IS_OPAQUE, IS_SOLID, IS_VISIBLE, IS_REDSTONE_DIRTY.

    • Redstone Data (1 byte): Multi-purpose field — low 4 bits = power level (0-15), bits 4-6 = block facing direction (0-5 for ±X/Y/Z), bit 7 = special state (lever on/off, piston extended, repeater locked).
       

  • Data-Driven Block Definitions: All block properties (opacity, transparency, light emission, texture coordinates, solidity, sound effects) defined in XML. Adding new block types requires zero code changes—only XML edits and texture atlas updates.
     

  • ChunkSerializer with RLE Compression: Binary format with ChunkFileHeader containing FourCC validation and chunk dimension bits. Block data (type + lighting + flags per block) compressed using Run-Length Encoding, achieving 60-80% size reduction. Format: [Header][CompressedSize:uint32][RLE Data].
     

  • Neighbor Linking: Each chunk maintains pointers to 6 adjacent chunks (±X, ±Y, ±Z) for cross-boundary operations including lighting propagation and mesh stitching at chunk borders.
     

  • Hidden Surface Culling: During mesh building, only block faces adjacent to air or transparent blocks generate vertices. Interior faces between solid blocks are culled at build time, reducing vertex count by ~85% compared to naive full-cube rendering.
     

  • Dirty Flag System: Block modifications mark chunks dirty, triggering light recalculation and mesh rebuild on next frame. Batches multiple edits before rebuilding to avoid redundant work.

ChunkJob.jpg
BlockDef.jpg
BlockSave.png
HiddenFaceCulling.png

Crop & Farming Mode System

RedCraft builds a data-driven basic crop system with configurable growth patterns, condition-based mechanics, and world-separated persistence.

Growth Patterns: Stage change (Wheat 8-stage progression), Grow-up (Sapling→Tree stamp), Spread (Grass/Mushroom propagation), Multi-block vertical growth (Sugarcane/Cactus with max height), Tree generation via FeaturePlacer
 

Condition System: Light level thresholds (min/max), block adjacency requirements, water proximity check (Manhattan distance), sky access validation, base block type verification
 

​Farmland Mechanics: Hydration state (dry/wet) based on water radius=4, moisture affects growth speed multiplier, trampling converts to dirt, unplanted decay timeout

​

Fluent Definition API: CropDefinition builder pattern configuring growth type, stages, light requirements, base blocks, growth chance per random tick, and drop tables

​

Drop Manager: Configurable min/max quantities with weighted randomization, item entity spawning with velocity scatter

​

Random Tick System: Per-chunk distributed ticks, growth chance evaluated per crop type, tick rate scales with game speed
 

World Save Isolation: Leverages SaveSystem's context stack (PushSaveContext/PopSaveContext) to separate Saves/InfiniteWorld/Chunks/ from Saves/FarmWorld/Chunks/. World type detected via WorldGenPipeline::GetWorldGenMode(); farm world enforces fixed 12×12 chunk boundary preventing unbounded save file growth.

CropGrow.gif
ModeSelection.jpg
Folders.png

Dynamic Weather System & Atmosphere

Redcraft creates dynamic weather simulation with day-night cycle, transparent rendering pipeline, and environmental effects.​

​Transparent Rendering Pipeline:

  • Dual VBO/IBO Architecture: Per-chunk geometry split into opaque buffer and transparent buffer (water, glass, ice, leaves).

  • Two-Pass Rendering: Pass 1 renders opaque geometry with depth write ON; Pass 2 renders sorted transparent geometry with depth write OFF, depth test ON (reads but doesn't write, preventing transparent-on-transparent artifacts).

  • Camera-Distance Sorting: ChunkSortTransparencyJob runs on worker threads, sorting transparent faces back-to-front by centroid distance to camera. Re-sorts when camera moves beyond threshold.

  • Alpha Blending: Fragment shader applies SRC_ALPHA, ONE_MINUS_SRC_ALPHA blending with underwater tint and fog based on camera medium state.
     

Day-Night Cycle:

  • World Time: Continuous time value drives sun/moon position, sky color, and ambient light intensity. Configurable day length (default 20 minutes real-time = 24 hours in-game).

  • Sun/Moon Rendering: Sun and moon orbit opposite each other; position calculated from world time. Sunrise/sunset trigger smooth sky color transitions (orange→blue→dark blue→black).

  • Dynamic Lighting: Outdoor sky light intensity scales with sun elevation (full brightness at noon, reduced at dawn/dusk, minimal at night). Indoor block-lit areas unaffected.
     

Weather System:

  • Weather States: 12 states (Clear, Cloudy, Light Rain, Heavy Rain, Thunderstorm, Snow, Blizzard, etc.) with smooth interpolated transitions. Duration randomized within configurable ranges.

  • Particle Effects: Rain uses stretched billboards with downward velocity + wind offset; snow uses slower drifting particles with rotation. Particle density and wind strength scale with weather intensity.

  • Lightning: Randomized timing during thunderstorms, triggers screen flash and temporary outdoor light boost.

  • Cloud System: Voxel-style cloud layer with horizontal drift, casts dynamic shadows on terrain below.
     

Fog & Sky Rendering:

  • Distance Fog: Exponential fog blended in fragment shader; base density scales with weather (clear=light, rain/snow=dense) and time of day (thicker fog at dawn). Fog color matches current sky gradient.

  • Sky Gradient: Procedural color blend from horizon to zenith, driven by sun position and weather. Overcast weather desaturates and darkens sky; night transitions to star field.

  • Medium Detection: Camera tracks current medium (air/water/lava). Underwater applies blue tint + increased fog + screen distortion; lava applies red-orange overlay + extreme fog + heat shimmer.

TransLeaves.jpg
DayCycle.gif
DiffWeather.gif
Underwater.jpg

Fog Underwater

Basic Physics System

RedCraft implements entity-component style physics with multiple movement modes.

  • Movement modes: Walking, Flying, NoClip with per-mode acceleration curves (Press V to change)

  • AABB collision detection with step-up support

  • Camera modes: First-person, Over-shoulder, Fixed-angle, Spectator (Press C to change)

  • Inventory system with hotbar and item management

Physics.gif

Other Solo (Individual) Projects

Lumina Global Illumination

ChessSoul

bottom of page