Tweens on atmosphere.density are not smooth

I am trying to tween atmosphere density, haze, and color, and the density seems to snap in occasionally instead of smoothly:

Here are the tweens being applied here:

local tweeninfo = TweenInfo.new(
	.400,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

local env_tween_activate_atmos = TweenService:Create(
	Lighting.Atmosphere,
	tweeninfo,
	{
		Density = 0.7,
		Haze = 3,
		Color = Color3.new(0.141176, 0.141176, 0.141176)
	}
	
)

local env_tween_deactivate_atmos = TweenService:Create(
	Lighting.Atmosphere,
	tweeninfo,
	{
		Density = 0.181,
		Haze = 1,
		Color = Color3.new(1,1,1)
	}

)

I looked around for a while and couldn’t find any information beside saying it’s impossible or to just slow down the tween (which may not be an option in some situations for my use). Is there a solution to this?

roblox lightning limitations. one trick you could do is tween the brightness instead. its a trick the game experience 3048 uses to cycle between day and night too.

1 Like

If I remember right the “chunking” effect only happens if you tween the colors of the atmosphere. It should transition smoothly if you use just density.

Avoid modifying the atmosphere colors. For lighting colors, tween the Ambient, OutdoorAmbient, Brightness, Exposure, TimeOfDay. You can also use color correction or bloom/blur effects. 90% of the time you can find an alternative to tweening atmosphere colors.

I had this issue in the past when I did a thunder effect for my game, but I fixed the issue by simply tweening the OutdoorAmbient instead.

1 Like

Personally, I would just go the longer/harder route and make things manually.

Try this script:


local RunService = game:GetService("RunService")

local function smoothUpdate(property, startValue, endValue, duration)
	local startTime = tick()
	local endTime = startTime + duration
	
	RunService.RenderStepped:Connect(function()
		local now = tick()
		local alpha = math.min((now - startTime) / duration, 1) -- Calculate interpolation factor
		Lighting.Atmosphere[property] = startValue + (endValue - startValue) * alpha -- Update the property
		if alpha == 1 then return end -- Stop once the tween finishes
	end)
end

smoothUpdate("Density", Lighting.Atmosphere.Density, 0.7, 0.4)
smoothUpdate("Haze", Lighting.Atmosphere.Haze, 3, 0.4)
smoothUpdate("Color", Lighting.Atmosphere.Color, Color3.new(0.141176, 0.141176, 0.141176), 0.4)

Thanks, this seems to give a similar effect as I wanted. I tried to tween just the color and density properties and they seem to be smooth, however haze has noticeable hitches.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.