luvcraft/sky.lisp
Time of day in [0,1): 0 midnight, 0.25 sunrise, 0.5 noon. The game starts at half past six in the morning.
Mutable time-of-day state owned by a luvcraft session.
SLY can pause it, set a time, change its rate, or pin it without restarting.
Advance clock by a bounded frame delta unless it is paused.
How many real minutes one of clock's days lasts.
A profile is a cyclic sequence of keyframes over the day fraction. Colours are 3-element single-float vectors; scalars are single floats.
Make a profile from keyframes, sorted cyclically by day fraction.
The keyframes bracketing day-fraction and the progress between them.
day-fraction coincides with a keyframe boundary.
One evaluated frame of environment state. CPU trigonometry is right for a single sun direction; per-pixel sky shaping stays in the shader.
The shader and CPU side share the definition in luvcraft.QUANTITIES. This
binding checks its ordinary single-float ABI against the actual sky-frame
slots once; calls below receive and return unwrapped numbers.
Return production fog attenuation at view-distance for evaluated sky.
The axis the sun revolves around: world Z, because the orbit is a circle in the X/Y plane displaced along Z.
Anything which needs a stable reference direction transverse to the sun should use this rather than world up. The sun's angle to this axis is the same at every hour, so a basis built from it is uniformly well conditioned; a basis built from world up degenerates toward the sun's own direction as the sun climbs.
The unit sun direction: rising at 0.25, zenith-adjacent at 0.5.
The orbit tilts slightly out of the X/Y plane so light stays directional even at noon.
Evaluate clock against profile once for the coming frame.
Day factor follows the sun's elevation with a soft twilight band, so direct light fades out while the sun crosses the horizon.
A clear-day profile whose noon matches the world's original literals.
midnight
pre-dawn
sunrise
morning
noon
afternoon
sunset
dusk
deep night
(clock profile)Mutable time-of-day state owned by a luvcraft session. SLY can pause it, set a time, change its rate, or pin it without restarting.
Division of two represented quantities.
Logical disjunction of tests and raw truth values.
A standard class whose annotated slots retain quantity declarations. Slot access and instance representation remain ordinary CLOS. The metaclass only makes definition-time meaning inspectable and inheritable. #OXBSAY
(clock seconds)The non-negative remainder of integer division.
Addition over compatible quantities.
Multiplication and scalar scaling.
(clock)(name-and-options &body slot-descriptions)Define an ordinary structure whose annotated slots publish quantity meaning. The runtime representation and accessors are still those of DEFSTRUCT. #FLRFU8
(keyframes)Test whether one compatible scalar is less than another.
(from to amount)Subtraction or unary negation.
(from to amount)(edge0 edge1 value)The maximum of compatible quantities.
The minimum of compatible quantities.
(profile day-fraction)Test whether two compatible scalars are equal.
Logical conjunction of tests and raw truth values.
(x y z)The interactive block world built on luv.
(&key representation-type quantity-specification quantity-layout source-form)(options &key (default-tensor-order 0))Parse one source declaration plist into a quantity specification. Return NIL when OPTIONS contains no quantity attributes. This is the common source seam used by arithmetic parameters, shader interfaces, and semantic storage declarations; callers retain ownership of their source-specific error conditions and…
(definition &key parameter-representation-types result-representation-type)(realization actual-parameter-declarations
&key actual-result-declaration)(record slot-name)(sky view-distance)How far the solar orbit leans out of the world X/Y plane.
(name (&key label (group :grading) documentation
(class ''scalar-knob)
quantity (type 'single-float)
unit-label minimum maximum step)
place)Define NAME as a knob of CLASS over the setf-able PLACE. PLACE may refer to SESSION, so a knob can live on the session -- its sky clock, its player -- as well as in a special. QUANTITY is a quantity plist as DEFINE-QUANTITY-CONSTANT takes, (:quantity ... :unit ...); it and TYPE make the knob's declaration, which…
()The axis the sun revolves around: world Z, because the orbit is a circle in the X/Y plane displaced along Z. Anything which needs a stable reference direction transverse to the sun should use this rather than world up. The sun's angle to this axis is the same at every hour, so a basis built from it is uniformly well…
(day-fraction)The unit sun direction: rising at 0.25, zenith-adjacent at 0.5. The orbit tilts slightly out of the X/Y plane so light stays directional even at noon.
The componentwise square root of a raw value.
The sky environment: a small session clock and a keyframed day profile.
The environment is continuous and frame-wide: Lisp evaluates the clock and profile once per frame into
sky-frame-parameters, and shaders evaluate spatially varying image mathematics from those uniform lanes. The clock is a session object with mutable runtime identity worth inspecting; the profile is ordinary data. There is deliberately no sky class hierarchy until more than one actual sky model exists.