Blog

Game Engine Progress: Month 4 ยป posted Wed 20 May 2020 07:34:09 PM EDT

So quite a lot has happened since my previous post. A 100-year plague has ravaged the earth, the markets have collapsed world-wide, and a new Doom has been released. In the midst of the ongoing apocalypse I happened to make some substantial improvements to my engine:

(Spoiler: it doesn't run on my atom n270 anymore :/)

State of the Engine

This screenshot sums things up pretty nicely, you can see here PBR models and different dynamic light types, editing object variables with ImGui, seperate camera objects, tonemapping... Definitely a big change from the last post. The normal mapping is still a bit broken, something with the tangent generation I haven't quite figured out yet, but eh, close enough for now. At the moment I'm trying to get things to a state where I can start developing the actual game soon, so bugs like this aren't too important just yet.

As far as ImGui goes, it was really easy to get it working, and the programming model is great, I would highly recommend. If only all GUI programming could be so simple...

WebGL demo

Live here
(note: the physics are very broken)

Last weekend I had decided to try out emscripten, and managed to get a fairly usable port for webgl up and running. It was a bit challenging, and required a major overhaul to the shader framework I had set up, but overall it went pretty smoothly. One major problem so far is that webgl doesn't support format conversion when specifying textures. Albedo textures are encoded in sRGB space, so without converting to linear color space on texture upload the albedo texture is converted to sRGB space again after gamma correction, which makes it way too bright. Gamma correction is necessary for good lighting, so I'll have to either keep a seperate set of albedo textures encoded in linear space, or do the sRGB->linear conversion myself before uploading. Also, the skybox breaks for some reason when switching to editor mode...

A quick summary of the controls:

    General:
      w, a, s, d, q, e - forward, left, back, right, up, down, respectively
      m                - toggle editor mode

    Player mode:
      click  - spawn a physics ball
      space  - add to the upwards acceleration
      escape - quit

    Editor mode:
      middle click - pan camera
      click        - place, select something
      i            - load save map

HRTF for audio

Song: Gojira - Satan is a Lawyer
(Should sound like it's going clockwise around your head)

Naturally, immersive audio is an important part of a good game, and I'm already making my own engine so why not roll my own 3D sound thing too. I've been working on this alone for a solid two weeks, tuning it has been a huge timesink, but I'm fairly happy with how it's turned out so far.

As far as the implemention goes, it's pretty simple: It keeps a circular buffer of samples from the mono input, and uses some trig to determine what sample should be output for each ear given the speed of sound and the position of the audio around the head, also accounting for phase shift, then applies a low-pass filter depending on the position. It does this twice, once for the main sound and for the reverb around the head, and sums the results. Not too shabby, has a lot of tunable parameters and isn't too expensive to compute.

This isn't merged in yet, but should be pretty soon.

PBR with a glTF helmet

A screenshot from april, after implementing the BRDF function from the glTF implementation notes. Looks pretty good!

Rendering order

This shows front-to-back ordering of draw calls relative to the camera. Not very impressive on its own (although it does improve performance), but this sets up the skeleton for fancier occlusion culling.

Octree

Finally a debug view of octree generation, just because it's neat.

To be continued

Next things to do:

Cool links to clicken and share