View terrain at any distance

For people working on the C++ code.
Post Reply
User avatar
MisterE
Member
Posts: 693
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

View terrain at any distance

by MisterE » Post

Would this be easy/possible to implement?

The idea is shamelessly taken from veloren
Image
https://veloren.net/

Veloren only recently implemented viewing terrain at any distance.

Some rough ideas of how it could be done: either save map data as the server loads it, or generate a preview from the seed. The goal is to get: 1) approximate average color of the nodes (pixels), and 2) height map of the terrain. Then, a simple pixelated image of the terrain color is mapped to a mesh of he terrain height and this is displayed in the distance. Each mapblock in the distance is its own rough mesh and image, and these are generated when the map is loaded, saved by the server, and sent to clients if/as they request them. When I say mesh, I mean a very rough mesh to save data. The trees and buildings, for example, should not be included. Basically, the mesh approximates the shape of the base terrain. As a player gets close to a mapblock, the mapblock is loaded, and details become visible like normal.

Infinite viewing is not necessary... just, send a large viewing range using this method would do.

User avatar
freshreplicant
Member
Posts: 224
Joined: Sun Aug 09, 2020 10:37
In-game: freshreplicant

Re: View terrain at any distance

by freshreplicant » Post

I think I saw a video about this being implemented in Veloren the other day actually. I don't have the technical know-how to weigh in, but from a users perspective this would be amazing.

User avatar
Linuxdirk
Member
Posts: 3216
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: View terrain at any distance

by Linuxdirk » Post

This actually was in the game once and was called "farmesh" but it was removed for some reason.

User avatar
MisterE
Member
Posts: 693
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: View terrain at any distance

by MisterE » Post

Looking up farmesh, it looks like it was a good start, but go abandoned. It really would be nice for core devs to have another go at it

User avatar
v-rob
Developer
Posts: 970
Joined: Thu Mar 24, 2016 03:19
GitHub: v-rob
IRC: v-rob
Location: Right behind you.

Re: View terrain at any distance

by v-rob » Post

Part of the problem with the farmesh is that it only previews generated terrain. If your map has a gigantic city or a huge crater from TNT blasts, the farmesh would only show what the map originally looked like. For small-scale buildings and suchlike, this isn't a problem, but largely modified maps aren't represented well.

Plus, the farmesh was from when nodes were hardcoded. Some more work would be necessary to make it work with Minetest's greater game versatility now. Even more so, the farmesh could only accurately (ish) represent 2D noise mapgens. 3D noise don't look quite right with the farmesh. Lua mapgens, which AFAIK can't be pre-generated, present even more of a problem.

So, while I do like the farmesh (when I occasionally play 0.3.1, I almost always turn it on), it presents a lot of problems for modern Minetest, and some thought would be necessary to reimplement it in a usable way.
Core Developer | My Best Mods: Bridger - Slats - Stained Glass

Dragonop
Member
Posts: 1233
Joined: Tue Oct 23, 2012 12:59
GitHub: Dragonop
IRC: Dragonop
In-game: Dragonop
Location: Argentina

Re: View terrain at any distance

by Dragonop » Post

v-rob wrote:
Wed Jan 13, 2021 18:02
Part of the problem with the farmesh is that it only previews generated terrain. If your map has a gigantic city or a huge crater from TNT blasts, the farmesh would only show what the map originally looked like. For small-scale buildings and suchlike, this isn't a problem, but largely modified maps aren't represented well.
Still better than a window into the cyan void, just hide it under some fog

User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: View terrain at any distance

by rubenwardy » Post

As well as farmesh, there's also farmap which was level of detail based - you'd see actual things in the distance at a lower resolution

Bedrock supports massive view ranges without these tricks which look terrible
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
AspireMint
Member
Posts: 415
Joined: Mon Jul 09, 2012 12:59
GitHub: AspireMint
IRC: AspireMint
In-game: AspireMint
Location: Stuck at spawn

Re: View terrain at any distance

by AspireMint » Post

Idea: If you could edit mapblock (not in db), before it is sent, maybe it would be possible to view things in distance.
I mean, remove nodes that are not visible but still rendered in client which slows down things,
replace nodes that has running jobs (abm) or mesh to dummy nodes, or remove unnecessary blocks,
and just send "shell" (eg. dirt_with_grass blocks, not dirt lying under it).
And level of modified mapblock would depend on player settings (low-end device friendly).
So something like this: minetest.on_send_mapblock = function(player, mapblock) should return modified mapblock
(settings - player:get_mapblock_settings() ?)

