Загрузка данных
local RunService = game:GetService("RunService")
local Lighting = game:GetService("Lighting")
--------------------------------------------------
-- SETTINGS
--------------------------------------------------
local SAMPLE_TIME = 5
local HIGH_FPS = 55
local MEDIUM_FPS = 35
local CHECK_INTERVAL = 2
--------------------------------------------------
-- EFFECTS
--------------------------------------------------
local atmosphere =
Lighting:WaitForChild("RTXAtmosphere")
local colorCorrection =
Lighting:WaitForChild("RTXColorCorrection")
local bloom =
Lighting:WaitForChild("RTXBloom")
local sunRays =
Lighting:WaitForChild("RTXSunRays")
--------------------------------------------------
-- PERFORMANCE
--------------------------------------------------
local currentQuality = "MEDIUM"
local frames = 0
local elapsed = 0
local averageFPS = 60
--------------------------------------------------
-- QUALITY
--------------------------------------------------
local function setQuality(quality)
if quality == currentQuality then
return
end
currentQuality = quality
--------------------------------------------------
-- HIGH
--------------------------------------------------
if quality == "HIGH" then
atmosphere.Density = 0.18
atmosphere.Haze = 1.2
atmosphere.Glare = 0.05
colorCorrection.Brightness = 0
colorCorrection.Contrast = 0.08
colorCorrection.Saturation = 0.05
bloom.Enabled = true
bloom.Intensity = 0.08
bloom.Size = 18
sunRays.Enabled = true
sunRays.Intensity = 0.04
sunRays.Spread = 0.8
--------------------------------------------------
-- MEDIUM
--------------------------------------------------
elseif quality == "MEDIUM" then
atmosphere.Density = 0.13
atmosphere.Haze = 0.8
atmosphere.Glare = 0.02
colorCorrection.Brightness = 0
colorCorrection.Contrast = 0.04
colorCorrection.Saturation = 0.02
bloom.Enabled = true
bloom.Intensity = 0.04
bloom.Size = 12
sunRays.Enabled = false
--------------------------------------------------
-- LOW
--------------------------------------------------
elseif quality == "LOW" then
atmosphere.Density = 0.08
atmosphere.Haze = 0.4
atmosphere.Glare = 0
colorCorrection.Brightness = 0
colorCorrection.Contrast = 0
colorCorrection.Saturation = 0
bloom.Enabled = false
sunRays.Enabled = false
end
end
--------------------------------------------------
-- FPS MEASUREMENT
--------------------------------------------------
RunService.RenderStepped:Connect(function(deltaTime)
frames += 1
elapsed += deltaTime
if elapsed >= SAMPLE_TIME then
averageFPS =
frames / elapsed
frames = 0
elapsed = 0
end
end)
--------------------------------------------------
-- QUALITY CHECK
--------------------------------------------------
task.spawn(function()
task.wait(SAMPLE_TIME)
while true do
local fps = averageFPS
--------------------------------------------------
-- HIGH
--------------------------------------------------
if fps >= HIGH_FPS then
setQuality("HIGH")
--------------------------------------------------
-- MEDIUM
--------------------------------------------------
elseif fps >= MEDIUM_FPS then
setQuality("MEDIUM")
--------------------------------------------------
-- LOW
--------------------------------------------------
else
setQuality("LOW")
end
task.wait(CHECK_INTERVAL)
end
end)
--------------------------------------------------
-- START
--------------------------------------------------
setQuality("MEDIUM")