PorkStudios / FarPlaneTwo

Level-of-Detail renderer in Minecraft. Allows for render distances of millions of blocks. (Cubic Chunks-compatible) (WIP)
https://daporkchop.net/
Other
1.45k stars 50 forks source link

Allow the mod to run client-only #78

Open byalvaroft opened 3 years ago

byalvaroft commented 3 years ago

Hello, I really like this mod, its anyone's dream to load chunks really far away without taking a huge hit in performance. Last year I had the idea to look for a mod to add chunk caching so when you enter a server, the chucks that are too far from a player to be streamed by the server, are loaded from a cache that is built from previews logins to the server....

I could not find any mod that does this specifically but I managed to modify some of the code of a mod called Baritone, Baritone has a cache feature that is used for pathfinding to aid it´s bot features, it does not save the chunks as a world downloader would, it only registers them as a solid blob of grey (I think only of the surface blocks) and saves them locally as a file that can´t directly be opened in single player of turned into any sort of schematic.

I went ahead and (with my really low level java experience) got rid of some parts of the code that enables Baritone´s other features, this was done for performance reasons and because they are not useful for what I want. I also added some lines of code that tell the chunk packer to keep information about the main blocks used for terrain and building so that when the chunks are loaded, they are textured.

This is the result: https://www.youtube.com/watch?v=OeCEItONFGo

The mod updates the packed chunk cache with the newly streamed chunks constantly so the 10 chunk radius is always accurate.

I found the results really promising but I don´t know how to take this any further, I am not a programmer, and although it looks really nice, there are memory leaks that make the game crash some times that I don´t know how to fix.

I am showing you this because I think this because I think this could be a really nice addiction to your mod, being able to instantly load chunks when going into a world or a server would be insane, specially when combined with the performance gains this mod gives.

DaMatrix commented 3 years ago

that... really wouldn't add any value in fp2's case. once the low-resolution terrain data has been generated, it loads practically instantly, with the main bottleneck being the client's CPU.

Ember-ruby commented 3 years ago

Hello, I really like this mod, its anyone's dream to load chunks really far away without taking a huge hit in performance. Last year I had the idea to look for a mod to add chunk caching so when you enter a server, the chucks that are too far from a player to be streamed by the server, are loaded from a cache that is built from previews logins to the server....

I could not find any mod that does this specifically but I managed to modify some of the code of a mod called Baritone, Baritone has a cache feature that is used for pathfinding to aid it´s bot features, it does not save the chunks as a world downloader would, it only registers them as a solid blob of grey (I think only of the surface blocks) and saves them locally as a file that can´t directly be opened in single player of turned into any sort of schematic.

I went ahead and (with my really low level java experience) got rid of some parts of the code that enables Baritone´s other features, this was done for performance reasons and because they are not useful for what I want. I also added some lines of code that tell the chunk packer to keep information about the main blocks used for terrain and building so that when the chunks are loaded, they are textured.

This is the result: https://www.youtube.com/watch?v=OeCEItONFGo

The mod updates the packed chunk cache with the newly streamed chunks constantly so the 10 chunk radius is always accurate.

I found the results really promising but I don´t know how to take this any further, I am not a programmer, and although it looks really nice, there are memory leaks that make the game crash some times that I don´t know how to fix.

I am showing you this because I think this because I think this could be a really nice addiction to your mod, being able to instantly load chunks when going into a world or a server would be insane, specially when combined with the performance gains this mod gives.

Like the mod bobby?

byalvaroft commented 3 years ago

that... really wouldn't add any value in fp2's case. once the low-resolution terrain data has been generated, it loads practically instantly, with the main bottleneck being the client's CPU.

Not in terms of performance of course, the value is in not having to walk to load those chunks every time you load the world or enter a server. Specially those with really low render distance.

If I am not mistaken fpt only keeps the low resolution chunks until the world is closed or you leave the server. My suggestion would be to keep a cache of low resolution terrain so no movement is needed to see your whole world or the server world on login.

CursedFlames commented 3 years ago

If FP2 is on the server, the mesh data is sent immediately anyway. If it's not, FP2 currently doesn't work AFAIK; making it work as a client-only mod would be doable, but Pork has said it's low-priority since "you'd only be able to see places you've already been to, so it'd just be a bunch of giant lines in the distance".