User avatar
MisterE
Member
Posts: 693
Joined: Sun Feb 16, 2020 21:06
GitHub: MisterE123
IRC: MisterE
In-game: MisterE

Re: View terrain at any distance

by MisterE » Post

Here is an idea for how to achieve near-infinite view distance. Clients are sent the regular chunks. Then, all around their normal view distance, the engine generates "horizon chunks" and sends them to the client. What it does, is for every mapchunk around the normal view range, it generates a large voxel that has a height that represents the average height of the landscape there, and it generates a texture based on the textures of the blocks there. It only uses solid colors, but maybe it averages each texture's color, and makes that the color of a pixel in the generated texture. So, in the distance, you would see a large mountain made up of a few giant voxels.

This is not an original idea.

https://devforum.roblox.com/t/open-sour ... tem/355090

User avatar
Gael de Sailly
Member
Posts: 845
Joined: Sun Jan 26, 2014 17:01
GitHub: gaelysam
IRC: Gael-de-Sailly
In-game: Gael-de-Sailly gaelysam
Location: Voiron, France

Re: View terrain at any distance

by Gael de Sailly » Post

MisterE wrote:
Tue Mar 23, 2021 16:21
Here is an idea for how to achieve near-infinite view distance. Clients are sent the regular chunks. Then, all around their normal view distance, the engine generates "horizon chunks" and sends them to the client. What it does, is for every mapchunk around the normal view range, it generates a large voxel that has a height that represents the average height of the landscape there, and it generates a texture based on the textures of the blocks there. It only uses solid colors, but maybe it averages each texture's color, and makes that the color of a pixel in the generated texture. So, in the distance, you would see a large mountain made up of a few giant voxels.
That sounds interesting, but I think there is another limitation, which is that the server would need to prepare these horizon chunks, and would need to access many chunks at once, located far from each other, which is very costly in file reading and RAM. But who knows, somebody may come with a strategy to overcome this :)

I have a straightforward question/suggestion: what about just rendering the nodes as solid colors past a certain distance? Would it speed up client-side rendering? It won't load map farther but maybe it could allow to increase the viewing range without lag.
Just realize how bored we would be if the world was perfect.

x2048
Developer
Posts: 68
Joined: Mon Feb 15, 2021 22:41
GitHub: x2048

Re: View terrain at any distance

by x2048 » Post

Gael de Sailly wrote:
Thu Mar 25, 2021 23:41
I have a straightforward question/suggestion: what about just rendering the nodes as solid colors past a certain distance? Would it speed up client-side rendering? It won't load map farther but maybe it could allow to increase the viewing range without lag.
The problem here is that in order to render the nodes as solid colors you need to load these nodes from mapblocks, first at the server, then transfer to the client and then generate meshes at the client. Loading, transferring and keeping a large number of mapblocks in RAM is the biggest problem here, not generating simple meshes or textures.

Here is what could be done to solve the problem: server maintains a sector-scale height map (e.g. 16x16 floats per sector) that can be rebuilt lazily (e.g. every 1000 digs in a sector) and transferred to the client in a separate packet, that would allow for efficient rendering of horizon and blend nicely with level-of-detail work already discussed by the coredevs.

This approach assumes classical continuous terrain and does not account for usecases with e.g. asteroids, floating islands, skyblocks etc.

The storage costs would be additional 1K (16x16x4bytes) per map sector.
And, for example, transferring horizon with a thickness 2 sectors at the default view distance of 24 sectors would require 2x4x24x1Kbytes = 192Kbytes per player. Moving a sector ahead adds 24sectors to the horizon or 48KBytes of network transfer per player per sector of movement.

This is at 1-node precision and without any color information and can be quickly reduced, for example, 4x4 heightmap per sector costs 64bytes, which would result in 12Kbytes transfer to load perimeter and 3Kbytes per sector crossed, giving room for more distance viewing ranges, encoding color information etc.

From implementation perspective this requires:
* Extension of the map format to include the heightmaps
* Some serverside process to kepp the heightmaps up to date without taxing CPU too much
* New network packet to transfer heightmap to the client
* New datastructures and process in the client to visualize the heightmap at the horizon

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests