Modules / Rendering & look

skydome3dplugin

The sky: the day clock, the sun and moon, weather and wind, fog, rain, snow and lightning.

Putting it in a scene

List it before render3d, and after terrain3d if it uses terrain3d's land (see Mods). The scene's sim lists the skydome3d kind from #plugins/skydome3d/skydome3d.sim.ts, and the scene has one { "is": "skydome3d" } actor whose prefab holds the row fields below.

"plugins": ["loader", "scenemanager", "player", "terrain3d", "skydome3d", "render3d"],
"world": {
  "seed": 1,
  "loader": { "assets": { "weathers": { "type": "json", "url": "/games/mygame/assets/weathers.json", "preload": true } } },
  "skydome3d": {
    "day": 1200,
    "weathers": "weathers",
    "soak": 20, "dry": 120, "lay": 60, "melt": 300,
    "gusts": [3, 7, 13],
    "bolt": { "lasts": [0.1, 0.4], "out": [300, 3000] },
    "look": {…},
    "precip": {…},
    "shadow": { "map": 2048, "half": 60, "near": 1, "far": 300, "bias": 0.0005, "normalBias": 0.02 }
  }
},
"prefabs": {
  "skydome3d": { "t": 600, "rate": 1, "doy": 172, "lat": 45, "phase": 0.5, "to": "clear", "from": {…}, "mix": {…}, "blend": 1, "fade": 0, "wet": 0, "pack": 0, "windDeg": 0, "flash": 0, "strike": [0, 0], "drift": [0, 0] }
}

The weathers file is a table of weathers by name:

{
  "clear": { "cloud": 0.15, "cirrus": 0.3, "base": 1800, "top": 2600, "dense": 0.3, "rain": 0, "snow": 0, "fog": 0, "haze": 0.3, "wind": 4, "gust": 0.2, "thunder": 0, "dust": 0 },
  "storm": { "cloud": 0.95, "cirrus": 0.2, "base": 900, "top": 3200, "dense": 0.9, "rain": 1, "snow": 0, "fog": 0.2, "haze": 0.8, "wind": 14, "gust": 0.8, "thunder": 4, "dust": 0 }
}

Weather

A weather is these 13 numbers, all required. The sky moves between weathers by blending every number.

NumberMeaning
cloudCover of the main cloud deck, 0 to 1.
cirrusCover of the high, thin cloud, 0 to 1.
base, topThe deck's lower and upper altitude, in metres.
denseHow thick and dark the clouds are. Thicker clouds also dim the sky and the lights.
rainAmount of rain, 0 to 1. Rain wets the ground.
snowAmount of snow, 0 to 1. At 0.02 or more, snow settles on upward-facing surfaces.
fogAmount of mist near the ground, 0 to 1.
hazeHaze in the distance, 0 or more.
windWind speed, in metres per second.
gustHow much the wind gusts, 0 to 1.
thunderLightning strikes per minute. A scene whose weathers thunder needs a world.seed.
dustAmount of blowing dust, 0 to 1.

Properties

The row

Read from the skydome3d actor's prefab. These change as the game runs and go to every seat.

FieldMeaning
t, rateThe time of day in seconds into a day, and how fast it runs. The clock advances rate sky seconds per second and wraps at day.
doy, latThe day of the year, and the latitude in degrees, north positive. They set where the sun and moon travel.
phaseThe moon's phase, 0 new and 0.5 full. It advances through a month every 29.53 sky days.
toThe name of the weather the sky is moving to.
from, mixEach a whole weather. from is the weather the sky left, and mix is the weather standing now. Sound, the HUD and the sea read mix.
blend, fadeHow far the sky is from from to to, 0 to 1, and the seconds the change takes.
wet, packHow wet the ground is and how much snow lies on it, both 0 to 1. They follow the weather with a delay.
windDegThe direction the wind blows toward, in degrees clockwise from north. 0 blows toward −z and 90 toward +x. It wanders as the wind gusts.
drift[x, z], the total distance the wind has blown, in metres. It positions the clouds and falling snow and rain, so every seat sees the same.
flash, strikeSeconds left of the current lightning flash, 0 when none, and where it struck, [x, z] in metres from the viewer.

World settings

Read from world.skydome3d. A child scene inherits them from the manager scene.