DaMatrix commented 3 years ago

you don't have to load distant terrain in order for it to be visible - otherwise i would have had to explore the entire world in order to capture this. fp2 implements a totally separate system for storing and tracking low-resolution terrain tiles, unaffected by the vanilla render distance option.

low-resolution terrain is stored persistently on the server.

byalvaroft commented 3 years ago

Hello, I really like this mod, its anyone's dream to load chunks really far away without taking a huge hit in performance. Last year I had the idea to look for a mod to add chunk caching so when you enter a server, the chucks that are too far from a player to be streamed by the server, are loaded from a cache that is built from previews logins to the server.... I could not find any mod that does this specifically but I managed to modify some of the code of a mod called Baritone, Baritone has a cache feature that is used for pathfinding to aid it´s bot features, it does not save the chunks as a world downloader would, it only registers them as a solid blob of grey (I think only of the surface blocks) and saves them locally as a file that can´t directly be opened in single player of turned into any sort of schematic. I went ahead and (with my really low level java experience) got rid of some parts of the code that enables Baritone´s other features, this was done for performance reasons and because they are not useful for what I want. I also added some lines of code that tell the chunk packer to keep information about the main blocks used for terrain and building so that when the chunks are loaded, they are textured. This is the result: https://www.youtube.com/watch?v=OeCEItONFGo The mod updates the packed chunk cache with the newly streamed chunks constantly so the 10 chunk radius is always accurate. I found the results really promising but I don´t know how to take this any further, I am not a programmer, and although it looks really nice, there are memory leaks that make the game crash some times that I don´t know how to fix. I am showing you this because I think this because I think this could be a really nice addiction to your mod, being able to instantly load chunks when going into a world or a server would be insane, specially when combined with the performance gains this mod gives.

Like the mod bobby?

Last time I checked there was no mod to to this, I'm so glad to see this, the thing is that bobby just streams normal chunks, so you do get the benefits of a local cache, which is really nice, but you will take the same performance hit.

I'd something like this was implemented here, you could both have a persistent high render distance and great performance.

Unless these two mods already work well together, which might be a thing already.

byalvaroft commented 3 years ago

you don't have to load distant terrain in order for it to be visible - otherwise i would have had to explore the entire world in order to capture this. fp2 implements a totally separate system for storing and tracking low-resolution terrain tiles, unaffected by the vanilla render distance option.

low-resolution terrain is stored persistently on the server.

I see, so it actually has something like a cache, but it's only server side, that's really nice, although I would love to use this client sided only so that I could use it in servers that don't have FPT, thanks for the info.

That's pretty impressive how much terrain is loaded O.o

DaMatrix commented 3 years ago

I would love to use this client sided only so that I could use it in servers that don't have FPT

ah, that's what you meant. i have no plans to allow the mod to run client-side-only at any point in the foreseeable future, if ever.

JapMatt commented 3 years ago

it does not save the chunks as a world downloader would, it only registers them as a solid blob of grey (I think only of the surface blocks) and saves them locally as a file that can´t directly be opened in single player of turned into any sort of schematic.

If FP2 ever has client-side chunk storing I think it'd be pretty nice to store them as aformentioned "blobs" that can't be ported to SP, since many servers don't allow for map downloaders and outright ban users for it.

byalvaroft commented 3 years ago

it does not save the chunks as a world downloader would, it only registers them as a solid blob of grey (I think only of the surface blocks) and saves them locally as a file that can´t directly be opened in single player of turned into any sort of schematic.

If FP2 ever has client-side chunk storing I think it'd be pretty nice to store them as aformentioned "blobs" that can't be ported to SP, since many servers don't allow for map downloaders and outright ban users for it.

Correct me if I´m wrong but isn´t the low poly terrain that fpt creates (server side) already stored as something very different than normal chunks, I ask mainly because I think that most servers would be ok with it, as long as converting the data to schematics or a sp world is non trivial, plus even if someone where to maliciously backward engineer the chunk encoding they would only get the surface blocks I guess, plus it would be easier for them to just change and compile the world downloader mod. xD

Cyclonit commented 3 years ago

Hi @JapMatt, @SpanishBeast,

FP2 doesn't cache any data that could be used to reconstruct proper chunks. It caches the visual geometry, not the actual blocks or entities. There simply is no way of going from FP2 data to Minecraft terrain.