Commit Graph

18 Commits (master)

Author SHA1 Message Date
Kenny Levinsen c7b622e8dc Explain the use of multiple locus better
It was not entirely trivial to understand why the two locus were
implemented, and why there was a transition between them. Explain this
more explicitly.
2023-12-12 16:22:06 +01:00
Kenny Levinsen 966728a29b Calculate blend factor as double 2023-09-01 14:12:02 +02:00
Kenny Levinsen 8d1067a5aa Move feature defines to C files 2022-05-04 10:58:42 +02:00
Artur Sinila 20d37fb751 Refactor RGB & XYZ colors into structs 2022-01-25 11:23:07 +01:00
Kenny Levinsen bcbca9e065 Use illuminant D for the majority of temperatures
D65, the natural whitepoint that wlsunset assumes, is defined on
illuminant D, which simulates daylight with atmospheric effects.
However, we used planckian locus for all values under 6500 K, which
meant that there was a significant jump in color - specifically, a
sudden reduction in green and blue - as we started reducing the color
temperature.

Instead, we purely use illuminant D down to 4000 K where it is well
defined. Below 4000 K, illuminant D starts unintentionally approaching
the planckian locus, before finally breaking completely at 2000 K. We
extend the boundary of illuminant D to 2500 K and perform a
sine-smoothed transition to planckian locus from 4000 K to 2500 K to
extend the range of wlsunset down to 1667 K, where planckian locus ends
and we finally give up.

The end-result is a smooth transition along all valid temperature
values, with no sudden jumps as we had before. However, we do end up
with slightly greener/bluer colors than earlier. We'll have to see how
that holds up.
2020-11-11 16:40:37 +01:00
Kenny Levinsen 0703fbcc0e Minor line length reduction 2020-10-21 00:41:50 +02:00
Kenny Levinsen b9f0b8e3c0 Move longitude time correction out of calc_sun
calc_sun reported sun trajectory in seconds since the start of a UTC
day, as they would occur for the specified UTC day. The caller would
then add the UTC timestamp for the start of a UTC day to these numbers.
This lead to complications, as e.g. a sunrise in China would be a
negative value, as it occurred in the last UTC day.

Futhermore, the start of a UTC day was used to signal the need for new
sun calculations. This would lead to recalculations to possibly occur
after its results were needed, such as after sunrise when the target
longitude deviated significantly from the prime meridian.

To fix this, we apply longitude time correction to the start of day
calculation. This way recalculation will occur on the start of the
longitude local day, close midnight for the observer.

We also remove the longitude time correction from calc_sun, so that it
simply returning the number of seconds since the start of the local day
of the observer. The caller then adds the start of the longitude local
day to get the final numbers.
2020-10-19 14:18:28 +02:00
Kenny Levinsen 5c497febb7 Do not use -1 for sun calc error 2020-10-19 00:37:02 +02:00
Kenny Levinsen fdcdb04023 Remove clamp from color_math.h 2020-10-18 00:45:36 +02:00
Kenny Levinsen e14e8efcf3 Gracefully handle midnight sun/polar night
The sun trajectory calculation previously emitted garbage if midnight
sun or polar night phenomena was in effect. To fix this, the calculation
is overhauled to report if the computation failed, and if so, which
specific phenomena was the cause.

Timing recalulation uses this information to change out of the normal
state that uses the four sun position timings, into a static state where
wlsunset simply waits a day at a time for a normal sun trajectory
pattern to be restored. In this state, a fixedc high/low temperature is
set as appropriate for the phenomena.

A transition phase replicating the previous day's sunrise is used to
smooth out entry into a midnight sun, which would otherwise cause a
jarring instant-daylight setting.
2020-10-18 00:36:52 +02:00
Kenny Levinsen 7bd167e9d3 Split state from config, cleanup 2020-10-14 17:57:34 +02:00
Kenny Levinsen 7c22eade9a Change twilight interval to -3 to 6 2020-10-04 19:51:25 +02:00
Kenny Levinsen 83d90d2bea Calculate dawn and dusk times 2020-10-04 15:30:45 +02:00
Kenny Levinsen 88a6d1dd17 Fix stricter build errors 2020-09-13 21:38:56 +02:00
Kenny Levinsen 208fc141fb These trailing whitespaces were not invited 2020-09-13 21:33:52 +02:00
Kenny Levinsen 98148d6610 Remove year_radian 2020-09-13 21:22:17 +02:00
Kenny Levinsen a89ae834be Use sun trajectory 2020-09-13 21:12:44 +02:00
Kenny Levinsen 4f8559405f Move math out of main 2020-09-13 03:22:18 +02:00