Tip:
Highlight text to annotate it
X
Here's what I've been up to in Unity. I've been developing this
astronomy package with the goal being to more accurately model the motion of
the Sun, moon or moons, rings
if the planet has them, and even the starfield in the background.
My sources for this were several articles on Wikipedia
about the position at the Sun and the orbit the moon
on and celestial coordinate systems. I've also borrowed
the sky dome shader from Unity forums
and adapted it so you'll see the package better.
my assumptions in this to simplify some of the math
is to assume that the orbits are circular
rather than elliptical, given that the eccentricity
of the orbits are extremely small. The other assumption is that
moons are already tidal-locked
that's the feature that causes you know the same side of the moon to always
be facing the planet.
So I don't handle it if the moon were still rotating.
going over my Unity hierarchy here,
I've put all the celestial stuff into one object.
On that object I run a script called Game Time.
It handles adjusting the
angle of the Sun, rotating the celestial sphere,
keeping track of the time of day and time of year
along with the axial tilt the planet,
and the current longitude latitude
I also use this timescale slider
to either start advancing time,
or to really get it spinning.
also in the hierarchy here,
there's a main camera for the celestial area, and then there's
a separate the camera attached the first person controller
over on the terrain. so the terrain area is essentially, where all
game play area where the player is
running and doing things and all the celestial stuff
happens in a sense happens in its own little bubble
and the cameras through a script are synchronized.
in their rotation so that way essentially
simple rendering pass
sky is drawn from the second camera.
in here I also have several moons
so I'll focus in on these.
I've borrowed these from DragonLance so that's why
there's a white, red,
and a dark almost black moon.
these objects have their own script which
borrows time from the celestial object
the moons have parameters including the orbital inclination
because they're not always perfectly aligned to the planet's equator
and then some parameters to
handle that inclination of tilt
of the orbit actually itself rotates around
during a period of time that's called and nodal period
separate from the orbital period
a lot of details what these parameters mean
are from the Wikipedia article, so it's easier to explain by
looking at those pages.
but inherently have got the three moons ethan has difference at the Predators
I am I currently have them said 80 inclination
I so they're much on the equator because
it helps with ur having actual alignments above the moon's
which I have one kinda programmed in here to come up
I am
the Rings actually is treated just like another
from moon here though I
added objector to represent planet it so that
the if it were in Unity Pro um
the should cast a shadow on the reins for that way
you be able to see in the game world when a shadow has been cast on the Rings
as well
the starfield here
is not just the starfield texture map um
shares a faced call shaker
but this shaker which is it was adapted from the
SkyDome shaker also handles
when it's daytime as well hi advance
no time for a bit
comes daytime
ago
but the brighter on where the Sun is this is a lens flare attached to the
directional like
the Sun
darker blues away from the horizon
and the time it does get a little more orange-red
it feeds all too quickly into stars
but it *** enough to showing its day time
for the Sun is actually two directional lights here
they're on different a.m.
calling masks
third one directional light helps too
eliminate the
gameplay terrain
from and so that's where the Sun will also change color
and a.m.
more left feet out at sunset I am
whereas a set this other like from moons I'm
its con Mosca said to just the celestial group
um to keep the moon's eliminated at my time
turkey I'm
and everything
scripted mmm tied together
bygone advanced time
0
everything spin around including
being view
really advanced things
we have a very close to sunset
even a dove the eye
alignment three moons
business sunset red 82
starfield I am
reason why first this alignment is happening
mere Sun certain not exactly at
the noon or something as because
currently have the avalanche hit latitude set to you where I am
on on the west coast in California
if I time
and
understood
they can get to see
here it's starting to go out
payment but a different part the world's how the line
look
so that's basically how it works
teachers I love this because it includes the
actual till to the planet
from you you do get seasons I love this
if I A
there for time
and it said it skills six
so this is a solar day per frame of course the moons are spinning by
you're seeing the Sun at a different position the same time of day
over the course of the years informs us
figure 8 called and a lemma sewers interesting that
all my calculations brought up this
feature which occurs on earth course to
first earth looks a little different because we do have that eccentricity
orbit and varying orbital speeds which
I've simplified to be area circular orbit a constant speed here
and of course because the way if the
latest directional yet lunar phases trial
with and lunar orbital inclination which I can demonstrate here
object a know I have hidden is the orbital plane
show you that's the plane that the
on orbits on
we can show
all
inclination
just
10
only the Earth's moon is inclined to a little over five degrees
this is where you can see that the orbital plane
crosses
plane in the Rings which is on the equator currently
listening longitude
justice
and so by adjusting their I'm north
these predators in the game you can actually affect a when you get eclipses
or other lunar alignments
this doesn't show eclipses of course because they don't have any pros on
marketing shadows
I'm also still have to figure out how to get shadows cast from them
onto the train or a map I might just have to be were
I do a calculation twin Lite and the moon determine whether or not I should
them out the Sun further
there's also no atmospheric distortion
at the horizon serving the Norman makes the moons look
a.m.
larger when they're on the rise in it also affects the Sun
from
when it's night time
this is just a
circle texture mapping
thing at this limitation
resolution
the texture at the polls
quite get the obvious wear them Northstar should be
and said can you get this gap
but a man I am
looks pretty good for
michael's to be