Using Daggerfall Imaging, the tilesets are TEXTURE.002-004 (desert), 102-104 (mountain), 302-304 (temperate), 402-404 (swamp). These tiles form everything you see on the ground in wilderness and towns. Each tile can be flipped, rotated or both.
These tiles are designed to fit together using marching squares
, an algorithm to follow contours using pre-made shapes. Compare the shapes below with the shapes above and you'll see the same patterns. This is what the lookup table is based on.
RMB (city) blocks have a bespoke tile layout by a human creator. All roads, parks, town squares, etc. are defined in the block data. When painting tiles inside locations, the bespoke data will always be used.
Out in the wilderness, you can paint tiles however you want by registering a custom implementation of ITerrainTexturing. Inheriting from DefaultTerrainTexturing
and overriding the virtual methods like in Basic Roads is the best starting point.
When DFU paints wilderness tiles, it will use the active ITerrainTexturing interface and ask it to supply a byte array for that block. This is done using the Unity job system, which complicates things a little, but the premise is fairly simple - populate an array with numbers matching the index and orientation of tiles you want to use.
The simplest implementation would paint the whole world using a single tile like dirt (index 1) or grass (index 2). This is the best place to start to make sure your ITerrainTexturing implementation is basically working. Then expand it to use another algorithm like a better version of marching squares.
Using my basic marching squares as an example, it creates a lookup table of tiles to suit the standard marching squares contours shown in image above. MakeLookup() is a helper method to set an index, rotation, and flip to a byte. Each tile byte uses the following bit setup.
Code: Select all
bits 0-5 tile index in TEXTURE.002, etc.
bit 6 set bit to rotate tile
bit 7 set bit to flip tile
The reason my algo is so basic is that it only supports contour adjacencies in a linear manner. For example, water>dirt>grass>stone. I'm not great with mathy concepts and I have to work hard just to create basic stuff like this, even with lots of examples out there to follow.
I don't recall classic using the full complement of tiles in wilderness either, it's a fairly simple implementation too. AFAIK the full tilesets are only used in locations. A better algorithm could support all the adjacencies in TEXTURE.002, etc, including those novel tri-part corner pieces.
The best advice I can offer is to start small and simple as possible. Paint the world completely in grass or dirt, or random tiles, then start working up from there. The standard marching square algorithm will yield results similar to classic and DFU, but I have no doubts someone brighter than myself could build a better algorithm to paint more interesting terrain tiles across the wilderness.
Alternatively, you could use some other solution to paint the world, like a splat map
. There's some support for this in the game now, TheLacus has a Splat Terrain Texturing
mod using splats instead of tiles. You could possibly even inject new materials onto terrain using a totally custom shader and solution, but you'd have to find a way to support towns as well.