Procedural Level Generation: From BSP to WFC
Roguelite without procedural generation is not roguelite. Survival-sandbox with fixed maps loses replayability. Our team of engineers with 10+ years of experience in game development (50+ level generation projects) knows: procedural generation is an architectural decision that requires serious design. Done carelessly, it generates "junk" levels: impassable corridors, isolated rooms, boring uniformity. We help configure generation so it works stably and fast. Order turnkey setup — get a ready module with quality control that reduces content development costs by 40–60% and pays for itself in 3 months. Contact us to assess your project.
Key Approaches to Generation
BSP (Binary Space Partitioning)
Recursive division of space into rectangular sections, each containing a room, with corridors connecting them. Classic dungeon crawler. Advantage: guaranteed passability. Disadvantage: rectangular monotony without additional post-processing. More details: BSP.
Wave Function Collapse (WFC)
Algorithm using compatibility constraints between tiles. Each cell has a set of possible states; when a state is chosen, neighboring cells receive constraints. The result is organic structures with high quality control through a set of rules. WFC generates levels 2x faster than manual development. Works with 2D tiles and 3D voxel structures. More details: WFC.
Noise-based terrain
For open worlds: Perlin noise, Simplex Noise, or Domain-Warped FBM. Unity Terrain with TerrainData.SetHeights() accepts a 2D float array — height generation via noise is done in 30 lines of code. Complexity begins with biomes: transitions, object placement, density control. Terrain generation requires curve tuning for vertical zones.
Grammar-based generation
For narrative levels with mandatory events: the progression graph is described via rules, the generator builds a level ensuring that graph. Used in action-roguelite where dramaturgy is important.
How to Choose a Generation Algorithm?
The choice depends on genre and platform. BSP suits dungeons with rectangular rooms, WFC for organic structures with clear rules, Perlin noise for large open worlds. For 2D dungeon crawler with procedural map generation, BSP is optimal; for roguelite with tile-based world, WFC; for survival-sandbox, noise-based with biomes. We will analyze your requirements and propose the optimal solution. Get a consultation — we will select an algorithm for your project.
Why Quality Control Matters?
Generation without validation is a source of bugs. Three main problems: passability guarantee, excessive uniformity, empty or overcrowded zones. Solution: flood fill/A* check, anchor rooms, Poisson Disk Sampling. This reduces defective levels by 90% and lowers testing costs. Level validation should be automated: after each generation, a script runs checking passability and object density.
More on passability check
Flood fill from the entry point fills all reachable tiles. If a key point (exit, boss) is not filled, the level is rejected. A* gives exact path but is slower. For mobile platforms, flood fill is faster and sufficient. Regeneration threshold: no more than 16 ms, otherwise the player will notice the delay.
The Hardest Part — Quality Control
Generation works, but not every generated level is "good". Three problems that always occur:
-
Passability guarantee. Flood fill or pathfinding (A*) from the entry point to all key points (exit, mandatory items, bosses). If pathfinding does not find a path — regeneration. Important: regeneration must be fast (< 16 ms on mobile), otherwise the player sees a loading delay.
-
Excessive uniformity. WFC and BSP without additional rules give a "bland" result — no accents, no interesting places. Solution: explicit anchor rooms (anchor rooms): start room, boss room, secret room — generated from fixed templates and placed in mandatory positions. The rest is procedural.
-
Too empty or too filled levels. Object placement (enemies, items, traps) cannot be pure random — you get either a desert or an impassable cluster. A working approach: Poisson Disk Sampling for even distribution with minimum distance between objects plus weight coefficients by room type and distance from start.
Example Implementation in Unity
Typical architecture for a 2D dungeon generator:
LevelGenerator
├── RoomGenerator — BSP / templates
├── CorridorConnector — room connections
├── ValidityChecker — flood fill passability
├── PopulationSystem — object placement
└── TilemapPainter — write to Tilemap
LevelGenerator receives LevelConfig (ScriptableObject with seed, dimensions, parameters) and returns LevelData — room graph with metadata. TilemapPainter renders LevelData into Tilemap with the required tile set. Separation of generation and rendering allows using one generator for different visual themes (dungeon, cave, ship).
Seed for reproducibility. Random.InitState(seed) before generation — the same seed always gives the same level. This is needed for: sharing levels between players (Daily Run in roguelite), debugging a specific level, server-side pass validation.
Generation Performance
On mobile devices, generation must fit into the loading screen. Benchmarks:
| Level size |
Generation time |
Comment |
| 50×50 tiles (BSP + population) |
5–20 ms |
On mid-range Android |
| 200×200 tiles |
50–200 ms |
Requires chunking with async |
| Terrain 512×512 (Perlin noise) |
50–200 ms |
Must be async/Thread |
Unity Job System allows moving noise generation computations into burst-compiled jobs — 5–10x speedup over managed code. Our team uses Job System to achieve 70% reduction in generation time.
Stages of Work
- Requirements analysis — generation type based on genre and mechanics.
- Algorithm prototype — quick validation of approach without final art.
- Quality control — level validator, rule iteration.
- Content integration — tilesets, anchor room templates.
- Performance — profiling, async, Job System.
- Parameterization — configs for game designer (difficulty, size, density).
What's Included
- Analysis of your project and game design documentation
- Development and tuning of the generation algorithm
- Integration into your engine (Unity, Unreal)
- Level quality validation
- Documentation and team training
- Post-launch support
Estimated Timelines
| Scale |
Timeline |
| Basic BSP dungeon generator (2D) |
2–4 weeks |
| WFC generator with quality control |
4–8 weeks |
| Noise-based open world with biomes |
6–12 weeks |
Cost is calculated individually after analyzing the genre, platform and level variety requirements. Contact us to discuss your project and get an estimate.
Cinematics and Video for Games
A cutscene that looks great in the editor can turn into a slideshow in the production build: characters freeze, camera jerks, lighting doesn't match gameplay. We've encountered this dozens of times on projects for PC and mobile platforms. A proper pipeline for creating game cinematics is built from the start, not in the final week. Below is how we structure this process.
What's Included in the Service
- Storyboarding and previs – animatic with timing, storyboard, narrative alignment before production begins
- In-engine cinematics – Timeline, Cinemachine (Unity), Sequencer (Unreal)
- Rendered cutscenes – pre-rendered video with engine integration
- Procedural generation of environments and animation – for large-scale content projects
- Technical art for cinematics – camera rigs, custom Timeline tracks
Why Are In-Engine Cutscenes More Advantageous Than Pre-Rendered?
In-engine cutscenes use actual assets, respond to player state (character customization, dynamic lighting) and do not require separate video file storage. The trade-off is the complexity of the production pipeline. But for 70% of modern projects, this approach is justified: disk space savings (up to 90% for multi-cutscene games) and the ability to adapt to different resolutions without re-rendering.
Timeline Architecture
Timeline in Unity is not just an animation tool but a full time management system for any game object. Each PlayableDirector manages a TimelineAsset containing tracks:
| Track Type |
Purpose |
AnimationTrack |
Character and object animations |
CinemachineTrack |
Switching virtual cameras |
AudioTrack |
Music, voiceover, SFX |
ActivationTrack |
Enabling/disabling objects |
ControlTrack |
Launching child Timelines, Particle Systems |
SignalTrack |
Calling events in code |
Custom tracks via PlayableBehaviour + PlayableAsset are key for complex cutscenes. For example, a track for controlling post-processing overrides, smooth DOF blend, or synchronizing subtitles with audio tracks. Over the years, we've implemented over 20 custom tracks for specific tasks.
Cinemachine: Virtual Cameras
Cinemachine fundamentally changes the approach to camera work. Instead of a single camera with keyframes, it's a system of virtual cameras (CinemachineVirtualCamera, CinemachineFreeLook, CinemachineStateDrivenCamera) between which the main camera smoothly transitions according to blend rules.
For cinematics, the most interesting are:
- CinemachineVirtualCamera – the main tool. Each virtual camera has its own Body (how the camera follows the target) and Aim (how the camera looks at the target). Combinations:
- Transposer + Composer: camera follows the character, keeping them in frame
- OrbitalTransposer + POV: third-person player camera
- DoNothing + DoNothing: fully static camera, controlled by keyframes
- Dolly Track (
CinemachinePathBase + CinemachineTrackedDolly) – camera moves along a spline. Designer sets the path in the scene, animator controls position on the path via Timeline.
- Camera Blend in
CinemachineBrain: transition between virtual cameras can be Cut, Ease In/Out, Linear, or via custom AnimationCurve. For dialogue scenes, the standard is Cut between lines, Ease for emotional transitions.
Problems and Solutions
Jitter when following a character – a common problem when physics update frequency (FixedUpdate) doesn't match rendering. Solution: CinemachineVirtualCamera > Body > Binding Mode: World Space + enable Stabilize Roll. If insufficient, a custom CinemachineExtension with additional position smoothing. Tested on projects with 30-60 FPS.
Lighting mismatch between gameplay and cutscene – occurs when switching between Unity scenes or using different Lighting Settings. In URP/HDRP, solved via Volume Profile Override on CinemachineVirtualCamera or via Timeline ControlTrack to activate the required Volume.
Lip sync – for dialogue scenes with voiceover, we use Salsa LipSync (Unity) or native Audio2Face (Unreal + MetaHuman). Basic level is viseme-driven animation via AnimationTrack with keyframes per line.
How Does Sequencer in Unreal Engine Simplify the Workflow?
Unreal's Sequencer is a functional analog of Timeline, but with several differences. For cinematic-level cutscenes, Sequencer is more convenient:
- Movie Render Queue instead of Play Mode for final render – provides path tracing, motion blur with subsampling, and consistent frame-by-frame results
- Level Sequence Actor allows nesting Subsequences – convenient for large projects where different parts of a cutscene are worked on in parallel
- Control Rig integration: direct FK/IK rig control in Sequencer without switching to Animation Blueprint
For MetaHuman characters, Sequencer is the main tool: facial animations via Face AR or Performance Capture are written directly into the Sequencer track.
Pre-Rendered Video: When and Why
Pre-rendered cutscenes are justified for intros/outros where quality matters more than interactivity. We render via Unity Recorder or Movie Render Queue (Unreal), final editing and color correction in DaVinci Resolve.
Engine integration: .mp4/.webm via VideoPlayer (Unity) or Media Framework (Unreal). Important for mobile platforms – video may not be hardware-decoded on all target devices; we check codec support in advance (H.264 – safe choice, H.265 – better quality but not all Android support it).
Cutscene Production Process
For each project, we go through these stages:
| Stage |
Duration (days) |
Result |
| Script + storyboard |
2–5 |
Approved script, storyboard |
| Previsualization (animatic) |
3–7 |
Draft with timing |
| In-engine assembly |
5–15 |
Finished cutscene in engine |
| Custom tracks + technical art |
2–5 |
Solving specific tasks |
| Testing and optimization |
1–3 |
Smooth 30+ FPS on target devices |
| Final render and integration |
1–2 |
Pre-rendered video or build |
Timelines are approximate and depend on scene complexity (number of characters, length, platform). Pricing is calculated individually – we'll evaluate your project free of charge upon request.
Procedural Generation: Wave Function Collapse for Assets and Animation
For projects with large amounts of content (roguelike, open world), manual creation of every level is impractical. Wave Function Collapse (WFC) is a tiled generation algorithm based on the principle of entropy (the name is metaphorical, the algorithm is deterministic). The gist: each grid cell can be one of N tiles; the algorithm iteratively "collapses" cells by selecting a tile based on compatibility rules with neighbors.
Practical application in Unity: the mxgmn/WaveFunctionCollapse library or a custom implementation for a specific game. Compatibility rules are set either manually (JSON describing which tiles can neighbor) or learned from example levels.
BSP (Binary Space Partitioning) – a classic algorithm for dungeon levels. Simpler to implement but less flexible in results. For roguelikes, it's a good choice.
For cinematics, procedural generation is also applied in another context: procedural camera animation (handheld camera shake, breathing idle) via Cinemachine Noise or custom Perlin noise-based controllers – adds cinematic liveliness without manual keyframing every movement.
Typical Mistakes When Creating Cutscenes
-
Ignoring performance: a cutscene with 20+ active virtual cameras can consume all FPS. Solution – use Priority and disable inactive cameras.
-
Lack of fallback for mobile platforms: pre-rendered video must have an H.264 fallback, otherwise older devices will show a black screen.
-
Overloading Timeline: tracks without organization turn the project into a mess. Rule – group by type (Animation, Audio, Control) and use Sub-Timeline for long scenes.
Why Entrust Cinematic Creation to Us?
With 10+ years in game development, we've implemented cinematics for over 50 projects – from mobile platforms to PC and consoles. Certified Unity (Unity Certified Developer) and Unreal Engine (Unreal Authorized Training Partner) specialists. We guarantee stable cutscene performance on all target devices.
Contact us for an evaluation of your script. Order turnkey cinematic development – from storyboarding to final build.