Hackathon 2018

Custom Rendering Engine

written in C++, compiled to run in browsers

 

Tyler Howard

What is it?

  • It's the rendering part of a game engine!
  • It uses emscripten!
    • Write in anything that compiles to LLVM, compile LLVM to asm.js or WASM
    • plus a few ports of existing things like OpenGL or SDL
  • Long-term goal: be more data-driven than C++ code-driven, be able to describe actors and components with files of some sort (e.g. character and enemy data, level design entities)

Why do this?

  • I want to run into architectural challenges, on purpose
  • I want to document my process so I can help teach other people how to make games
  • I'd recommend using a real engine in practice, but starting from scratch like this makes for less information overload than Unity or Unreal's docblocks
    • that is, this approach is like building a tech tree, as opposed to getting another engine's huge info dump all at once and feeling entirely lost

What I Started With:

Kind of a lot! I've been working on this project since November.

  • Environment set up (a linode instance, a makefile, publishing, a functional program that compiled and didn't crash)
  • Basic functionality for detecting mouse/keyboard/gamepad events
  • Texture/image loading
  • Shader compilation
  • Index and Vertex Buffer loading
  • Some software abstractions layered around all that

Flexibility

  • Wanted to keep core game logic abstracted away from any external API
  • e.g. I want to be able to compile to both a Win32/64 .exe and to the web
  • Graphics can use either OpenGL or DirectX
  • etc.

Not what I focused on for Hackathon, but helped a lot

Status at 9 AM, Friday morning

a not particularly exciting rectangle with no interactivity, it may as well be a screenshot

"Rectangle"

  • This is evidence that I have:
    • Texture loading
    • Shader compilation
    • Index/Vertex buffers working
  • but there are still issues:
    • it's a boring rectangle (very simple geometry)
    • the geometry is unit-length, so it should actually be square (camera isn't correct, no projection matrix)
    • pressing buttons doesn't do anything

What I did during the Hackathon:

  • Finished abstracting out OpenGL calls away from core logic
  • Ability to import .obj 3D models to geometry
  • A properly working camera (fixes perspective)
  • Keyboard controls to actually maneuver that camera
  • A shader that uses the Blinn-Phong lighting technique

Live demo!

W: Move forward

A: Move left

S: Move backward

D: Move down

Space: Move up

X: Move down

Arrow keys: Rotate camera

F: Turn fullscreen on

 

Progress and bugs

"Model loading works! ... but I don't have a working camera"

"Camera works with the correct perspective! ... almost."

"okay cool got the camera perspective fixed for real"

"except I still can't move around"

"i am so lost"

the teapot finally renders!

still can't move camera

the teapot finally renders!

still can't move camera

hardcoded camera translation

not yet hooked up to keyboard

let's try getting a more complicated model than the teapot in

 

why does it crash due to running out of memory? ... oh

[models] thoward ==> ls -la
total 22260
drwxr-xr-x 2 thoward trusted     4096 Feb 23 19:45 .
drwxr-xr-x 7 thoward trusted     4096 Feb 23 12:16 ..
-rwxrwxrwx 1 thoward trusted 22228917 Feb 23 19:45 sponza.obj

tried to render teapot and cube, got neither

keyboard working! shading working! ... kind of

current live demo

Hackathon 2018

By tdhoward