Lithium

Directory

↓ About
↓ Roadmap
↓ Examples
↓ Screenshots

About

↑ Top

General

Lithium is a 3D game engine for 64-bit Windows written in C++ and uses OpenGL as its low-level
rendering API.

The engine allows for modular development of a game meaning that programmers, texture artists,
modelers, mappers, etc. will see few conflicts in their project during development due to the
authoring tools provided by the engine and the modular design of the engine's internal code.

Complex scenes with many objects with high-quality lighting due to the deferred rendering pipeline,
LODs for objects in the scene, and other graphics pipeline optimizations.

Currently, the engine is undergoing a major refactor to improve the engine's design, performance,
and usability. This includes a new structure for how objects and behavior are handled and a suite
of commonly used data structures and behavior across the different engine modules and projects.
This includes a custom memory allocator, allowing both managed and unmanaged memory, custom
containers, and synchronization primitives. This refactor is aimed to be comleted somewhere
in mid-May. As a result of this refactor, some of the information below may become outdated as
structures are constantly in flux.

Update May 7, 2023 6:07 PM: Compiling shaders no longer crashes the program!

Update April 24, 2023 8:38 PM: No more compiler errors (or warnings) from the refactor!

Technical


The engine uses Freetype 2, libpng, expat, zlib, and glad for third-party libraries.

The Windows API is used for all performance-critical areas of the engine, such as the the
window. A window is created manually using CreateWindowExA and its events are managed
manually to remove as much function call overhead as possible while still being fairly
easy to use by an end-user.

In the future, I may plan to switch to using my own cross-platform windowing system, mtgl,
which can be found on GitHub.

Roadmap

↑ Top

Future Features

Examples

↑ Top

Example Game Script

This script creates a new Point Light when a map loads then animates its x-position using sine.

scripts.h

					#include<game_script.h>
					#include<engine.h>
					#include<render_main.h>
					#include<render_light.h>
					
					using namespace lithium;
					
					classMyScript : publicScript {
					private:
					ManagedMemory<PointLight> m_light; // auto-initializes to null
					public:
					// overriden functions, all optional
					virtual boolinit() override;
					virtual voidstart() override;
					virtual voidupdate() override;
					virtual voidunload() override;
					}
					
				

myscript.cpp

					#include"scripts.h"
					
					boolMyScript::init() {
					// called when engine initializes
					returntrue; // success
					}
					
					voidMyScript::start() {
					// called when when the map loads
					RenderLightHandler *rLightHandler = ENGINE->renderLightHandler();
					   m_light = rLightHandler->createPointLight();
					   m_light->diffuse = Color3(1.0f, 0.0f, 0.0f);
					   m_light->enabled = true;
					}
					
					voidMyScript::update() {
					// called each frame
					
					// animates the position of the light
					float sinTime = sinf(ENGINE->time());
					   m_light->position = Vector3(sinTime * 10.0f, 10.0f, 0.0f);
					}
					
					voidMyScript::unload() {
					// called when the map unloads
					
					// remove the light we created, or it will persist in next map
					RenderLightHandler *rLightHandler = ENGINE->renderLightHandler();
					   rLightHandler->removePointLight(m_light);
					   m_light = nulled(PointLight); // good practice
					}
					
				

Example Material Script

Script is used to animate water outside C++ code and is referenced within the water material file,
but can be used to animate any material.

animate_water.psc

					; $tpos is an output variable which controls texture offset
					import $tpos from Lithium.Texture
					
					; $time is an input variable equal to the number of seconds the map has been running
					import $time from Lithium.Engine
					
					; translate texture proportional to map uptime
					$tpos: vec2(div($time, 16), div($time, 8))
					
				

The water material that uses this script.

water.lmt

					<materialversion="1.0">

					

					<!-- What shader this material should use -->
					   <shadershader="GBufferGenericDeferred">

						<!-- Tell the shader to use these textures as input -->
						      <albedobase="color"/>
						      <metallicbase="metallic"/>
						      <roughnessbase="roughness"/>
						      <normalbase="normal"/>
						      <normalIntensitybase="0.1"/>

					   </shader>

					

					<!-- Tie script(s) to this material -->
					   <proxies>

						<!-- Binds the source textures to be controlled by the target script -->
						      <proxytarget="albedo metallic roughness normal"target="nature/animate_water"/>

					   </proxies>

					

					</material>

					
				

↑ Top

Screenshots

↑ Top

Physically-Based Rendering Model

Large Open-World Environments

Water reflecting a house, using Screen-Space Reflections

Supported antialiasing modes

Example usage of the scripting REPL

© 2024 Ethan Vrhel

view on github