local Lighting = game:GetService("Lighting")
-- ================= НАСТРОЙКИ =================
local Settings = {
AutoCycle = true, -- автоматическая смена дня и ночи
DayLengthMinutes = 120, -- сутки в минутах (120 = 2 часа)
StartClock = 0, -- старт с ночи (0 = полночь)
BloomIntensity = 0.55, -- сила бликов
DepthOfField = 0.2, -- размытие дали (0 = выключено)
CloudCover = 0.55, -- облачность (0..1)
CloudDensity = 0.65, -- плотность облаков (0..1)
}
-- =============================================
local function getOrCreate(parent, class, name)
local obj = parent:FindFirstChild(name)
if not obj then
obj = Instance.new(class)
obj.Name = name
obj.Parent = parent
end
return obj
end
local atmosphere = getOrCreate(Lighting, "Atmosphere", "WorldAtmosphere")
local bloom = getOrCreate(Lighting, "BloomEffect", "WorldBloom")
local sunRays = getOrCreate(Lighting, "SunRaysEffect", "WorldSunRays")
local color = getOrCreate(Lighting, "ColorCorrectionEffect", "WorldColor")
local dof = getOrCreate(Lighting, "DepthOfFieldEffect", "WorldDOF")
local clouds = workspace.Terrain:FindFirstChildOfClass("Clouds") or Instance.new("Clouds", workspace.Terrain)
-- Базовая картинка
Lighting.GlobalShadows = true
Lighting.EnvironmentDiffuseScale = 1
Lighting.EnvironmentSpecularScale = 1
Lighting.ShadowSoftness = 0.15
bloom.Intensity = Settings.BloomIntensity
bloom.Size = 40
bloom.Threshold = 1.2
dof.FarIntensity = Settings.DepthOfField
dof.NearIntensity = 0
dof.FocusDistance = 40
dof.InFocusRadius = 35
atmosphere.Offset = 0.25
clouds.Cover = Settings.CloudCover
clouds.Density = Settings.CloudDensity
local function lerp(a, b, t)
return a + (b - a) * t
end
local function update()
local t = Lighting.ClockTime
-- день: 0 ночью, 1 днём
local day = math.clamp(math.sin((t - 6) / 12 * math.pi) * 1.4, 0, 1)
-- близость к рассвету или закату
local edge = math.clamp(1 - math.abs(day - 0.3) * 3, 0, 1)
Lighting.Brightness = lerp(0.3, 3, day)
Lighting.ExposureCompensation = lerp(0.4, 0, day)
Lighting.OutdoorAmbient = Color3.fromRGB(lerp(25, 120, day), lerp(30, 125, day), lerp(55, 135, day))
atmosphere.Density = lerp(0.45, 0.32, day)
atmosphere.Haze = lerp(0.8, 1.8, edge)
atmosphere.Color = Color3.fromRGB(lerp(60, 199, day), lerp(70, 190, day), lerp(110, 200, day))
atmosphere.Decay = Color3.fromRGB(lerp(40, 106, day), lerp(40, 112, day), lerp(70, 125, day))
sunRays.Intensity = 0.05 + day * 0.15
color.Contrast = 0.08
color.Saturation = lerp(-0.1, 0.15, day)
color.TintColor = Color3.new(1, lerp(0.97, 0.9, edge), lerp(1, 0.8, edge))
-- облака темнеют ночью
clouds.Color = Color3.fromRGB(lerp(60, 235, day), lerp(65, 235, day), lerp(85, 245, day))
end
Lighting.ClockTime = Settings.StartClock
update()
task.spawn(function()
local step = 0.25
local perStep = 24 / (Settings.DayLengthMinutes * 60) * step
while true do
task.wait(step)
if Settings.AutoCycle then
Lighting.ClockTime = (Lighting.ClockTime + perStep) % 24
end
update()
end
end)