Egregoria Devblog #9

Welcome to the 9th Egregoria devblog!

There won't be a lot of topic covered, but one big one!

3D Update

I spent the last three months rewriting most of the graphics engine to use 3D.
After a lot of vector maths, quaternions, perspective matrices, gpu memory shenanigans and big shaders, I'm happy to show you the result of this hard work.

Some buildings and roads in a forest
You can see a coal power plant, some bakeries, some farms and some houses

Realistic sky shader with the sun rising over the horizon, casting beautiful shadows
Credits for the sky shader goes to wwwtyro

A small town with procedurally generated houses

3D Roads

Porting the 2D road code to 3D to allow vertical roads was a very hard part which is not entirely finished.
As always, devil is in the detail and 3D brings a lot more detail!

However, we can now build beautiful road interchanges.

A simple highway interchange

Go crazy with the possibilities

The Road UI shows where the pillars will end up

The technical details

Making a 3D renderer involves a lot of decisions with different tradeoffs:

  • How do you store your meshes ?
  • How do you handle materials ?
  • What antialiasing technique do you go for ?
  • Forward or deferred ?
  • PBR or not ?

In the end, I chose to go with a forward renderer as I don't support any form of lighting since I'd need to handle thousands of lights (mostly lamp posts). NewCity doesn't have lights either, only some "light sprite" from what I've seen.

Forward rendering allows using the very powerful Multi-Sampling Anti Aliasing which is relatively "free" anti-aliasing and looks much better than FXAA to me.

The renderer has a few render passes, summarized in this diagram:

done using excalidraw

The depth prepass avoids having too much overdraw, the SSAO w/ depth reconstruction was rederived by me and is not perfect, but it is very fast and looks good enough.

Here, SSAO is exagerated to show the effect

To summarize, here are the features supported by my wgpu "engine":

  • GLTFhttps://en.wikipedia.org/wiki/GlTF import (up to 1 material only atm)
  • Generated meshes
  • SSAO
  • Basic directional light shadow mapping
  • Vertex coloring
  • Albedo map
  • Sprites
  • Instancing (e.g. lots of trees!)
  • Basic terrain management

Here are some features I'd like to implement somehow:


Following matklad's advice, and pushing toward helping potential contributors, I have written an Architecture.md file to explain Egregoria's code architecture.

You can read it here.

I'll also share the bird eye's view.

What next ?

Since 3D renderer results are good enough for now, I'll focus on the simulation and gameplay features.
For example, more ways of transportations (train? bicycles? bus?) and also building interiors!

There are a lot of gameplay ideas just waiting in the backlog.

If you ever want to chat about Egregoria, keep in mind there is a discord server.
You can talk about your ideas, city builders or anything else. It's definitely a source of motivation and helps to steer this project in the right direction.

< Back to list