Shadows

Planning and Development

I saw first-hand today something that I already knew.  Shadows are expensive.  One of my test machines is an old PC currently running Ubuntu 18.04 LTS.  It has an Intel® Core™2 Duo CPU E8500 @ 3.16GHz and 8GB of RAM.  Needless to say, this isn’t a powerful machine.  The processor scored a 2286 on the Passmark benchmark test.  By comparison a $1,000 gaming PC you can buy on Newegg right now has an Intel® Core™ i7-8700K @ 3.70GHz with a score of 16034.  And that’s completely ignoring the graphics card.  My point is, if the game will run on this test machine it should run just about anywhere.  Without shadows I get 20-25 FPS on a 1920×1080 monitor.  If I knock that down to 1024×768 I get about 40 FPS.  If I turn on shadows, however, my FPS at 1920×1080 is around 5.  5 FPS!  If I size the window to 1024×768 it shoots up to about 12.  This is why I want to build the game from the ground up to be as configurable as possible by the players.  If you want fancy effects and have a fast computer, go for it.  If your machine is kind of old and you don’t care so much about the visuals, turn them off.  If you have a clunker but want to see all the cool effects and don’t mind a horrible frame rate, jump right in!

This will take some effort throughout development but I think it’s worth it to give players some control over their own experience rather than dictating a certain set of hardware requirements to enjoy the game.

Next steps

Planning and Development

These are things that need to be implemented in Lyridia, in no particular order.  I’m just putting them here as a reference so I can think about how I want to proceed.

  • Collision detection
  • NPCs
  • Enemies
  • HUD
  • Better camera controls
  • Multiplayer

This is a short list of some very big items.  Each will need to be broken way down but this gives me something to be thinking about.

Demo scene planning

Planning and Development

I’m happy with the world editor for now.  I need a working version of the game so that I can see what the world actually looks like from a player’s perspective so I can tell how to add assets to Penrith Forest.  It’s really easy for me to end up creatively paralyzed in situations like this so I’m going to get a basic “walking around” demo done then just start adding stuff.  If it’s bad I can take it out or change it, but without something to start with I’ll never get close to a finished product.  It may take me a few days to get the demo done but when I do it will be the very first version of the game and future versions will just be incremental improvements to that base, so I’m looking forward to that.

World editor lighting

Planning and Development

Messing with point lights is becoming a pain so I’m going to shelf it for now.  It will be an important feature eventually, but for outdoor scenes lit by the sun other lights are not really noticeable anyway.  I’m going to create a few more small assets for Penrith Forest then put them in the world and edit the terain to fit around the assets.  Then I’ll put together a very, very simple demo that will be the very first early alpha version of Chronicles of Tright: Lyridia.

Better lighting, etc.

Planning and Development

Here’s the latest:

You’ll notice a few things.  First, the scene is just much brighter overall.  I bumped up the ambient light by a good bit and darkened the material on the terrain so it wouldn’t look blown out by the brighter lights.  Also, SHADOWS!!  THREE.js is so awesome.  Adding the shadows to a directional light took a little bit of fiddling but overall it was actually quite easy.  The shadows do affect performance.  You can see in the FPS counter I’m down to around 50 frames per second with this simple scene.  I want the game to be able to run on very low end hardware so users will need the ability to disable the shadows, but my goodness does it make a difference in the overall look and feel of the game.  I absolutely love that objects even shadow other objects, so you can see the shadow of the tree on the left hand side of the screen partially covering the crate.  Just absolutely fantastic.

Some notes on implementation.  To keep the shadow map relatively small the directional light that is the sun now moves whenever the camera pans.  This means you will never see shadows more than about 50 meters past the camera’s target, but who cares?  This is also totally configurable so if a player has better hardware maybe that distance could change automatically to show shadows farther away.  I also added in the ability to remove objects from the world.  That was, as expected, quite simple.  You can also now toggle viewing the light helper objects so that if you want to see a directional light’s position and orientation, just hit ‘l’.  But most of the time that just gets in the way while editing so you can hide it.

That’s it for now.  I’m really happy with the better lighting.  I think the next step is to allow live editing of the lights in the scene.  Right now you can see the lights through the associated helpers, but you can’t actually select them and move them around in the world editor.  If I’m going to have lamps with individual lights in them or any other kind of somewhat complicated lighting in a scene I’ll need some better tools to place and move lights around.  Oh, and I’ll keep creating assets for Penrith Forest.

Penrith Forest

Asset Spotlight, Planning and Development

It’s kind of weird to call this a “forest” because there are zero trees so far, but here you go:

The lighting is bad but you can at least sort of make out the farmhouse, a crate, a wheelbarrow, and a lamp post.  All of these objects were added to and saved into the scene by the world editor.  I moved them all into place and rotated them around to look the way I wanted.  Again, this was all done in the world editor!!  You can still see the purple test boxes because I haven’t put in the object removal functionality yet, but it’s coming.  This also demonstrates how important light editing features are going to be.  All in all I’m so excited to be at this point.  The world editor’s controls are a bit awkward but the whole thing absolutely works and that’s the part that’s important for now.

Editor improvements

Planning and Development

As per my last post, I have changed the selection tool for terrain editing into a sphere.  It makes so much more sense to do it that way, and took about 10 minutes to change.  I have also changed the functionality so that editing the terrain is a “click-hold-drag” process instead of single clicks.  This gives much more control over the process.  Because of that I was able to change the amount that each update changes the terrain’s height down to 0.01, from 5.  Again, this is a much, much finer control for editing terrains.  I have put in a selectionStrength variable that I will eventually be able to change to affect how much or how little dragging across the terrain should affect it, but for now it’s just nice and slow.  When in terrain edit mode you can scroll the mouse wheel to make the selection sphere bigger or smaller, like this:

Small Selection

Big Selection

Overall I’m really happy with where I am right now.  I still need a way to remove objects from a scene but that’s such an easy thing I’ll probably save it for later and start creating accurately scaled assets for Penrith Forest.  I’ll probably take a few days to get a basic set of objects together then provide at least a screenshot of the area in the world editor, and eventually a demo you can run around in.

World editor update

Planning and Development

Here’s the latest scene from the world editor:

You can see a few objects I’ve added and the terrain is a bit of a mess, but the point is to show that with the world editor I can now edit the terrain pretty easily.  The terrain moves up and down in increments of 5 meters at this point and that will change eventually but it’s really pretty simple to modify terrain at this point.  Just click or shift-click and it moves.  Easy peasy.

I need to change the selection tool from an big elongated cone into a sphere, and I would like to be able to just click and drag to move terrain, but I may save that improvement for later since it actually works pretty well using discrete clicks.  Scale is going to be important here.  Once I get some objects in the scene it will be easier to model the terrain around them because right now each click moves the terrain up or down by 5 meters.  That’s a really big jump but with the camera zoomed out to see almost an entire 1,024 meter x 1,024 meter block, smaller changes are not noticeable.  However, once there are houses and trees and fences and other objects in the scene, it will be easier to model the terrain in a way that make sense at scale.  That’s just hard to do without correctly scaled objects in the scene to use as a reference.

One other feature I’m finding I will need eventually is a scene explorer.  That is, a text listing of all of the objects in a scene.  As it is now, if I have an object in the scene but it’s hidden underneath the terrain or inside another object there is no way for me to select it to move or delete it.  This may not be a huge deal since I can always just edit the .json file directly, but it’s probably worth implementing sooner rather than later just to keep things clean.