Water

This month has involved building worlds, a visual identity crisis, and Lua.

World building

I have a somewhat clear picture in my head of the world I want to build and having dabbled with procedural generation in the past I know there is a world of pain awaiting me. For this reason I wanted to investigate a bit what tools might allow a more semi-automatic approach to world building.

Using the LOD system I already had in place I experimented a bit with how it could potentially be used to actually edit a large world.

It’s very early still but I also made some changes to how voxels are evaluated that simplify the world building. Rather than dealing with raw voxels I now evaluate voxels based on a heightmap (for landscape) and an edit list (inspired by Dreams) for combining multiple smaller SDF-style edits. This made the editing a lot easier to implement.

Visuals

I’ve also experimented with the visuals.

Animations

One thing that has bugged me for a while is how to deal with character models, so I tried out two approaches.

Anim1

First a typical Minecraft-ish 3D approach. It’s still voxels so no skinning or anything. Animation isn’t winning any awards but you get an idea.

Anim2

Second, I tried just putting a typical pixel-art-style billboard in there. And I kinda like it. The character is taken from the Ninja Adventure Asset Pack.

Splatting

Splatting

Played around with splatting to give that painted visual style.

Buggy splat

Including dealing with all types of bugs.

Normals

Smooth normals

With the heightmap in place, it’s straightforward to also calculate the normals of the terrain so I tried out baking smooth normals into the voxels. So basically each voxel also has a packed normal and we are not restricted to the normals of the voxel itself.

Old normals

As you can see it gives a bit of a different vibe compared to how it looked before. Not really decided which way to go though.

Water

Water

I also implemented very simple water. Nothing much yet, but it helps a bit when tweaking visuals. For now it’s just flatlands (a plane stretching across the whole world), but it would be cool to allow for rivers flowing from mountains and such later.

3D pixel art

I fell in love with this YouTube video showing off a 3D pixel art game. This led me into another rabbit hole: how to create 3D pixel games. As a happy surprise it turns out that my current camera setup makes it very easy to implement so I’ve tried it out a bit. Not fully happy with the results so nothing to show yet, but I might continue tweaking it a bit.

Lua

I’ve mentioned hot reloading in the past and it came with various issues I couldn’t be bothered to deal with so I just disabled it. However, as I got back to gameplay and the editor I missed the short feedback loop so I thought maybe it’s time to try Lua. How hard can it be? Surprisingly not that hard thanks to ziglua.

It’s fairly simple, now I just have two Lua environments, one for the editor and one for the game. Then I expose a small API which lets the Lua side do various things. I’m split on the whole two-language thing though, on one hand it’s annoying to maintain but on the other I don’t feel as bad writing crappy experiments in Lua as it doesn’t leak into the backend code as easily.

local M = { target = nil }

function M:update(_)
  if not self.target or not world.isValid(self.target) then
    return
  end
  local pos = world.getPosition(self.target)
  if not pos then
    return
  end
  local cam = world.getCamera()
  if not cam then
    return
  end
  local rot = quat.fromEuler(pitch, 0, 0)
  local fwd = rot * vec3(0, 0, -1)
  world.setPosition(cam, (pos + look_offset) - fwd * camera_distance)
  world.setRotation(cam, rot)
end

return M