Skip to content

Commit

Permalink
Merge branch 'lighting'
Browse files Browse the repository at this point in the history
  • Loading branch information
moltenwolfcub committed Jul 15, 2023
2 parents 70ccc02 + 6a77ba7 commit 613c3f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions game/ambientLighting.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ func getSunsetTime(dayOfYear int) (start float64, end float64) {
t := float64(DaysPerMonth * MonthsPerYear)
d := float64(HoursPerDay)

offsetDay := math.Mod(float64(dayOfYear)+(float64(SolsticeMonthsOffset)/MonthsPerYear)*t, t)

a := -d / (0.5 * t * t)
b := d / (0.5 * t)
c := 0.5 * d

time := a*float64(dayOfYear*dayOfYear) + b*float64(dayOfYear) + c
time := a*float64(offsetDay*offsetDay) + b*float64(offsetDay) + c
return time - transitionTime/2, time + transitionTime/2
}

Expand All @@ -123,10 +125,12 @@ func getSunriseTime(dayOfYear int) (start float64, end float64) {
t := float64(DaysPerMonth * MonthsPerYear)
d := float64(HoursPerDay)

offsetDay := math.Mod(float64(dayOfYear)+(float64(SolsticeMonthsOffset)/MonthsPerYear)*t, t)

a := d / (0.5 * t * t)
b := -d / (0.5 * t)
c := 0.5 * d

time := a*float64(dayOfYear*dayOfYear) + b*float64(dayOfYear) + c
time := a*float64(offsetDay*offsetDay) + b*float64(offsetDay) + c
return time - transitionTime/2, time + transitionTime/2
}
2 changes: 2 additions & 0 deletions game/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const (
HoursPerDay = 20
DaysPerMonth = 10
MonthsPerYear = 8

SolsticeMonthsOffset = 1
)

type Season int
Expand Down

0 comments on commit 613c3f4

Please sign in to comment.