Level Editor

I started toying with the idea of building an integrated editor in my game project. Due to the way I have my game layer separated from the application layer I realized I might be able to fit an Editor layer between the two to manage additional UI elements.

I’m starting off by trying to get a floating toolbar to create and hide itself, and then show\hide it when the user pauses the game. I’d like to start off with axis aligned brush placement, light placement and see if it feels like a good path to go down or not.

I am a little intrigued by how the integrated editor might force certain architectural changes in the game and engine objects. I’m not sure if the editor will poke actual game data, or if it will manipulate editor objects that are transferred when the user resumes the game.

I’d also like to keep the editor functionality somewhat isolated so that I can layer it over other game projects as part of the engine package.

I’ll post a screenshot once I get pause, resume, and toolbar working.

Oh right… from my Volition work, I actually have a fair amount of experience writing editors, unlike shaders :) Though I have no experience with integrated editors.

Getting Closer

I have a shader up and running that supports Phong shading. So far it only supports a single directional or point light. The results are exactly what I was originally hoping I’d get out of the fixed function pipeline. Of course, now that I’ve got simple shaders working, I realize that I could have turned on fixed-function Phong shading (I think). Regardless, now that I’m over the hump, I’ll stick with the programmable pipeline for now.

I was able to rip out the D3D material implementation since I no longer need to pass in a custom class. The fewer one-off classes I have to maintain, the more time I can spend on meaningful improvements. I’m now passing material data directly in to the shader.

I suppose next I need to figure out how to support multiple lights. For the time being I’m going to stick with DirectX 9.0c and HLSL2.0. I also want to get texturing turned back on soon, which will require improving the Blender static mesh exporter.

I’d also like to be able to position point lights in the level geometry using Blender if I can attach metadata for range, color, attenuation, etc. If not it might be time to start thinking about a simple level editor (yuck).

Two Directional Lights and Fog

Here’s a simple fixed function lighting setup that I think is a good starting point for my upcoming level geometry experiments. I’m going to move forward with this for now.

Directional lights dodge the point light vs. vertex lighting issue by outputting the same color for coplanar verticies, so there’s no ugly interpolation. Here I’m using two directional lights pointing in opposite directions.

A bit of an impasse

So I have two issues with my recent level geometry experiments:

  1. Point lights with vertex lighting looks terrible.
  2. There are some visible seams between prefabs.

I’m not quite sure how to deal with either of these yet so I’m trying to work through my options. My past games using the engine have been based on smaller objects that are far enough away from the camera to avoid close scrutiny. Level geometry is new territory for me.

With the point lighting issue I can subdivide my geometry more, but that still doesn’t look great. The other option is per pixel lighting. If I stick with a fixed function pipeline I should be able to use bump mapping and\or lightmapping. My main reason for wanting to stick with fixed function is to support older iOS devices. At the same time, half the reason for writing all of this stuff myself is to learn, and I should probably be learning modern techniques…

With the new engine architecture I could easily create fixed function and programmable implementations of the rendering engine, but that goes against my desire to keep things low maintenance. I could keep the iOS implementation fixed function and switch the Windows implementation to programmable… that’s an option. I’ll have to decide if I’m okay with the divergence.

As far as the prefab seams go, after I built the level geometry from my previous post I had all kinds of inaccuracy in the vertex coordinates – they weren’t perfectly grid aligned, so there were a lot of seams. Last night I figured out a Blender technique to alleviate this, so I rebuilt the geometry from scratch. It went must faster this time. Now the verts are perfectly grid aligned in Blender, but in engine there are seams between some prefabs. I still need to verify that the engine is storing the coordinates without floating point errors.

I could merge the verticies, but then the vert normals would be averaged and shared, which means I won’t get sharp edges on corners, again due to vertex lighting. I guess per pixel lighting would solve this problem too, but it would require that I merge my prefabs before export. I’d rather figure out how to get DirectX to draw the seams accurately.

Anyway, those are the issues I’m trying to work through. We’ll see what happens.

Light Manager

