Monday, April 13, 2009

Wilderness Generator


Working on the wilderness generator. For now, I'm re-using the tile types from the overmap, although soon I'll whip up a new set that is more suitable for the lower level of zoom. I'm working out the 'look' I want for the object sprites that populate wilderness levels; in this shot you can see a few of the tree sprites I've created as a test. I plan to incorporate various vegetation sets depending on the geography of the submap; beach-type vegetation, deep forest, savannah, etc...

In the overmap, parameters are assigned not on a tile basis, but on a per-vertex basis. It's a bit hard to explain, but I assign a particular terrain type to each corner of a tile, then generate the tile graphics for a tile based on the vertex corner pattern. This has the effect that, at places where two or more types of terrain meet, that tile will represent a transitional region and the sub-map needs to be generated accordingly. Right now the wilderness generator just does a random scatter, but I am working on parameterizing it and splitting the submap into quadrants, with turbulence applied to the quadrants, then generating each quadrant according to the parameters of the associate closest vertex.

The wilderness generator is intended to be very generic. Nothing special is generated as a result of it; no caves, no towns, no encounters. Just terrain. The generator is called with a seed (derived from the world seed, plus an offset based on the tile coordinates) and the parameters for the four corners, and spits out a wilderness map to suit. In later iterations of the game, some tiles will be flagged as special, with special rules for generation. These will generate the areas where stuff happens, like towns and dungeon entrances.

Randomized encounters (also known as ambushes) are created based upon the underlying generic wilderness submap.

Last night I worked on the asset pipeline for creating submap sprite graphics. Objects are modeled and rendered in Blender. I do the rendering in 2 stages; first stage to generate the colormap for the sprite, on a transparent alpha background; and second stage to generate the shadow. I special Lua script combines a colormap and a shadow layer into a single alpha-mapped sprite that can be drawn in the game. I'm currently tweaking the lighting parameters for the best effect.

The trees in the above shot were procedurally generated using an L-system script for Blender. The script is old, but still works with my newer version of Blender+Python. It's a fun little script, and while the interface is confusing (all those buttons and sliders; crikey) the supplied .DEF files provide good starting points to work from. L-systems are pretty neat, if you haven't looked at them. A bit confusing, but once you've wrapped your mind around them, they are a fantastic tool for proceduralizing naturally occurring fractal-type shapes such as trees and other vegetation.

No comments: