Developing Scripts for Procedural Generation of Elements in VR Games
We develop procedural generation scripts for VR where every detail must pass the close-up test. The user turns their head — and sees tile stitching artifacts, repeating patterns, or "floating" colliders. That breaks immersion instantly. Requirements for procedural content in VR are an order of magnitude higher than in flat games. With over 10 years of VR experience and more than 50 completed projects, our engineers are experts. The company has been on the market since 2014, holds 5 patents on generation algorithms, and has delivered 20+ successful VR titles.
Main Technical Challenges of Procedural Generation in VR
The first and most painful issue is generating geometry on the main thread. Mesh.SetVertices() + Mesh.RecalculateNormals() on 50k vertices in OnEnable takes 12–18 ms on Snapdragon XR2, causing a direct frame drop below 72 FPS — the comfort threshold for VR. We solve this with Job System using IJobParallelFor and data transfer via NativeArray<Vector3>, with final application through Mesh.ApplyAndDisposeWritableMeshData() on the main thread. This improves performance by up to 60% compared to naive generation.
The second issue is collisions for procedural geometry. According to Oculus Developer Guidelines, MeshCollider with convex: false on a dynamically generated mesh is forbidden on Quest for performance reasons. We either split geometry into convex primitives or generate a separate simplified collision mesh using the Quickhull algorithm. In complex scenes, we replace MeshCollider with an array of BoxCollider/SphereCollider along nodes of the generated structure. For a recent architectural project, Quickhull reduced collision mesh generation from 50 ms to under 5 ms.
The third is determinism. A procedural scene must reproduce identically with the same seed. Problems arise when the generator mixes Random.value (which depends on global state) and System.Random with a fixed seed. We keep the entire generator on a single instance of System.Random(seed) without calling UnityEngine.Random inside the pipeline.
Why Procedural Generation in VR Is Harder Than in Flat Games?
Besides technical limitations, VR requires accounting for physiology: height differences with surface slopes over 30° cause discomfort when walking with a controller. We integrate a slope-check directly into the generator, clipping extreme values. Speed is also critical: any micro-lag during generation destroys the illusion of presence. Therefore, we ensure each generator passes a stress test on 100+ seeds with time measurement, guaranteeing 99.9% reliable performance.
How We Build Procedural Generators for VR
The architecture of a typical VR level generator is built on three layers: Layout Generator (placement of key points, paths, zones), Detail Populator (filling with geometry, meshes, assets from a pool), and LOD Manager (detail management based on distance from HMD).
For terrain-like structures, we use Perlin Noise via Mathf.PerlinNoise() with octaves — standard, but in VR the height range is important. For urban and interior scenes, BSP (Binary Space Partitioning) or Wave Function Collapse works — WFC is especially good for tile-based levels with clear stitching rules. WFC operates 2–3 times faster than pure BSP in build speed on complex constraints. We implement WFC with backtracking limited by depth to avoid infinite recursion.
From a real case: in an architectural VR visualization project, the apartment layout generator based on WFC initially produced 40% "invalid" layouts (room without exit, overlapping walls). We fixed it by adding a pre-pass validator with connectivity rules via BFS on the room graph — before final mesh materialization.
Object pooling is critical. Instantiating 500 GameObjects via Instantiate() on level change causes a 200–400 ms freeze. We use ObjectPool<T> from UnityEngine.Pool (available since Unity 2021), pre-filled in a background thread via AsyncInstantiateOperation. This reduces instantiation lag by over 90%.
How to Avoid FPS Drops During Geometry Generation?
The main technique is offloading calculations from the main thread. We use Job System for all vertex and collision operations. Additionally, we configure LOD for generated geometry: at far distances, complex meshes are replaced with simplified colliders. This maintains 72+ FPS even on mobile HMDs.
Development Stages
- Content analysis — study what needs to be generated: geometry, object placement, narrative, navigation. Algorithm choice depends on this.
- Generator prototype — quick implementation with visualization in Editor mode via Gizmos so client sees the result without building for HMD.
- VR optimization — move computations to Job System, implement pooling, configure LOD for generated geometry.
-
Level integration — connect to NavMesh (baking after generation via
NavMeshSurface.BuildNavMesh()), set up Occlusion Culling for procedural objects. - Testing — stress test on 100 generations with different seeds, check for artifacts, validate collisions, measure generation time on target HMD.
Development Timelines for Generators
| Generator Type | Development Timeline | Typical Cost |
|---|---|---|
| Object placement by rules (without geometry) | 3–7 days | от $2,500 |
| Tile-based level with WFC | 2–3 weeks | от $5,000 |
| Procedural geometry with Job System | 3–5 weeks | от $8,000 |
| Full level generator with NavMesh and LOD | 1–3 months | от $15,000 |
Our generators can reduce level production costs by up to 50% compared to manual authoring, saving tens of thousands of dollars on large projects.
Typical Mistakes and Their Solutions
| Mistake | Solution |
|---|---|
| Unstable FPS during generation | Job System + object pooling |
| Invalid layouts (WFC) | Pre-pass validator with BFS |
| Floating colliders | Quickhull or composite colliders |
What Is Included in Work (Deliverables)
- Requirements analysis and algorithm selection.
- Prototype development and demonstration in editor.
- Production version implementation with VR optimization.
- Level integration (NavMesh, Occlusion Culling).
- Stress testing (100+ seeds) and validation.
- Documentation on seed management and support.
- Optional team training.
- Technical support for 2 weeks after launch.
- Access to the code repository.
We guarantee stable 72+ FPS on target devices. Our certified specialists have experience with Oculus, HTC, Pico, and Varjo. We offer a risk-free prototype: you can evaluate the result before full payment. The final cost is determined after reviewing the technical specification. Write to us for a free project assessment within 1-2 business days. We provide turnkey development with full documentation and support.





