Offroad Engine 2 (2008 - 2020)
My homemade open-world game engine with advanced vehicle simulation and easy to use terrain editor, successor of the Offroad engine. It is designed to support much larger landscapes, greater visibility distance and user-friendly scene editor.
Project is written in C++ using SDL2 library, ImGui user interface and OpenAL-soft for sounds. Physics is no longer powered by my own physics engine from the Offroad1 project but I decided rather to integrate the much more modern PhysX 4.1 library from NVidia.
Main features:- 41x41 km open world map (8192x8192 heightmap grid)
- easy to use terrain editor (incl. road editor)
- complex vehicle simulation
- battery charge
- brakes temperature
- engine overheating
- main component wear
- multiplatform (Linux, Windows)
- two testing vehicles (extensible)
- based on Škoda 110r
- based on Karosa bus
Architecture
Project is composed from separate basic modules which communicate using a message bus updated once per frame. Each module then optionally runs a separate thread for its own calculations. Scene manager and renderer threads are currently interlocked as I don't have yet fully implemented smooth scene interpolation/extrapolation (it works just for PhysX objects at this moment).
Messages between modules were previously implemented by C Unions so they can be easily created on stack and with C++17 I upgraded them to std::variant to solve deallocation if the message holds some dynamic memory. Each module can send a message to any other module, messages will be evaluated in the next frame. Modules run their own thread but they are synchronized at the beginning of each frame when messages are being processed.
Simulation
Physics simulation is based on Vehicle implementation in PhysX library with some minor adaptations (for manual shifting). Terrain is streamed around the player's vehicle to a physics scene in 80x80m grids. There are also dynamic objects created (barrels, traffic signs) which are streamed together with the tile but can't stream in another tile.
Internal vehicle simulation is based on a component system where each component has its own durability, heating and battery drainage which can vary in time (lights drain more power on high beam than on low beam mode). Battery simulates internal resistance based on its actual charge and outside temperature.
Editor
Engine contains a built-in editor for all basic operations: heightmap and surface edits, object placement, roads, water. It also allows importing various external bitmap images with predefined global data (for example surface map with tree areas).
Rendering
Scene is rendered using OpenGL API, objects have assigned GLSL materials. Good performance is ensured by a combination of hardware instancing and dynamic vertex buffers. Engine implements also several useful tools for image post-processing used for bloom effect or sun rays.
Future work
There are several improvements I would like to implement in future:
- Quad-tree terrain - to increase visibility distance and performance
- PBR materials, glTF format - easier model import, better appearance
- Deferred rendering - for unlimited lights support
Download
Engine is available at Itch.io