I got the light manager back in place. It’s nothing fancy but it allows me to manage different hardware lights and continue to manipulate their parameters after initialization. The interface can also be implemented by D3d or OpenGL ES 1.1. I probably won’t write the OGL implementation until the next time I do a maintenance pass for iOS.

Here’s an in-game shot. This makes it pretty obvious that the normal data from Blender needs some work. That’ll be the next step.

The engine is entirely fixed function. I’m not quite ready to abandon older iOS devices just yet.

Map Loaded

I got the 2-room + arched hallway map prepped and loaded. I had to modify the static mesh exporter to ditch the x16 scale that I was applying. I think I’ll set that up as an option.

In-game the lighting looks terrible so I need to spend some time making it look at least presentable. A couple of old systems like the light list manager were removed some years ago and never replaced. I’m glad I finally have a reason to re-implement one of them.

It’s also pretty clear that exporting to a .map format of some kind would be pretty useful rather than making the whole level a collection of individual static meshes. It would be nice to be able to place lights in Blender and save them out to a .map. That kind of information doesn’t make much sense in the context of a static mesh file.

Blender Prefabs

I’m learning how to lay out levels with prefabs in Blender. I found a good tutorial here: http://www.katsbits.com/tutorials/blender/map-basics-tutorial.php

From what I’ve read UDK games are shifting away from brushes and are mostly custom static meshes, but it sounds like designers still use brushes for a first pass.

I have no plans right now to make a map compiler, and I don’t even know if that’s still part of modern 3D engines. I get the impression it’s going away. Regardless, these prefabs are exactly what I want to work with to get a feel for level metrics and flow.

I thought I would go ahead and make these two rooms connected by the hallway as described in the tutorial, and then go a step further by making a passage under the floor that lets you crawl between the two rooms, possibly with a flooded section.

The units used in this tutorial are different from what I’ve been using. I have to decide if I want to remove the scale factor from my static mesh exporter, or scale the level down. I kind of like this because it’s 1:1.

This tutorial also touches lightly on using helper objects for “info_player_start”, etc. I’m pretty interested in doing something like that instead of hard-coding my player’s start position. Though, I don’t know that I want to detour that long in order to make a .map system. We’ll see.

Several months back I downloaded the Fallout mod kit. I think the modular static mesh approach that they use in their map editing is pretty interesting. It’s a more basic approach than I would have guessed by playing the game.

The interesting thing is that the old King’s Field games used the same approach. Those were the forerunners to Demons\Dark Souls games. I don’t believe the Souls games use this approach anymore though. I saw a model viewer that someone put together and it looked like continous meshes.

I don’t recall if I’ve mentioned it, but Shadowgate, King’s Field, and the Souls games all have an intense level of atmosphere that I’d be interested in experimenting with.

Blender Refresher

About a two months ago (give or take) I started learning some very basic Blender modelling. It was necessary for creating test data for my static mesh exporter. After that I started toying around with my basic collision stuff because I wanted my “player” mesh to stand on the floor with gravity applied.

While doing the collision work I could feel my recently acquired knowledge of the Blender interface slowly slipping away. To remedy that I’ve spent some time over the last couple of evenings reacquainting myself to Blender. This time I got a little deeper in to manual edge and face generation. That process caused a lot of degenerate geometry, so I also got to learn how to clean up geometry and make it viable in the engine.

Below is a 1st and 3rd person screenshot of the results. I know this isn’t too impressive, but just remember, I’m a programmer, not an artist : ) Also, I only have a collision mesh defined for the ground – nothing for the walls.

I’ll probably continue with Blender work for a couple of days. Now that I got this all working I’d like to try again and see if I can expand on it more efficiently. I’d like to be able to “green box” a small play space with as little effort as possible. I was thinking about making a palette of block prefabs that have collision meshes attached, and just building those up in Blender to make a small play area.

I’m already using units and grid snapping setup for Unreal, so the prefab thing should allow me to slam stuff together pretty fast.

I’ve been giving some thought to game concepts. I mentioned my interest in exploring clostrophobic spaces. That’s a theme that keeps resurfacing with me so I think there might be something unique there to drive motivation. We’ll see. Maybe I’ll put some crawl spaces in the floors that connect two buildings together.