I’ve discussed most of this on the DaggerXL forums already, but I’ve decided to make a full post in order to inform everyone else as well.
Version 0.14 Teaser
The build has had some delays, due to issues with time not technical concerns. Anyway the build is right around the corner – here are some teaser screenshots of a different climate (the desert). All regions and locations will be available in the upcoming version, including the Sentinel region shown below. I’ll talk about the terrain system more in the next blog post, but you can see the smooth terrain transitions between terrain and locations in the screenshots below, especially in the towns. This is accomplished by smoothing out the terrain around the locations, interpolating between the location height and the desired terrain height with a fade off based on 2D distance from the location boundary. In addition the terrain textures are matched to the edges, when possible. Also some of the flats are scaled wrong in the screenshots, I know what the problem is but haven’t fixed it yet. It will be fixed for the next build.
As I’ve discussed on the forums, after this build is released I’m planning on taking a break from the terrain system – roads, rivers, improved water and long distance rendering to the horizon will be implemented later. I will immediately begin implementing gameplay features, as listed in the 0.3 milestone in the Roadmap.
In order to test a variety of features and skills, there will be 4 default characters that you can choose from – starting in version 0.15 and beyond. These will include a mage type class, fighter type class, assassin and generalist. In addition the quick save will be extended to save the inventory, stats, skill levels and character level. As discussed in the Roadmap leveling will be implemented, proper skill use, spell system, ranged combat (bows), the remaining base enemies, proper loot, the remaining weapons and armor, the rest of the dungeons and more. Once the gameplay features for version 0.30 are complete I’ll finish up the terrain while people test out the everything else.
Stay tuned, there will another blog post in the very near future when version 0.14 is released!
It’s been a while since the last post, I went for about a week or so without being able to work on DaggerXL very much. Since then there has been some more progress on the terrain system.
The foliage positions are now generated directly from the terrain vertices. The effect of this is that foliage no longer shows up in location blocks, like it did sometimes before. It is also generated at the correct height now. You can see the effect in the screenshots below. Look at the hill in the background.
Locations & Collision
As before locations are still flat and the entire location is placed at the global altitude map height for that map pixel. This means that ground collision and Flat/NPC heights are adjusted accordingly. In addition the terrain now “connects” to the locations so that it is continuous. Right now it can be somewhat jarring, but I plan on smoothing out the transitions so that it looks natural. When the player walks on the bumpy terrain, the collision now works correctly. Rather then colliding with the polygons themselves, when terrain tiles are generated around the player the heights are saved. To figure out the height at the player’s position, the engine figures out which quad the player is standing on and determines the height using bilinear interpolation.
This turned out to be more of a task than I originally thought. Most engines have a few repeating textures and then some global blend maps (or vertex blending) to blend between them. Daggerfall had 56 tiles, all derived from 4 basic terrain textures (water, grass, dirt, rock – for temperate climates). The first thing DaggerXL does it pack these textures into an atlas for each climate. The engine automatically generates a small border around each texture by extruding the edges, so that filtering works correctly. As you’ll see later, I have to make the border larger, there are still artifacts (edges visible around the quads) at lower mip-levels.
Here’s the atlas generated for temperate terrain:
In order for each quad in the mesh to map to a different tile, extra vertices have to be generated (4 per quad) – though this doesn’t affect the polygon count or index buffer size. Anyway when each terrain tile is generated, a 16×16 tile index is generated, from which the texture coordinates are derived.
A screenshot of random texture tiles applied, just to verify the texture coordinates are generated correctly:
So the next step is to choose one of the base terrain tiles for each vertex, from which the final tile will be generated. The terrain tile index is generated from coherent noise, with probabilities generated based on altitude and proximity to the shore line. This means that each terrain cell can be generated independently and the textures still match up, as you’ll see later.
A screenshot of the base texture tiles being generated with no transitions:
If you look at the terrain atlas again, you’ll notice that most of the tiles represent transitions between different base tiles. For each quad, the base texture tiles generated for the 4 vertices making up that quad are used to determine the proper transition tile. Using Marching Squares, for a transition between 2 different tile types within a quad, there are 16 transitions (lines or curves if generating an isoline or isocurve). In Daggerfall, to preserve space, those transitions are generated from a much smaller set of tiles using horizontal flipping, vertical flipping and 90 degree rotation. So I pack the vertex base tile types into an unsigned long which then accesses a table that specifies the tile index, 1 bit for u flip, 1 bit for v flip and 1 bit for 90-degree rotation. The following screenshots show this off, however only transitions between grass and dirt have been finished, though the rest will be in soon.
I have to finish the terrain transition table, handle texturing along coastlines and then I can release the next version. 🙂