Handling Level of Detail?

What is the best way to handle LOD in game? I’m thinking of having a lot of assets in my game and to preserve fps I made three different meshes for each asset with different levels of quality, but I don’t know what would be the best way to switch between them as the player walks around the map. I was thinking a constant Region3 replication where anything outside the Region3 is turned into the lower quality mesh, but I think this would be quite taxing. Any ideas?

4 Likes

Subdivide your map into a checkerboard and determine at any point in time in which box the player is. Then load the X boxes in the neighbourhood of that box and unload boxes too far away from the box of the player.

The subdivision and putting references to models in the correct boxes would be done once by the client when they join the game. If there are moving parts in your map, either exclude them from LOD or you need to make sure they’re in the correct box all the time.

5 Likes

Wouldn’t this be weird at the corners of boxes? Or am I not thinking about this correctly?

Also, what would be the best way to switch between LOD meshes? I’m thinking about having them all in workspace and to switch I would just turn them invisible and visible again, but I don’t know if this is better than cloning meshes from ReplicatedStorage and putting them into workspace.

1 Like

You can have multiple layers of boxes around the player, similar to what Minecraft does for their chunking system. Here’s an example of a shape you can use for loaded chunks, but it could also just be a square of chunks:

image

For switching out meshes, probably changing their transparency from 0 to 1 might work. Don’t tween transparency though, because anything between 0 and 1 is expensive to render. Toggling should be fine. I’m not sure whether it’s cheaper than parenting and unparenting the meshes onto their baseparts, this is something you can test out yourself.

8 Likes

Use PreloadAssets and add a cool loading screen.

--from wiki
local ContentProvider = Game:GetService("ContentProvider")
 
local function LoadAssets(AssetList)
	-- Takes an asset list and preloads it. Will not wait for them to load. 
 
	for _, AssetId in pairs(AssetList) do
		ContentProvider:Preload("http://www.roblox.com/asset/?id=" .. AssetId)
	end
end
 
LoadAssets({2253543, 2434541, 5133543, 2423433, 41143243, 2453865, 21433365, 2154549})

It preloads the assets you list so it won’t have to load in-game

Why don’t you just use something like magnitude?

Well, I don’t know how taxing it would be to use magnitude on a lot of objects.

That’s just taking the distance between two vectors, shouldn’t be that taxing.

It’s very basic calculations, as compared to Region3 or something like Chunk systems I would think that magnitude wouldn’t be that taxing at all.

So I’m about to implement this system and I was thinking, for magnitude I’d have to loop through all of the parts in workspace and if there were like 50,000-100,000 parts I’d have to loop through and turn visible/invisible based on magnitude wouldn’t that be very intensive?

This is not going to work for that many parts. You’ll have to divide them into buckets like I suggested above, and then turn entire buckets on/off depending on where the player is. You can’t check individual parts at that scale frequently.

3 Likes