DEV Community

Cover image for 🌳 Building Realistic 3D Bushes: Optimizing Procedural Generation in NervForge
The Lone Engineer
The Lone Engineer

Posted on

🌳 Building Realistic 3D Bushes: Optimizing Procedural Generation in NervForge

Just published a devlog article on taking NervForge's bush generation from obviously computer-generated to more natural looking plant with a couple of major changes (plus other fixes in the process):

Note: You can also try it yourself directly from here: https://nervtech.org/nervforge/

The biggest challenge? Implementing self-repulsion so branches don't intersect even at root level, without killing performance. Initial naive approach: 23x slower (16ms → 364ms). Final optimized version with deferred insertion levels and center-of-mass approximation: 58ms.

What's covered:

  • Spawn area distribution (disc/square) for natural root spreading
  • Architectural refactoring to eliminate widget dependencies
  • Deferred repulsion levels: real-time for visible structure, batched for details
  • Spatial grid optimization using weighted center-of-mass per cell
  • Lock contention solutions for multi-threaded branch generation
  • Performance profiling and iterative optimization strategies

The video walks through the actual problems encountered, shows the broken versions, and explains the exact solutions implemented. Code snippets, performance comparisons, and visual before/after examples throughout.

Perfect if you're working on procedural generation systems, spatial partitioning, or real-time graphics optimization. (If you think about it, the spatial grid implementation strategy is applicable beyond just tree generation)

You can also check the full DevLog article at this url: https://wiki.nervtech.org/doku.php?id=blog:2026:0314_initial_bush_config

Top comments (0)