Skip to content

sekaha/AGBAES

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Gan-Based Approach to Erosion Simulation

Authors: David Sommerfield and Nicholas Moen

This repository contains code and a paper detailing a method for simulating hydraulic erosion on heightmaps. It utilizes a GAN framework for training, while the core architecture is a high-performance CNN designed for realistic and efficient terrain generation. This approach is enables high speed terrain procedural terrain generation and real-time terrain authoring in artistic applications.

Note: the paper was just made for a university course, so it's less polished than a typical academic publication. See our presentation here: Google Slides Link.


Results

image

image

image

Input

image

Predicted

image

Actual

image


Key Features

  • Architecture: Based on a modified pix2pix model, the framework incorporates encoder-decoder structures and a patch-based discriminator. The generator utilizes dilated convolution layers to capture long-range spatial patterns like sediment carry.
  • Performance: This model performs signifigantly faster than traditional simulation (~192x faster than the simulation we used to generate the training data). On three Quadro RTX 6000/8000 GPUs, the model generates 32 terrain images in 0.1 seconds. Even a single GTX 1060 achieves this in 0.3 seconds, making it suitable for real-time applications.
  • Data Generalization: Trained on a diverse set of procedurally generated heightmaps (e.g., Perlin noise), the model demonstrates adaptability by effectively simulating erosion on unseen data.
  • Limitations: The model exhibits minor grid artifacts in the output terrain and can benefit from further refinements in detail generation.

Datasets

The training data was created using a custom data acquisition pipeline, described in detail in the "Datasets" section of the final project report.

  • Input Images: Generated using Perlin noise maps with adjustable parameters such as scale, noise level, amplitudes, and variances all distrubted according to a normal distribution. These parameters enabled the creation of diverse terrain characteristics and helped avoid artifacts resulting from sparse input.
  • Output Images: Created by running the input DEMs through a hydraulic erosion algorithm.

To optimize the data for GAN-based architectures, images were encoded as 16-bit .tiff files, allowing parameter values to range from 0–65535 instead of the typical 0-255 (important for smooth height representation).

Encoding details:

  • Red Channel: Height (the only value that differs between input and output).
  • Green Channel: Rock hardness.
  • Blue Channel: Erosion amount in simulation (constant per image).

image

image

Model Overview

Generator

  • Encoder: Downsampling with dilated convolutions to capture both local and long-distance features.
  • Decoder: Transposed convolutions and dilated layers to upsample and refine the output.

Discriminator

  • Patch-based evaluation (patch size: 70×70) focuses on localized details for realistic texture reproduction.

Training

  • Loss Function: Mean Absolute Error (MAE) and LPIPS for realism and perceptual similarity.
  • Augmentation: Random rotations to improve robustness across terrain orientations (not strictly necessary).
  • Hardware: Trained on three Quadro RTX (6000/8000) GPUs over 200 epochs (21 hours).

Setup

  1. Create Conda Environment:
conda env create -f agbaes_env.yaml
  • Or if you want just make sure your dependencies match.
  1. Activate Environment:
conda activate agbaes_env
  1. Configure Dataset Path:
  • Change the dataPath variable in test/test_generator.py (line 83) and models/train.py (line 92).

Training

To start training:

  1. Navigate to models directory:
cd models
  1. Run the training Script
python3 train.py

Testing

After training, run the testing script:

  1. Navigate to test directory:
cd test
  1. Run the test script:
python3 test_generator.py

This will generate output images for evaluation.

Custom Images

You can modify the ErosionOnFileWith8_BitImages() function in test_generator.py to use your own images.


For further details, consult the provided paper or feel free to contact us.

About

A Gan-Based Approach to Erosion Simulation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages