Astral Realms MS2,Terrain Paging and Artificial Environments

 

Just another update on my current projects. I have started doing some work on the next milestone of Astral Realms. I plan to put in an extensive "artificial life" simulator to make the game world feel more realistic. I intend to have elements like trees, plants, and shrubs that grow from seeds to seedlings, then to saplings, and then full size trees or plants. Players will be able to harvest seeds from the environment and plant them wherever they want, as well as use tools to cut down trees and clear a path through thick brush.

I am also thinking of including rivers that change direction, terrain features that erode over time, and weather effects which actually influence the environment, such as depressions in the ground filling when it rains hard enough, or plants withering and dying when there is not enough water.

This adds a lot to the "sandbox" stlye of Astral Realms, anything that can happen naturally, the player will be able to do as well. Players could use shovels to dig trenches and irrigation ditches, then use the water to grow plants, creating their own gardens or environments. They could create a line of trees to shield a village they are building from strong winds, or divert a river to protect it from flood waters.

In order to do this though, I have had to first work on the terrain system. The current T3D terrain system supports a maximum size of 4096x4096, which is just over four kilometers square (1 Torque unit = 1 meter). This is not enough for a game of the scale I envision, I really need some kind of terrain paging system, similiar to the old Atlas terrain. However, I need the ability to deform the terrain in real-time, something which wasn't possible with Atlas. I also need the ability to randomly generate terrains, since it would be impractical to create massive terrains by hand.

So, what I have done, or rather, what I am doing, is creating a "poor man's" terrain paging system. Conventional terrain paging is extremely advanced, and often used in RPG games. It essentially loads, or "pages" only the terrain pixels that are close enough for the player to actually see, and updates this list of visible pixels as the player moves. This means that the computer only has to render a very small subset of the terrain at once, the rest is stored on the hard disk drive, meaning the only actual limitation with most types of terrain paging is the users hard drive space. The terrain is generated from a "seed" value that is generated on the server and sent to the clients, because each client receives the same seed, the terrain they generate is exactly the same.

 

I don't have the time right now to create a fully-fledged paging solution, so what I have done is extensively modify the existing terrain system to do what I want. The conventional terrain system has the ability to generate a random terrain, so, what I have done is read a list of these random values into a float array the size of the terrain I want (I am shooting for a 16 km x 16km terrain at least, possibly more if I can get away with it). I then iterate through the float array in "chunks", with each chunk being less than 4096. These chunks are then read out into seperate files with a unique name specifying their coordinates in the larger pseudo-terrain. I then take the users position and, using a very complex algorithm that took some time to write, figure out exactly which terrains the player can potentially see from their position, and load them.
It has proven to be more complex than I thought, but it works very well, except for two major problems, which I am still trying to solve.
The first problem is that there is a visible "seam" where the individual "chunks" join up. This could be covered to some extend with art, such as vegetation, water, trees, etc, but not completely, and there is also some collision problems when passing from one chunk to the next.
The second problem is that generating and loading the terrains takes time, and while loading, the game freezes. This would not be so bad if it occured at the beginning of a level, but to happen seemingly at random (as far as the player knows) is a serious issue. I need to figure out how to load the terrains in the background.

I don't think the solution will be perfect, but it should satisfy my requirement for now, until I learn enough to implement a complete paging system. I have learned a lot from this project, and I think I could probably make something more complex now if I had the time.

I have included some pictures of my work so far, showing clearly the seaming effect between the chunks. I will probably upload this to GarageGames as a resource when it's done.



You must be a member of this blog to see the comments. Log in now!