SettingMeaning
.daySeconds in a sky day.
.weathersThe loader catalogue name of the weathers file, a json entry with preload.
.soak, .drySeconds for the ground to get wet, and to dry. Longer is slower.
.lay, .meltSeconds for snow to build up, and to melt. Sunshine melts it faster.
.gusts[a, b, c]: three whole numbers of gust cycles per sky day. The wind returns to the same strength at midnight.
.bolt{ lasts: [lo, hi], out: [lo, hi] }: the range of a flash's length in seconds, and of its distance in metres.
.biomesOptional. Biome name to { scale?, add? }, each a partial weather: in that biome (terrain3d's), every number n becomes n·scale + add. The sky drawn is the weather under the camera, sliding from one biome's to the next as the camera crosses. Sound, wind, wetness and lightning stay the scene's.
.look, .precip, .shadowHow it draws, below. Page only.
.mods{ land: "terrain3d" } (see Mods).

.look

Colours are sRGB strings.

KeysMeaning
dayZenith, dayHorizon, nightZenith, nightHorizonThe sky gradient overhead and at the horizon, by day and by night.
setZenith, setHorizonThe colours the gradient is pushed toward at sunrise and sunset.
sunHigh, sunLow, moonThe colour of sunlight when high and when low in the sky, and of moonlight.
groundThe ground colour of the hemisphere light.
exposure, nightOpenskydome3d sets render3d's exposure every frame to exposure·(1 + nightOpen·night), where night runs from 0 to 1. A higher nightOpen brightens the night. Any exposure in render3d's settings is overwritten.
sunIntensity, moonIntensityThe strength of sunlight added to a base of 0.5 at midday, and of moonlight at full moon.
hemiDay, hemiNightThe strength of the sky-and-ground light by day and by night.
cloudScale, cloudSharpThe size of the cloud pattern in noise cycles per metre, and how sharp its edges are.
cloudDriftThe fraction of the wind drift that reshapes clouds, so they change as they travel.
cloudShadowHow much the cloud deck dims direct light on the ground.
cloudLit, cloudShade, liningThe deck's lit colour, shaded colour, and the bright edge where light shines through.
cirrusAlphaThe opacity of the high cloud.
godraysThe strength of light shafts through gaps in the clouds.
stars, starSizeThe strength of the stars, and a star's radius in cells of its grid.
twinkle, twinkles, twinkleSpreadHow deep the twinkle goes, the whole twinkles per day, and the largest whole-number multiple of that a star may be given.
sunShrink[lo, hi]: the sun's height over which its disc shrinks from 0.0115 to 0.0080 radians.
sunEdge, moonEdgeWhere a disc's edge starts to soften, as a fraction of its radius.
moonSizeThe moon's radius in radians.
snowScaleThe size of the pattern snow settles in, in cycles per metre.
flashHow far a lightning flash brightens the sky and the key light.
radiusThe dome's radius in metres. The render3d camera's far must be larger, or the sky is cut off.
overcastHow much cloudy weather darkens the sky and the lights.
haze, mistFog density: haze scales distant haze, and mist scales the weather's fog.
envSun, envMix, envIntensityThe sky is also the scene's reflection map. It is rebuilt when the sun has turned by more than envSun radians or the weather blend has moved by more than envMix. envIntensity is how strongly it lights things.

.precip

Rain, snow and dust fall in a box of range metres each way round the camera.

KeysMeaning
rangeHalf the width of the box, in metres.
rain, snow, dust, splashesThe most of each drawn, scaled by the weather.
edge, nearMetres over which a drop fades out at the box's edge, and fades in from the camera.
rainFall, rainLen, rainWidth, rainOpacityRain's fall speed in metres per second, streak length and width in metres, and opacity.
snowFall, snowSize, snowOpacity, snowSwayThe same for snow, with a sway.
dustFall, dustSize, dustOpacity, dustColour, dustSwayThe same for dust, with a colour.
swayPeriodSeconds. Each sway is rounded to a whole number of cycles of this.
splashSize, splashLife, splashOpacity, splashRingA rain splash's final radius, its life in seconds, opacity, and ring thickness as a fraction of its radius.
liftMetres a splash floats above the ground.
keyShareHow much of the key light lights falling rain, snow and dust, besides the hemisphere light.

A sway is [metres, radians per second, spread]: how far a flake wanders across x and z, how fast, and how much the rate differs between flakes.

.shadow

The key light, the sun or moon, always casts shadows. It needs render3d's shadows on, and meshes that cast and receive.

KeyMeaning
mapShadow map size in texels.
halfHalf the width of the shadowed box, in metres. The box follows the camera.
near, farThe box's depth along the light, in metres.
bias, normalBiasOffsets that stop surfaces shadowing themselves.

Methods

Acts

Closed acts. A rule calls them with w.call.

weather( name, fade )

Changes the sky to the named weather over fade seconds. If a change is under way, the new one starts from where the sky is now. A fade of 0 takes effect on the next step.

time( hours )

Sets the time of day, from 0 to 24 hours.

rate( x )

Sets how fast the clock runs.

moon( phase )

Sets the moon's phase, wrapped into 0 to 1.

place( lat, doy )

Sets the latitude in degrees and the day of the year.

On the page

Through plugins.skydome3d, undefined until the sky has drawn its first frame.

light( ) : object

The sky's light, for anything lit apart from the scene, such as a cockpit in render3d's overlay, and for the sea. The same object every frame, updated in place.

FieldMeaning
sun, sunColorThe direction toward the sun, and its colour scaled by its share of the key light. Zero once the moon has the key.
key, keyColorThe direction toward the body the key light shines from, sun or moon, and its colour times its intensity, including any lightning flash.
zenith, horizonThe sky colours overhead and at the horizon, in linear colour.
fogThe scene's fog.
sky, groundThe hemisphere light's two colours, times its intensity.

Mods

Name them in world.skydome3d.mods.

  • terrain3d
    land: rain splashes land on the ground, and with biomes the weather follows the biome under the camera. With no land, splashes are not drawn. List terrain3d before skydome3d.

Used by

  • ocean3d
    Takes its light and wind from the sky.
  • render3d
    Every dressed material gets the sky's wetness, snow and cloud shadows.

In the guide