How to optimize a huge map?

im building a park and i realized i have 1400 trees which well it lags on older devices at medium graphics like mine, but the thing is this map isnt for me its for a client so idk really how to go about optimizing this?

4 Likes

For starters, you could cut down on the cookie cutter spam of trees maybe.

2 Likes

all i see is :evergreen_tree:
why so many :evergreen_tree:
maybe cool down on the :evergreen_tree:

4 Likes

yea i thought of the same and i did but whats next

1 Like

i cut the amount of trees down in half

1 Like

i cut down the amount of trees in half but whats the next step

1 Like

Well, not much as else seeing as your map seems lackluster in quality, i guess just having smarter tree placement will do you better.

2 Likes

ye its js not done really not even close tbh but i realized i forgot about the performance

How are the tree models structured? Are they meshes or just planes with textures?

If they are textures, you might want to scale the resolution down.

Just follow all the optimization rules for every part/mesh:

  • Do all the trees have different MeshIds? If yes, change that. Every tree should have the same meshId to reduce draw calls.
  • Does it need a touched event? If no, disable CanTouch.
  • Does it need collision? If no, disable CanCollide, CanQuery and set CollisionFidelity to Box.
  • If it needs collision, how exact does it need to be? Set the CollisionFidelity according to it.
  • If you don’t need them to be precise models in the distance, you can set its RenderFidelity to performance.
  • Does it need to cash shadow?
    (If you do that, do it with the console)

You could also enable StreamingEnabled if you want.

3 Likes

thanks but i dont know how to get around streaming enabled settings

I suggest reading the documentation and trying out the different settings.

https://create.roblox.com/docs/performance-optimization/design#low-end-devices

Maybe if you make every two-four trees a union that would help?

Unions most of the time increase triangle count

1 Like

Go to workspace and scroll down and you’ll find the Streaming tab. Change he StreamingTargetRadius from 1024 to something smaller like 512 or 256.

1 Like

I will give you an idea. Optimize trees so they wont render further away. I am not a fan of streaming enabled because you barely have any control. For trees make a folder and put the trees in it.

local RenderDistanceSystem = {

	RenderDistanceFunction = function(RenderFolder, renderRadius, refreshFrequency)
		local RunService = game:GetService("RunService")

		local renderFolderCache = Instance.new("Folder")
		renderFolderCache.Name = "RenderCache" .. RenderFolder.Name
		renderFolderCache.Parent = game:GetService("ReplicatedStorage")

		local treeParts = {}
		for _, object in ipairs(RenderFolder:GetChildren()) do
			if object:IsA("Model") and object.Name == "tree" then
				table.insert(treeParts, object)
				object.Parent = renderFolderCache
			end
		end

		local irfs = 0

		local function updateRender()
			irfs += 1
			if irfs < refreshFrequency then
				return
			end
			irfs = 0

			local camera = workspace.CurrentCamera
			if not camera then
				return
			end

			local camPos = camera.CFrame.Position

			local ok = pcall(function()
				for _, v in ipairs(treeParts) do
					local startPart = v:FindFirstChildWhichIsA("BasePart")
					if startPart then
						local dist = (startPart.Position - camPos).Magnitude

						if dist > renderRadius then
							if v.Parent == RenderFolder then
								v.Parent = renderFolderCache
							end
						else
							if v.Parent == renderFolderCache then
								v.Parent = RenderFolder
							end
						end
					end
				end
			end)

			if not ok then
				warn("Render loop error avoided — continuing safely")
			end
		end

		RunService:BindToRenderStep("RenderSys", Enum.RenderPriority.Camera.Value, updateRender)
	end,
}

return RenderDistanceSystem

Made this module script that should be inside of the replicated storage. In starter player scripts require it and fire the RenderDistanceFunction. RenderFolder should be the folder you have inside, Render distance should be the how far can an object be for it to be rendered and refresh frequency is how often does it update. You can make multible folders like some trees render still render so it gives an illusion. Lets say make first folder that renders it 200 studs away, other 400 studs away, and other 800 studs away.

2 Likes

too many trees for such a small area. use streaming enabled or optimize the tree meshes if you dont feel like changing the tree density