Lighting the World

With the general shape of the background world in place, I started working on lighting it.  Most modern hardware (according to Irrlicht) supports eight dynamic lights, which just isn’t enough.  So, programmers use lots of tricks to support more than eight lights.  I decided to allow any number of lights, but only turn on eight at a time, based on what is currently being rendered.  For each object in the scene, the distance to each light is calculated.  The eight closest lights are turned on and the others are turned off.  The result is that only eight lights are ever actually “on” at any given time.  The result looks really nice in my test scene, I think.  If this approach doesn’t look right or isn’t fast enough as the scenes get more and more complex, I’ll have to investigate more complicated techniques, like, possibly, deferred lighting.

Creating the World

The World of Ladon is starting to take shape.  It’s a spherical world built from geometric shapes, mostly hexagons.  Hexagons are ubiquitous in Ladon.

working_in_flight

I was experimenting with constructing the sphere during a flight.  I ran into a problem that I should have seen coming, but didn’t — there is no way, mathematically, to tile a sphere with regular hexagons.  There are two approaches that come close, and each has advantages and disadvantages.

The first approach is to start with regular hexagons, tiled as they would be on a flat surface.  This is the common “honeycomb” pattern.  You can wrap this tiling around a sphere, but the hexagons will begin to overlap.  You can correct for this by changing the size of the hexagons as you go, but, depending on which way you choose to do the wrapping, you will run into “poles” at some points on the sphere.  At these points, your hexagons will essentially vanish to zero.  This is exactly the same problem that mapmakers encounter — the reason why Greenland appears to be as big as Africa on a map, even though Africa is about 14 times larger in reality.  By breaking the map up into sections, as mapmakers have done in different ways for a very long time, this approach can be fudged enough to work.  If your sphere is large enough, the viewer will probably never notice the difference.  Some of your hexagons just have to be slightly distorted.

The other approach is more mathematical.  A sphere can be “tessellated” into triangles.  You can then group these triangles into hexagons.  The big drawback to this approach is that none of the hexagons are regular.  They’re all distorted pretty heavily.  And worse, there are exactly twelve locations on the sphere that aren’t hexagons at all, they’re pentagons.  The most familiar way to visualize this is a soccer ball.  No matter how small you make the tiles, those pentagons don’t go away.

hex_tiling

The above image shows the two approaches side by side.  The regular hexagons on the left begin to overlap as they bend around the sphere.  The tessellation on the right fits together perfectly, but is made up of very distorted hexagons with a pentagon in the middle.

The problem with the distortion, in either approach, is that our 3D modeler needs to be able to crank out these hexagonal tiles.  If they aren’t all the same shape, roughly, then he’ll have to model each one individually!  I don’t think we pay him enough for that…