I’ve created a render distance system for a game I work on that has shown to improve GPU performance a decent bit on higher graphics settings. It’s especially useful for Xbox which seems to have Roblox’s built-in render distance maxed out, so it saves a lot on performance in that regard.
I was wondering if anyone knew of some good ways to improve it. Right now, it runs on BindToRenderStep, but waits a certain number of frames before checking the distance of every single object that applies to the render distance system. This is what I think is the worst about it when it comes to performance.
Pretty much all I want to do is have it run faster. I was thinking it’d be possible to do it by using Region3 somehow, or disabling the system entirely for lower graphics setting users, but I’m not entirely sure yet. A place file demonstrating it and how it works is attached, with the script in StarterPlayerScripts.
tl;dr: How to make my render distance system (attached) more performant?
EDIT: For those who don’t want to look at the place file:
local renderRadius = 100 -- Render distance radius
local refreshFrequency = 10 -- Amount of frames to wait before checking the distance of objects
local renderFolder = Instance.new("Folder", game:GetService("ReplicatedStorage"))
renderFolder.Name = "RenderCache"
local localchar = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local localhrp = localchar:WaitForChild("HumanoidRootPart")
local treeParts = {}
for i,object in pairs(workspace:GetChildren()) do
if object:IsA("Model") and object.Name == "RenderTree" then
table.insert(treeParts,object)
object.Parent = renderFolder
end
end
local irfs=0
local function updateRender()
irfs=irfs+1
if irfs>=refreshFrequency then
irfs=0
if localhrp then
for i,v in pairs(treeParts) do
local startPart = v:FindFirstChildWhichIsA("BasePart")
if startPart then
local partDistRender = (startPart.CFrame.p-localhrp.CFrame.p).magnitude
if partDistRender>renderRadius then
if v.Parent==workspace then
v.Parent=renderFolder
end
else
if v.Parent==renderFolder then
v.Parent=workspace
end
end
end
end
end
end
end
game:GetService("RunService"):BindToRenderStep("RenderSys", 1, updateRender)
RenderSystem.rbxl (22.4 KB)