A real-time terrain generator using fault formation algorithm, rendered with WebGL 2.0. Features dynamic terrain generation with adjustable parameters and automatic camera rotation.
- Real-time terrain generation using fault formation algorithm
- Phong lighting with environment-aware specular highlights
- Automatic orbit camera
- Responsive fullscreen display
- Color variation based on slope (green for shallow slopes, red for steep areas)
- Dynamic terrain resolution control
- A modern web browser with WebGL 2.0 support
- Local web server for development
- Clone the repository
- Serve the directory using a local web server
- Open
index.htmlin your browser
The interface provides a control panel at the top with the following options:
- Grid size: Controls terrain resolution (default: 50)
- Faults: Number of terrain deformations to apply (default: 50)
- Regenerate Terrain: Creates new terrain with current parameters
The main window shows the generated terrain with automatic camera rotation.
Uses fault formation algorithm:
- Creates a flat grid of specified resolution
- Applies random fault lines that raise/lower terrain
- Normalizes heights to maintain consistent scale
- Generates smooth normals for lighting calculations
The terrain uses a custom shader that:
- Applies different materials based on slope
- Shallow slopes: Green with sharp specular highlights
- Steep slopes: Red with broader, dimmer specular reflection
- Includes ambient, diffuse, and specular lighting components
Features an automatic orbiting camera:
- Maintains fixed height above terrain
- Orbits at constant speed
- Looks at terrain center with slight downward tilt