Ghengin: A vulkan-based, shader-centric, type-heavy, Haskell game engine
Haskell
85
592 commits
updated Aug 28, 2026
A work in progress game engine.
Status of building all examples:
See the executables from ghegin-games.cabal in the examples/ directory.
The working examples are the following. In sequence, they build up to a
"user-space" higher-level engine using the Core of the engine only (ghengin-core).
Cooler examples:
planets-core implements Sebastian Lague's procedural planets
teapot-obj renders the Utah teapot using Blinn-Phong lighting and a perspective camera
Solid examples:
simple-triangle is a simple 2D trianglesimple-triangle-coloredsimple-cube is a simple 3D cube (no projections)simple-camera example of camera with projectionfull-pipeline a full shader pipeline example ported from FIRfunction-drawing attempt at drawing functions using shadersdear-imgui is a trivial demo which setups and renders the DearImGui demo windowExperimental examples:
function-plotting attempt a drawing functions using verticesoscilloscope attempt at drawing with an oscilloscope (UNFINISHED)lorenz-attractor the lorenz attractor; currently only static shader imageImplementing write-ups:
book-of-shaders-3 Chapter 3 of Book of Shadersbook-of-shaders-5 Chapter 5 of Book of ShadersWe have a nix derivation to set-up a shell with all required Vulkan and GHC dependencies. You can enter it using:
nix-shell
But it should also be possible to run the project if you provide all required
dependencies. You can take a look in shell.nix to get an idea of what they
are.
After that, we use cabal to build and run examples. For instance:
cabal run exe:simple-triangle
# or
cabal run exe:simple-camera
# or
cabal repl exe:simple-cube
I haven't had much time to write about this, but the key ideas are:
Things inserted into a RenderQueue are things that get rendered. Each render packet is essentially defined by:
MeshMaterialRenderPipelineMeshes are vertices together with properties to influence the render of these vertices, and are parametrized by:
Materials are group of properties that influence how all render packets sharing this Material are rendered; it is parametrized by:
Render pipelines are group of properties and descriptions of render pipelines in graphics parlor, that define how all render packets that share this render pipeline are rendered (across different materials and meshes); it is parametrized by:
The Compatible constraint must be satisfied in order to construct a render
packet. This constraint validates, at compile time, that:
Mesh (see also CompatibleMesh)
Material (see also CompatibleMaterial)
RenderPipeline (see also CompatiblePipeline)
...
The Core of the engine is abstract over the renderer implementation (through backpack), though we only have a vulkan implementation of the renderer, and the Core isn't yet fully standalone
The Core of the engine is much like the Core in GHC: it strives to be a tiny but very expressive engine, that can represent in its completeness the full engine (which provides additional features not directly available in Core, but that can be expressed in it), for example:
Camera construct is not part of Core, for it can be fully defined as
a RenderPipeline property that gets bound in descriptor set #0 once
per render pipeline, and some shader math. Of course, this ought to be
provided as a plug and play capability in the full engine (say, one just
has to import the Camera module, add it as a property of the render
pipeline, and call the imported camera shader function in their own
shader)
Some resources:
What ghengin-core does and does not:
These add-ons exist as separate packages, and are all included in ghengin, the
batteries included engine. These also attempt to be somewhat independent from
ghengin-core when possible.
Work in progress ones:
ghengin-camera, a camera object, shader, and update function (i.e. a camera, in its usual meaning)ghengin-geometry, some geometry thingsUnimplemented ideas:
ghengin-scene-graph, which defines a scene-graph and world coordinate space
with objects related in a hieararchy with properties defined relative to
their parents (i.e. a scene, in its usual meaning)ghengin-models, to load and render 3D modelsghengin-lighting, that provides lighting functions/models like the Blinn-Phong modelghengin-dearimgui, for UIs based on ghenginghengin will provide game-development abstractions on top of ghengin-core, and
will be more developer friendly in the sense that it does not require linear types
everywhere, rather only when expressely necessary.
It is future work.
Haskell
92.3%
TeX
7.3%
Ghengin: A vulkan-based, shader-centric, type-heavy, Haskell game engine
Haskell
85
592 commits
updated Aug 28, 2026
A work in progress game engine.
Status of building all examples:
See the executables from ghegin-games.cabal in the examples/ directory.
The working examples are the following. In sequence, they build up to a
"user-space" higher-level engine using the Core of the engine only (ghengin-core).
Cooler examples:
planets-core implements Sebastian Lague's procedural planets
teapot-obj renders the Utah teapot using Blinn-Phong lighting and a perspective camera
Solid examples:
simple-triangle is a simple 2D trianglesimple-triangle-coloredsimple-cube is a simple 3D cube (no projections)simple-camera example of camera with projectionfull-pipeline a full shader pipeline example ported from FIRfunction-drawing attempt at drawing functions using shadersdear-imgui is a trivial demo which setups and renders the DearImGui demo windowExperimental examples:
function-plotting attempt a drawing functions using verticesoscilloscope attempt at drawing with an oscilloscope (UNFINISHED)lorenz-attractor the lorenz attractor; currently only static shader imageImplementing write-ups:
book-of-shaders-3 Chapter 3 of Book of Shadersbook-of-shaders-5 Chapter 5 of Book of ShadersWe have a nix derivation to set-up a shell with all required Vulkan and GHC dependencies. You can enter it using:
nix-shell
But it should also be possible to run the project if you provide all required
dependencies. You can take a look in shell.nix to get an idea of what they
are.
After that, we use cabal to build and run examples. For instance:
cabal run exe:simple-triangle
# or
cabal run exe:simple-camera
# or
cabal repl exe:simple-cube
I haven't had much time to write about this, but the key ideas are:
Things inserted into a RenderQueue are things that get rendered. Each render packet is essentially defined by:
MeshMaterialRenderPipelineMeshes are vertices together with properties to influence the render of these vertices, and are parametrized by:
Materials are group of properties that influence how all render packets sharing this Material are rendered; it is parametrized by:
Render pipelines are group of properties and descriptions of render pipelines in graphics parlor, that define how all render packets that share this render pipeline are rendered (across different materials and meshes); it is parametrized by:
The Compatible constraint must be satisfied in order to construct a render
packet. This constraint validates, at compile time, that:
Mesh (see also CompatibleMesh)
Material (see also CompatibleMaterial)
RenderPipeline (see also CompatiblePipeline)
...
The Core of the engine is abstract over the renderer implementation (through backpack), though we only have a vulkan implementation of the renderer, and the Core isn't yet fully standalone
The Core of the engine is much like the Core in GHC: it strives to be a tiny but very expressive engine, that can represent in its completeness the full engine (which provides additional features not directly available in Core, but that can be expressed in it), for example:
Camera construct is not part of Core, for it can be fully defined as
a RenderPipeline property that gets bound in descriptor set #0 once
per render pipeline, and some shader math. Of course, this ought to be
provided as a plug and play capability in the full engine (say, one just
has to import the Camera module, add it as a property of the render
pipeline, and call the imported camera shader function in their own
shader)
Some resources:
What ghengin-core does and does not:
These add-ons exist as separate packages, and are all included in ghengin, the
batteries included engine. These also attempt to be somewhat independent from
ghengin-core when possible.
Work in progress ones:
ghengin-camera, a camera object, shader, and update function (i.e. a camera, in its usual meaning)ghengin-geometry, some geometry thingsUnimplemented ideas:
ghengin-scene-graph, which defines a scene-graph and world coordinate space
with objects related in a hieararchy with properties defined relative to
their parents (i.e. a scene, in its usual meaning)ghengin-models, to load and render 3D modelsghengin-lighting, that provides lighting functions/models like the Blinn-Phong modelghengin-dearimgui, for UIs based on ghenginghengin will provide game-development abstractions on top of ghengin-core, and
will be more developer friendly in the sense that it does not require linear types
everywhere, rather only when expressely necessary.
It is future work.
Haskell
92.3%
TeX
7.3%