Level of Detail (LOD) - Scripting Advice Needed

Hello developers,

Today I come to you with a question. The maps we build for my games are always pretty large and part count-intensive. Generally the maps are structured as wide open spaces with large settlements or ruins dotting the landscape. My current idea for relieving strain on the server would be a simple LOD system where each town/ruin starts off with a muffled exterior and a completely emptied interior. When a player gets within range of the central ‘point’ in the area, the full town/ruin model (with full exterior & interior) would be loaded into the map from ReplicatedStorage, and the reverse would happen when they leave that range.

The issue here is that I want to craft the best possible LOD system for my games that would actually reduce server strain noticeably and be worth the time and effort to create. Most of the work wouldn’t come from scripting but rather making low LOD versions of all the big areas. Is this the best method? Should I go for chunks instead perhaps? Would loading these areas in cause no noticeable improvement or even worse performance? How would I even load in the model other than just reparenting it to Workspace?

I appreciate any and all responses!

9 Likes

You could identify when a player is close to a part using magnitude, and set the building with high detail transparency to 0, and the one with low detail to 1. Tried to keep this simple.

3 Likes

EndorsedModel made one for his floral generation script. He had an LOD system on the client. The essentially just moved them in and out when they were far enough away. I’m not sure of another way to do this.

3 Likes

There are multiple ways of doing it however, I personally don’t know the most efficient way for an LOD system however, I can give you details about them.


@Conejin_Alt’s method of LOD is pretty simple, just have checks when a player is in a certain chunk, then “load” chunks by making them appear via transparency from 0 to 1(though if there are parts with different transparencies, you’ll have to store a table of some sort to keep track of the transparency and set them as usual). Although this is simple, it does put much less strain on the server rather then having all appear however, collisions would still stay meaning it still is there/other things. You decision on what to choose though :man_shrugging:, having collision stay might even be good from some things.


@MrLonely1221’s method does somewhat work however, moving parts/objects continuously in my opinion would give lag spikes every once in a while if you travel fast in chunks/etc. Moving them far away isn’t a good idea either though. (I might be reading it wrong so don’t mind me :stuck_out_tongue:)


Another method would be to parent and unparent them when getting in a certain chunk. Kinda confusing but let me explain:

Let’s say you had map1, map2, and map3. Map1 is close to map2 and map 3 is close to map 2 but not 1 and vice versa. If a player is in map1, map2 would load a little/all but map3 won’t load at all/won’t be parented to workspace.

This in turn makes sure that even if the player travels fast, the area would stay loaded just in case as to allow the player not to fall to the abyss/get confused. (Side note, you can parent models/objects in and out of workspace via changing the parent to nil/to workspace, just make sure you keep it in check and remove as necessary to prevent memory leaks, might be possible though Idk)

However, depending on the map like @MrLonely1221’s method, this could cause some sudden lagspikes when loading in maps per usual, especially if you can travel back and forth like if you were to be in map2 yet you could go between map1/map3. However, this will help with performance/ “reduce” part count and lag.


Now then, to move to your method. It works similar to bloxburg’s method of LOD very much where they load/unload parts inside buildings as to reduce lag and load in when they get near. I don’t know if its better to keep it in Replicated Storage and move it in and out though It should work the same as parenting nil/etc so I don’t find anything bad, I might be wrong though.

I wouldn’t think of it to be necessary to make low very LODs of each map however, you can just “tag” parts via CollectionService/etc on parts you want to be gone during the LOD process without duplicating/making more parts/increasing part count.


Depending on your map, chunking/other things would work better. Let me explain again, if your game works like Speed Run 4, where maps are separated from one another, having a “chunk” of the entire map would be a good idea. If it’s like Minecraft, having chunkify the map in squares would be a better idea rather then regions though personal preference.


One last thing, looking at other people’s methods of LOD helps quite alot, one of the methods I explained above can be seen here: Chunk Loading System - Roblox (Credit to TheNexsusAvenger, some parts however might be outdated/some functions deprecated though It’s still useful)

Another good example by dogwarrior24: Infinite Terrain - Roblox
Original post by dogwarrior24 if you’re more interested: [Open Source] Infinite Terrain & Level of Detail system

Hopefully this helps, good luck :+1:

3 Likes

The biggest thing to keep in mind when doing something like this is that if you don’t delete the parts, they will stay in memory and you won’t get any memory benefit. This is also true for setting parent to nil. If you want to remove them from memory you will have to delete them and to reload them you will have to use remote events to replicate the parts from the server back to the client (increasing network load).

Just setting transparency or parent to something other than workspace will see a tender time improvement though.

4 Likes

Memory benefit, huh? Is the memory benefit of putting ~50 to 100k parts into ServerStorage worth it? And do you think the network load issue of loading in those models to the Client (perhaps ~25k each) would be very bad?

1 Like

The memory benefit is where it will come down to testing and your specific use case. I would look into the memory usage of your game and decide whether it needs to be reduced to run well on the platform(s) you are building it for. If not, this isn’t a significant concern.

As for network bandwidth, it’s also pretty hard to tell, but this is where issues occur with using Roblox’s default Streaming Service since it uploads parts of the game to the clients as they go into unloaded areas.

Ultimately I would look for the problem you are trying to solve first rather than looking to find a solution, and test the solution you develop to determine its impact.

I used to do this exact same thing and make my maps large but, detailed. Two things that I found to work best are StreamingEnabled and meshparts. Nowadays, when I build, if I know that the part will require a union of parts or parts structured in a uniform way, I’ll go ahead and do it in blender.

I’ve widely adopted low poly and found detail to be both visually pleasing and easy on most computers. Perhaps, @UndoneBuilder could give some advice since this is more-so his area of expertise.

Hope this helps!

1 Like

I’m not sure if this is impossible due to some backend voodoo I’m unaware of, but I wish Streaming Enabled was a feature one could toggle on the Client so I could hook up Mobile users with Streaming Enabled and let the computer users play without streaming. The smaller screens and lack of horsepower on the mobile machines makes Streaming a pretty useful thing, but on a computer it just looks ugly and there’s a crazy amount of pop-in.

Hello!

I have (in the past) worked on LOD systems, for 2 separate games. These games both have thousands of parts, and are very intensive with geometry.

After developing these systems, I have noticed that they actually are a detriment to performance, and it is very expensive to maintain them (due to saving in memory, etc). I say marginal CPU performance boosts, and around 25-30% memory increase.

Roblox instances are very performant, there’s not a significant amount you can do, however, StreamingEnabled will be getting great updates in the future that will solve this problem for you!

2 Likes

What kind of updates do you mean? Like toggling locally?

Referring to the road map, there are several changes that will benefit you greatly, some have already been enabled, since I last saw.

StreamingEnabled is basically only creating instances that are nearby you, a LOD system essentially.

This is a crack at one of the LOD systems I did for a commission, however, it was canned after we discovered the performance boosts were actually detrimental: Render Test - Roblox
Render-Test.rbxl (776.3 KB)
refer to StarterPlayer > StarterPlayerScripts > RenderModule.

This system is essentially a grid chunking system, image

Red is your current grid, it will only “load” grids surrounding a few grids. Thinking about it now, I could pre-calculate what grid each instance goes into, and grouping them? This is costly for memory, as you could imagine.

edit: I never actually completed that part of the render module. The old render module was slightly different in that it was a radius check. A chunk based system where you pre-calculate what chunk each asset is in might be suitable, however, I imagine it is pretty costly on performance

1 Like

So you think an LOD system isn’t worth it at all? As for StreamingEnabled, I wish I could use it but it just has no customization options. I need to be able to toggle SE per-client.

Just to clarify, I think a base map with small towns that load in are a better option for my games than chunk loading. You think losing in one part at a time rapidly as a player enters the ‘high LOD’ zone for a town would cause more problems than it solves?

1 Like

Correct, I don’t really think they are worth pursuing. From my own experiences, I haven’t seen a great performance increase with them. May be worth a shot to pursue. Roblox Instances are very performant, though.

My mobile users say performance is very poor and I hope to boost that. But the game itself is larger than most so if LOD doesn’t work and SE is sorta a bad idea until it gets better, then I’m not sure what to do.

Yeah, not really sure if a LOD will fix that, as, it is costly on memory, of which mobile has very little of. Over the years, people generally get better devices and this is less of an issue :slight_smile: