Real Sun Path | Realistic Sun Movement and Longer/Shorter Days!

Hi! I’ve created a very cool radio communicator that has support for modular apps and such and decided to adapt the real sun path clock GUI to add support for your module.

However, I’m not able to write a function that returns the degrees from 0 to 360 from sun height and azimuth for the daily sun path you see in the picture, I want the sun to be at 0 degrees for sunrise and 180 for sunset, do you know how I would be able to accomplish that?

I was also wondering if you are going to update your module to provide values for the moon too, as that would be very cool :slight_smile:

3 Likes

This looks cool but does it have weather/climate system?

1 Like

I don’t clearly understand fully what you’re trying to do, but I do know that the Sun doesn’t rise at 0 (North), and set at 180 (South). It should rise at more or less 90 degrees (Depending on the day of year), and set at more or less 270 degrees, assuming the day of the year is set at the equinoxes. I assume you’re trying to offset the display degrees, which you can simply do simple addition to the current azimuth value.

And for the Sun height, -90 is directly below horizon (nadir), 0 if its at the horizon, and +90 if directly overhead (zenith). It doesn’t go all the way to 360.

For the Moon, Roblox currently has a fixed Moon phase of a Full Moon, so the best way is to make one separate for the Moon but you will need to mimic the positioning system of the Sun for an artificial BasePart Moon, then apply the Real Sun Path formulae with some modifications. It will be a lot of work given the current Roblox features.

Also nice GUI work you made! Can’t wait to see that astronomy app you’re making!

1 Like

Hi! It’s a work in progress, but you can already try the whole device here:

At the end of the app list, there should be an app called “Suntimes”, that’s what I’m working on now!
I am currently trying to make an accurate sun path on the front page (here highlighted in red)
immagine
The sun icon in the position above is rotated by 0 degrees (sunrise), 90 degrees would be overhead/12pm and 180° would be sunset, do you know how I could achieve this based on variables used in the sungraph script? :slight_smile:

You’re free to try out everything I made up to this point, I am still sorting out the chart a bit, you may have seen the Sensors app, that uses some of your formulas along with others (humidity, etc. and EMF, which is fictional and calculated based on near parts with scripts)

Everything’s open source, and you can find more details here: 🌡️ Sensors | Indirecta

1 Like

God help my soul this looks like seal team 6 briefing.

A simple 180 degree diagram should be relatively easy so basically lets say you’re living at a high enough latitude where you get about 8 hours of daylight in the winter, and 16 hours in the summer. For every hour that passes, you move the Sun on the diagram about 180 deg / 8 hours = 22.5 deg / hour. And for the summer, you do the same thing: 180 deg / 16 hours = 11.25 deg / hour. So 180 degrees will be the constant, and you’re treating the length of day on the denominator as the variable.

Also looks like you wanna keep 12pm as solar noon, so you will have to shift when you want the diagram changes occur. So in my example, you begin moving the diagram at 8am, and for the summer, you start at 4am.

2 Likes

Thank you! I was able to get it working with this function

function calculate_sundial_rotation(daylength, t)
			-- Convert time t to be within the range of the day (0 to daylength)
			local rotation;
			t = t % daylength

			-- Calculate sundial rotation
			if t < daylength / 2 then
				rotation = (t / (daylength / 2)) * 90  -- Rotates from 0 to 90 degrees
			else
				rotation = 90 + ((t - daylength / 2) / (daylength / 2)) * 90  -- Rotates from 90 to 180 degrees
			end

			return rotation
		end

Do you plan on adding moon stuff, and phases to your script? :slight_smile:

EDIT:
This seems to actually be more precise, however, there’s still some offset between actual sunset and 180°.

local function calculateRotationAngle(t, dayLength)
	t %= 24
	local anglePerUnitTime = 180 / dayLength
	local rotationAngle = (t - sunriseTime) * anglePerUnitTime
	return rotationAngle
end
2 Likes

Moon phases would be far fetched, especially I tend to work this script alongside 3D Atmosphere, which involves a mesh that blocks FogEnds to create an atmosphere. Hope your script works now, sorry for the late reply but yeah. If Roblox has a feature where parts can appear behind another part, I will definitely add realistic Moon phases too!

1 Like

Hello
I am doing a small game, where you will be able to fly in space
I have an invisible Part which represents the Sun and I would like to position the Sun Skybox texture “behind” the Sun Part when the player looks at the Sun Part (i.e. at the place on the skybox where the direction vector between the player and the Sun Part “hits” the skybox).
I care only about the X and Z position. I would like the “height” of the Sun texture to remain more or less same all the time (around 15-16 o’clock)
So I wonder how can I set (and update) the correct Sun texture position in game using the Geographical Latitude setting?

Thanks in advance

1 Like

I don’t clearly know what exactly you’re doing but to my understanding, if you’re going to make a space game, I would highly recommend you using my 3D Atmosphere script 3D Atmosphere - Roblox where it already does what you are describing. The Sun’s texture is already customizable, and with accurate apparent diameter and refraction effects.

Hey amazing work man… everything is just so well prepared and thought off… Just one quick question, I’m unable to figure out how to make a real time script which works with this system, unlike the one it already has which simply just plays a cycle that isn’t synced with the real world.
Any help would be appreciated!

1 Like

Basically the ClockTime value inside this script is based on local solar time, with 12pm referring to when the Sun crosses the meridian on an average.

By default, the display time, which is on the game clock may be ahead or behind the ClockTime value (local solar time), depending of where you are on the ideal timezone, plus any DST offsets.

If you wanna sync with the actual Sun, you will have get the current time of the day in real life, and subtract it by the Sun offset, which can be found in the game clock, which this script comes with.

I may implement something like that for future updates but so far you will have to do a bit of math. The best part is that you will be working with decimal hours though.

Thank you! I’ll see what I can do with my kinda basic scripting skills lol

That’s pretty cool. The atmosphere module could change a lot of visuals in some games.

Heyy tysm again! I was able to make the cycle with a very simple script! The results are awesome and incredibly accurate!

Why did you use GuiMain over ScreenGui?

(it’s deprecated)

Alright it’s me again lol… I have an issue with the clouds… I wanted to add them to the game, however, with the 3d environment feature seems like they are set in the background and can’t be seen… What solutions can I try?

Unfortunately, the Roblox clouds aren’t compatible with 3D Atmosphere, hence why I had to use an improvised cloud system for the game I used 3D Atmosphere in. One way of improvising clouds is to stack decals and use a cloud texture. Then offset them on the XZ plane in random directions. This article has a great solution to the cloud problem: Volumetric Clouds: Phase 2!

I see… I’ll have to give it a try I guess… It’s a shame we cannot customise Clouds in any way
Thank you so much anyway!

Edit: I have thought about a way better alternative to this problem rather than using different clouds or not using the 3D atmosphere, here’s my idea:
Instead of simulating the upper atmosphere with a mesh, we could stick to Roblox’s built in sky box to replicate the same effect. This could be done by changing the sky box texture according to the Atmosphere color/texture value.
I believe this could be possible to implement and I think I could be able to figure it out (no promises lol) but I’ll need to actually get to know how’s the transition in the atmosphere’s colour to replicate the same effect on a decal, and that might be something I’ll need your help with (if you are willing to).
Thanks in advance!

This seems really nice!

I made a season system on my game that changes throughout the year and wanted to have the length of the day change with the seasons. Lets say I was a bit disappointed in Roblox’s system. I’ll take a look at this script for sure