Duel Arena Visual Enhancements
This document describes the visual improvements made to the duel arena system.Overview
The duel arena has received significant visual upgrades to create a more immersive medieval combat atmosphere:- Procedural Stone Tile Floors - Randomized sandstone texture for each arena
- Lit Torches with Fire Particles - Corner torches with flickering flames
- GPU-Instanced Particle System - Efficient fire rendering via ParticleManager
Procedural Stone Tile Texture
Commit:f8c585eLocation:
packages/shared/src/systems/client/DuelArenaVisualsSystem.ts
Each duel arena floor now features a unique procedurally-generated sandstone tile pattern for OSRS medieval aesthetic.
Features
- Canvas-Generated Texture - Created at runtime, no texture files needed
- Randomized Per Arena - Each arena gets unique tile variation
- Sandstone Aesthetic - Warm beige/tan colors matching OSRS style
- Grout Lines - Dark lines between tiles for depth
- Color Variation - Subtle per-tile color shifts
- Speckle Noise - Fine grain detail for realism
Implementation
Texture Parameters
- Resolution: 512x512 pixels
- Tile Grid: 8x8 tiles
- Base Color:
#d4c4a8(warm sandstone) - Grout Color:
#8b7355(dark brown) - Grout Width: 2-3 pixels
- Color Variation: ±10% per tile
- Speckle Density: 0.15 (15% of pixels)
Performance
- One texture per arena (not per tile)
- Texture generated once at arena creation
- No runtime texture updates
- Minimal memory footprint (~1MB per arena)
Lit Torches with Fire Particles
Commit:cef09c5Location:
packages/shared/src/entities/managers/particleManager/GlowParticleManager.ts
Torches with flickering fire particles are placed at all 4 corners of each duel arena.
Features
- Corner Placement - One torch at each arena fence corner
- Fire Particles - Rising embers with heat distortion
- Point Lights - Dynamic lighting from torch flames
- Flicker Animation - Realistic flame movement
- Glow Preset - “torch” preset with tight particle spread
Torch Configuration
Particle Behavior
- Rise Spread: 6 particles per torch
- Tight Spread: 0.08 radius (concentrated flame)
- Upward Motion: Particles rise with slight wobble
- Respawn: Particles respawn at base when reaching peak
- Flicker: Random intensity variation for flame effect
Lighting
Each torch includes a PointLight:- Color: Orange (#ff6600)
- Intensity: 2.0 (with flicker variation)
- Distance: 8 units
- Decay: 2.0 (realistic falloff)
- Position: Slightly above torch base
Performance
- GPU Instancing: All torch particles use shared InstancedMesh
- 4 Torches per Arena: Minimal draw call overhead
- Shared Geometry: One particle geometry for all torches
- TSL Materials: GPU-driven animation, no CPU updates
GPU-Instanced Particle System
Commit:4168f2fLocation:
packages/shared/src/entities/managers/particleManager/
The particle system was completely refactored to use GPU instancing for massive performance improvements.
Architecture
Performance Impact
Before Refactor:- ~150 draw calls for fishing spot particles
- ~450 lines of per-entity CPU animation code
- Individual mesh per particle emitter
- CPU-driven particle updates every frame
- 4 draw calls total (4 InstancedMeshes)
- GPU-driven animation via TSL NodeMaterials
- Centralized particle management
- Zero CPU cost for particle animation
Usage Example
TSL NodeMaterials
Particles use Three.js Shading Language (TSL) for GPU-driven animation: Vertex Shader Features:- Billboard orientation (always face camera)
- Polar coordinate motion (angle + radius)
- Parabolic arcs for splash particles
- Sine wave wobble for bubble particles
- Circular wandering for shimmer particles
- Texture-based alpha (glow/ring textures)
- Fade in/out envelopes
- Twinkle effects (shimmer)
- Additive blending for glow
spotPos(vec3) - Emitter world positionageLifetime(vec2) - Current age, total lifetimeangleRadius(vec2) - Polar angle, radial distancedynamics(vec4) - Peak height, size, speed, direction
Glow Presets
Altar Preset:- Geometry-aware spark placement
- Particles rise from altar mesh surface
- Requires
meshRootparameter for bounds detection - Upward motion with slight outward drift
- Rising embers with heat distortion
- Orange/yellow color gradient
- Chaotic motion with turbulence
- Suitable for campfires, furnaces
- Tight particle cluster (0.08 spread)
- 6 particles per torch
- Concentrated flame effect
- Minimal horizontal drift
Memory Budget
Vertex Buffer Attributes (per particle layer):-
Particle layers: 7 of 8 max attributes
- position (1)
- uv (1)
- instanceMatrix (1)
- spotPos (1)
- ageLifetime (1)
- angleRadius (1)
- dynamics (1)
-
Ripple layer: 5 of 8 max attributes
- position (1)
- uv (1)
- instanceMatrix (1)
- spotPos (1)
- rippleParams (1)
Extensibility
To add new particle types:- Create specialized manager (e.g.,
SnowParticleManager.ts) - Add type to
ParticleConfigunion inParticleManager.ts - Add case to
register(),unregister(),move()switch statements - Call
update()inParticleManager.update()
Visual Quality Settings
Particle Density
Particle counts are tuned for performance vs. visual quality: Fishing Spots:- Splash: 4-8 particles (depends on spot type)
- Bubble: 3-5 particles
- Shimmer: 3-5 particles
- Ripple: 2 particles
- Fire: 6 particles per torch
- 4 torches per arena = 24 particles total
- Max splash: 96 instances
- Max bubble: 72 instances
- Max shimmer: 72 instances
- Max ripple: 24 instances
- Total: 264 particle instances across all fishing spots
Texture Quality
Glow Texture:- 64x64 pixels
- Radial gradient with power falloff
- Sharpness: 2.0 (concentrated glow)
- Alpha channel for soft edges
- 64x64 pixels
- Ring radius: 0.65
- Ring width: 0.22
- Exponential falloff for smooth edges
Future Enhancements
Potential additions to the particle system:- Weather Effects - Rain, snow, fog particles
- Magic Spell Effects - Spell-specific particle trails
- Combat Hit Effects - Impact particles on damage
- Environmental Ambience - Dust motes, fireflies, leaves
- Celebration Effects - Victory fireworks, confetti