-
Notifications
You must be signed in to change notification settings - Fork 312
Sky
Analysis is based on the decompiled source of the vanilla b1.7.3 client.
The celestial angle is defined by the following function, where X is a value between [0, 1].
Y = X + ( (1 - (cos(X * PI) + 1) / 2) - X ) / 3
Notch derives X from the current time-of-day (in ticks) divided by 24,000 (the number of ticks in a day-night cycle), minus 0.25. If X is less than 0, he adds one in order to keep the domain between [0, 1] as required by the equation. The reason Notch shifts the domain by 1/4 is not clear.
The following graph shows the result of Notch's celestial angle calculation function for inputs between [0, 24000] in increments of 240.
The World Sky Color is the multiplicative product of the base sky color, a brightness multiplier, and other multipliers related to weather events.
The base sky color is derived from the biome and temperature of the voxel in which the player entity currently resides. The input temperature is divided by 3 and the result clamped to [-1, 1]. Notch uses this constrained temperature to compute the color in the HSL coordinate representation where the hue, saturation, and lightness are defined as shown below. The result is then converted to RGB.
let hue := 0.6222222 - constrainedTemperature * 0.05
let saturation := 0.5 + constrainedTemperature * 0.1
let lightness := 1.0
Only the Sky biome overrides this computation to instead return a constant (0.75R, 0.75G, 1.0B).
The brightness multiplier is derived from the current celestial angle using the following function with the result clamped to [0, 1]:
Y = cos(celestialAngle * 2PI) * 2 + 0.5
TODO
The World Fog Color is derived from the current celestial angle. The exact calculation varies by dimension.
The celestial angle is transformed using the following function with the result clamped to [0, 1]:
Y = cos(celestialAngle * 2PI) * 2 + 0.5
The red, green, and blue components are then derived as follows:
let red := 0.7529412 * Y * 0.94 + 0.06
let green := 0.8470588 * Y * 0.94 + 0.06
let blue := 1.0 * Y * 0.91 + 0.09
The Nether ignores the current celestial angle and uses a constant (0.2, 0.03, 0.03) for the world fog color.
Minecraft renders the sky using a solid colored ceiling plane, floor plane, and fog. For the lowest two visibility settings, only fog is used. The sky is the first thing rendered in each frame.
-
Compute The Fog Color for the frame.
-
Clear the color and depth buffers. Fill the color buffer with the fog color.
-
Orient the camera. Aside for some minor effects, such as view bobbing, Notch avoids translating the camera until after the sky has been rendered.
-
Configure the Fog Parameters
-
Disable textures, Disable writes to the depth buffer, enable fog.
-
Draw the ceiling plane. Prepare a 128x128 plane tessellated from four equally sized quads. The plane should have extents which are [-64, 64] along the X and Z axis (so the anchor point lies in the center). Set the ambient color of both planes to the world sky color. Draw this plane at (0, 16, 0). This should result in the ceiling plane being centered above the camera. However, if you translated the camera prior to this step, you will also need to translate the ceiling plane.
-
TODO - Sunrise/Sunset coloring
TODO ...
Explain This
Explain This