Cascadia 0.2

Sun Nov 12 2023

A new devlog with the first update for Cascadia! There may not seem to be a lot here, but there were some major under-the-hood changes that I needed to do to set up the groundwork for future updates as time goes on.

Download Pre-Alpha 0.2 and smell the pretty flowers 🌹

Changelog

Additions

Changes

Fixes


To get Cascadia out of prototyping and into pre-alpha, I had to make some game jam-esque sacrifices by hardcoding things into the program. The two I'm sharing today are both graphics-related: render passes and chunk rendering.

What's a render pass?

When you want to draw something to the screen, you need to give your GPU instructions and data to work with. Those instructions are called shaders and that data is given through a pipeline. Altogether this makes up a render pass!

Games can use multiple render passes to create the final image, like terrain, character meshes, water, post-processing effects, and UI.

Cascadia has one non-UI render pass which can only render terrain, which is a problem if I want to render something that isn't terrain.

Since this is will be a long-term effort, I'll start small and set up a line drawing render pass so I can give players a block selection box when they mouse over a block within reach.

Drawing lines can't be hard, right?

Drawing lines on screen is apparently a hard problem.

Shaders may support drawing line primitives, but they kind of suck as detailed in the linked blog post and were not going to work in my game. Guess I'll have to triangulate my own lines.

There are many ways to go about doing this, especially more so in 3D, so I'll skip to what I ended up going with: screen-space projected lines.

Let's break down what that means.

Spaaaaace

When working in graphics there's a concept of spaces; coordinate systems that are centered around a specific origin.

There are many kinds of spaces, object space (sometimes called "model space"), world space, view space (sometimes called "eye space"), clip space, and screen space.

Object space is the coordinate system that the vertices of a model reside in, relative to the model's origin.

Of course, models don't permanently sit at (0, 0, 0), they can be positioned within world space, and thus relative to the world's origin.

View space is the coordinate system in front of the camera. In fact, in shader code you transform world space into view space—the world moves around the camera!

But view space on its own has no perspective, which is where clip space comes in. By doing some clever math, you can apply perspective to get clip space, which is ultimately what you submit to the GPU's rasterizer1.

So what's screen space then? Well it's the pixel coordinates of your screen! We want to project the 3D world space coordinates of our lines into screen space so that we can triangulate it there and get lines of constant thickness.

If we were to triangulate without projecting to screen space first, our lines would experience perspective and appear thinner the further away they are.

Hmm, chunky

Cascadia's chunk renderer is hardcoded to create cube meshes, but not all blocks are cubic, like the new red poppies. I could hardcode those in, but this is just unsustainable in the long-term.

So I created a data-driven system that loads block models through json files! Block models can have multiple sub-elements, each with their own shape, size, rotation, and textures.

It also supports parenting, which allows a model to inherit from a template to simplify the process and minimize redundant code. Pretty neat, huh?

Postmortem

The line renderer and block models are both important system for Cascadia. In their current state they are a bit rough, but so is the rest of the code :P In time they'll get polished.

So what's next for Cascadia? More polish! And hopefully some new content too. It's hard to pinpoint exactly what I'll work on next as I'm still learning how to do things, and it'll probably stay that way until I reach a more stable version where I can focus more on content, such as alpha and beta.

Footnotes

  1. The rasterizer is what turns triangles into pixels on your screen. ↩

signature
← Back