0

Background information

I am in the process of making a game engine so I have complete, explicit control over everything, anything is an option. I desire to make procedurally generated 3D terrain. It's mostly coming along quite well actually.

I am however, having a difficult time finding any good information on how exactly destructible terrain can be done optimally. I think the mesh deformations could be done at run-time and written to disk but the issue I encounter there is the desire to have ore and similar resources under the ground. I've had the idea to layer additional maps for each unit length of depth but that just seems like it'd have a heavier impact on performance than I'd like.

I know it's of course possible to do that but how to do it efficiently is what I'm interested in here. Perhaps I'm just using bad keywords when I search for information but I'm not turning up much of anything of use on this topic.

I've gone beyond just Perlin Noise for the generation as well using various other algorithms for layers such as vegetation, ground cover like small rocks, etc. By generating the texture maps using the techniques I'm sure we're all familiar with.

A lot of the ideas I've been coming up with would work I suppose but I don't like the obvious impact of performance my ideas have been so far.

Eventually of course I'd have a layer of solid indestructible bedrock but I can't figure out a way better than having a texture map for each layer down per unit length. So if I had a depth of 60 units before hitting the layer of solid bedrock that would mean 60 texture maps. I don't like that at all. Surely there is a better way. I've seen a lot of games not render or even generate the underground at all during initial creation of the game world and do that at run-time but I can't figure out how ore and similar resources could be generated in varying depth layers effectively on initial creation of the world. If the map is color coding by resource it wouldn't exactly work to also color code the height as you would with a height map. It must be one or the other.

Question

The problem I'm having now is underground. What would be the best way to implement underground layers in a performance friendly way that doesn't involve an excessive number of textures used?

  • I think we need some more information on your game for this. Is it 3D? Voxels, meshes? Voxels are the typical way to go for 3D terrain deformation, but modelling ores and such underground as meshes might be possible if you set your mind to it. – Omegastick Nov 13 '19 at 08:59
  • It's actually for a custom engine similar to something like Unity but something we feel will work better for us (leaving opinions out of it). It is 3D mesh terrain. I am certainly willing to put in the work to make it work well. I already have Biome and Temperature/Climate mapping and all those features you'd expect to see in realistic terrain sorted out for the surface quite well. If I need to clarify on anything else let me know. – Hawkeye4040 Nov 13 '19 at 09:06
  • If it's meshes, then what's the problem with using 3D perlin noise to put some ore/cave meshes underground? – Omegastick Nov 13 '19 at 09:13
  • 3D Perlin Noise is a very attractive option for this. I can see how I could layer that with other noise as well fractal I could see being used. What about saving to disk? That should just work out like any other mesh then and that would nullify the need for layered textures right there.

    This might take a little more though but off the top of my head I don't see anything with that that'd conflict with the existing surface maps I mentioned before, height, biome, temperature, etc.

    – Hawkeye4040 Nov 13 '19 at 09:19
  • It is a little tricky to figure out how to map the resources locations and store those to disk unless the best idea I have for that is having them as a child entity of the terrain (Custom ECS implementation as well). I have the rule sets in the base class for said resources that specify biomes, minimum/maximum depth, buffer radius between similar deposits, etc. – Hawkeye4040 Nov 13 '19 at 09:24
  • If you're doing deformable mesh terrain, AFAIK there's no way around saving the meshes themselves to disk (which is obviously gonna be a big disk-hog). Maybe you can do something clever with only saving the altered meshes to disk and recreating the others from scratch (given the seed) every time you load the game. – Omegastick Nov 13 '19 at 09:29
  • The altered mesh trick I have seen done before in a meaningful way in many games. Perhaps the ores can still be mapped on world generation and simply not rendered. Maybe this could be done at run-time with the ores too since they do have the rules stored in the resource definition class. That might actually work and not be too excessive on the disk, I think it'll work in my favor that most gamers out there have Solid State Drives now too. – Hawkeye4040 Nov 13 '19 at 09:36
  • Have you researched how existing games of this nature solve the problem of generating underground content like ore locations, and culling it from being rendered when out of view? "Most efficient" is probably not something you will find (very few gamedev techniques have optimality proofs), but "efficient enough to ship one of the top-grossing games of all time" might well be good enough for your needs too. ;) – DMGregory Nov 13 '19 at 10:24
  • These links are very helpful. I did find some good stuff in my research for various other parts but just could not find much useful information on the underground topic. I also agree with efficient enough, I'm sure like most things I'll figure out how to better optimize it over time

    As Alexander Calder said, "To an engineer, good enough means perfect. With an artist, there's no such thing as perfect."

    – Hawkeye4040 Nov 13 '19 at 10:36
  • I saw the other post Why is it so bad to optimize too early?. That brought up some great points as far as strategy here. To clarify I am perfectly okay if it runs clunky in the debugger the first time I try it, in fact I fully anticipate that. As long as I can get it where I want it to ship that is what matters here. – Hawkeye4040 Nov 13 '19 at 10:42

0 Answers0