top of page
ARIIQ WICAKSANA
technical artist
Terrain Generator
Engine : Unity
Tools : Unity
Terrain Generator is a tool to help create procedural content generation that is terrain.
Material

Shader Graph

Script
Explanation
To ensure high performance for real-time terrain generation, I designed a multi-stage system leveraging Unity’s Job System and Burst Compiler. The system is modular, scalable, and optimized for massive terrains with minimal GC pressure and high parallelism.
System Overview
The terrain generation process consists of several key stages, each managed as separate jobs for maximum performance:
-
Position Calculation Job (PositionJob)
-
Input: Grid size (e.g., chunksPerAxis), spacing, and origin.
-
Output: NativeArray<Vector3> of world positions for noise sampling.
-
Job Type: IJobParallelFor.
-
-
Noise Sampling Job (NoiseJob)
-
Input: Position array from PositionJob.
-
Output: NativeArray<float> of height values based on coherent noise (e.g., Perlin, Simplex).
-
Parallelized: Yes, using IJobParallelFor with Burst for SIMD optimization.
-
-
Mesh Data Generation Job (MeshDataJob)
-
Input: Heightmap array from NoiseJob.
-
Output: Vertices, normals, UVs, and triangle indices stored in NativeArrays.
-
Optional: Includes LOD support or normal smoothing based on surrounding heights.
-
-
Mesh Application (Main Thread)
-
Once jobs are complete, the mesh data is marshaled back to the main thread to create a Unity Mesh.
-
Performance Features
-
Burst Compiler: All jobs are Burst-compiled, drastically reducing CPU usage and improving throughput via vectorization (SIMD).
-
Memory Layout: Using NativeArray<T> with deterministic memory allocation and disposal to avoid GC.
-
Parallelism: Heavily utilizes IJobParallelFor for maximum CPU core utilization.
-
Job Dependencies: JobHandle used to schedule dependent jobs cleanly without blocking the main thread.
Debug Tools
-
Gizmos: Debug mode includes position markers and height map visualization via Debug.DrawRay.
-
Timing: Custom profiler stopwatch to track job durations and bottlenecks.
bottom of page