Shadows are choppy when changing TimeOfDay

Whenever we’re changing the TimeOfDay tween slowly it seems to be doing in “ticks” and turns out pretty choppy, when you speed it up it’s pretty smooth and we don’t know any methods that we could try which wouldn’t require us to use the client as that would make it desync.

Methods we tried:

local Lighting = game:GetService"Lighting"
local TweenService = game:GetService"TweenService"
TweenService:Create(Lighting,TweenInfo.new(24--[[adjust the time]],Enum.EasingStyle.Linear,Enum.EasingDirection.Out,math.huge,true,0),{
    ClockTime = 24
})

Looped Version:

local Lighting = game:GetService"Lighting"
local RunService = game:GetService"RunService"
while true do
    Lighting.ClockTime = Lighting.ClockTime + RunService.Heartbeat:Wait()/25
end

Another Method:

while true do
    wait(10) -- Or whatever time, I used this for testing purposes.
	for i = 1,100 do
		local Time = game.Lighting
		Time.ClockTime = Time.ClockTime + .01
		wait(.01)
	end
end

Anyone know how we could fix it?

2 Likes

Well, first of all wait can only go to 1/30th of a second, and is choppy in itself, so I would recommend task.wait(). Also, this should be a bit better?

while true do
	task.wait(10) -- Or whatever time, I used this for testing purposes.
	for i = 1,100 do
		local a = task.wait()
		local Time = game.Lighting
		Time.ClockTime += a
	end
end

wait() tends to throttle, which makes things look choppy. Also, task.wait() can go as low as 1/60th of a second, doesn’t throttle, and returns how much time has passed, which allows me to add it to the clock time. If you want it to be an even number however, I would instead just add 0.01.

while true do
	task.wait(10) -- Or whatever time, I used this for testing purposes.
	for i = 1,100 do
		local Time = game.Lighting
		Time.ClockTime += 0.01
		task.wait()
	end
end
1 Like

Why don’t you use lerping? This example is already very close to how you would use lerping

1 Like

Also, when I try this in my studio, it seems to be working smoothly. Maybe try lerping? That’s the only other thing I can think of.

Try using TweenService to animate the time of day.

Tried to do that multiple times.

I am pretty sure that this is a game engine problem, if I am not wrong then you should file a bug report.

1 Like

It is a limitation of the game engine. Nothing you can really do about it, if you want a constant time update.

local Game = game
local Lighting = Game:GetService("Lighting")
local TweenService = Game:GetService("TweenService")

Lighting.ClockTime = 0
local Tween = TweenService:Create(Lighting,TweenInfo.new(48, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1), {ClockTime = 24}) --Increase 48 for a longer (smoother) transition.
Tween:Play()

I’d also recommend performing tweens on the client instead of on the server.

1 Like

Change to softer shadows, either by increasing Lighting’s ShadowSoftness or changing Lighting’s Technology to something softer, such as Voxel. With softer shadows, there’s not so many choppy pixels being rendered (especially in the grass) and a smooth transition looks a lot better