Table of Contents

Class SceneSkylight

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

An opening in a cave's roof up to the sky (2026-10-20, caves livened; Skylight): where its emitter stands and how its seed carries the opening's height over it, and the two measures every presenter of it agrees on — how much of the sky a point under it sees (SkyShare(Vector3, float, Vector3)) and whether the sun falls on it through the opening (InBeam(Vector3, float, Vector3, Vector3)). One definition read by the client's skylight presenter (CaveSkylights: the shaft, the motes, the sky let in round it), its bounce light (SiteLightPool) and the lit surfaces' underground darkness (FishSkylights.hlsl, which mirrors these two functions line for line).

public static class SceneSkylight
Inheritance
SceneSkylight
Inherited Members

Remarks

Why the sky's share. Underground the lit surfaces take no sky and no sun (FishUnderground: their ambient and the sun's term are taken off, since the cave's deep rock casts no shadow). Under an opening that is wrong: the throat's walls near the top are as good as outdoors, and the floor under it sees a patch of sky — the share a disc of the opening's radius fills of a point's sky (r² / (r² + h²) on its axis), boosted a little for the light the throat's sunlit walls throw down, falling off faster off the axis where the rock hides the opening.

Why the beam. The sun's term is kept, not taken off, where a line toward the sun leaves through the opening: the shadow map (the terrain's, its hole clipped; the rock round the opening, which casts) then lights exactly the patch the sun reaches and no more.

Fields

BeamInner

Where a beam's edge fades, as shares of the opening's radius: the shadow map draws the real edge inside it.

public const float BeamInner = 0.8

Field Value

float

BeamOuter

Where a beam's edge fades, as shares of the opening's radius: the shadow map draws the real edge inside it.

public const float BeamOuter = 1.15

Field Value

float

DefaultRadius

The opening's radius when its emitter names none, metres.

public const float DefaultRadius = 4

Field Value

float

HeightBits

The bits of a seed that carry the opening's height over its emitter, decimetres (0–819.1 m).

public const int HeightBits = 13

Field Value

int

LitOver

How far over the floor under the opening its emitter stands, metres: where its light off the sunlit floor is.

public const float LitOver = 1.2

Field Value

float

LowestSun

The least the sun must stand over the horizon for any beam (its direction's y).

public const float LowestSun = 0.02

Field Value

float

MaxNear

Openings the shaders take at once (FishSkylights.hlsl's FISH_SKYLIGHTS).

public const int MaxNear = 4

Field Value

int

SkyBoost

How much the sky's share (a disc's view factor) is lifted for the light the throat's sunlit walls throw down.

public const float SkyBoost = 3

Field Value

float

SkyOffAxis

How much faster the sky's share falls off away from under the opening (the rock round it hides it).

public const float SkyOffAxis = 4

Field Value

float

Methods

BeamOnFloor(float, float, Vector3)

How much of the sun that comes in at an opening reaches the floor under it rather than the throat's wall, 0..1: all when the sun stands high enough over a shallow opening, none when it slants in so low it falls on the wall.

public static float BeamOnFloor(float height, float radius, Vector3 toSun)

Parameters

height float
radius float
toSun Vector3

Returns

float

Floor(in SceneEmitter)

The floor under the opening (world): the emitter less LitOver.

public static Vector3 Floor(in SceneEmitter e)

Parameters

e SceneEmitter

Returns

Vector3

Height(uint)

How far over its emitter the opening's middle is, metres.

public static float Height(uint seed)

Parameters

seed uint

Returns

float

InBeam(Vector3, float, Vector3, Vector3)

Whether a point under an opening has the sun through it, 0..1: a line from it toward the sun (toSun, unit) leaves through the opening, soft at the edge (the shadow map draws the true one). Nothing over the opening, nor with the sun at or under the horizon.

public static float InBeam(Vector3 opening, float radius, Vector3 toSun, Vector3 p)

Parameters

opening Vector3
radius float
toSun Vector3
p Vector3

Returns

float

Opening(in SceneEmitter)

The opening's middle on the ground (world).

public static Vector3 Opening(in SceneEmitter e)

Parameters

e SceneEmitter

Returns

Vector3

Radius(in SceneEmitter)

The opening's radius, metres.

public static float Radius(in SceneEmitter e)

Parameters

e SceneEmitter

Returns

float

Seed(float, uint)

A skylight's seed: the opening's middle height metres over its emitter, and a hash of its own over the rest.

public static uint Seed(float height, uint hash)

Parameters

height float
hash uint

Returns

uint

SkyShare(Vector3, float, Vector3)

How much of the sky a point sees through an opening, 0..1: all of it at the opening, the boosted share of a disc of its radius under it, falling off away from under it; nothing over it (the open air is not this one's to give).

public static float SkyShare(Vector3 opening, float radius, Vector3 p)

Parameters

opening Vector3
radius float
p Vector3

Returns

float

SkyShareAt(IReadOnlyList<SceneEmitter>, Vector3)

The greatest sky share at a point of any opening in a list of skylights (for the camera's own ambient).

public static float SkyShareAt(IReadOnlyList<SceneEmitter> skylights, Vector3 p)

Parameters

skylights IReadOnlyList<SceneEmitter>
p Vector3

Returns

float

SmoothStep(float, float, float)

HLSL's smoothstep (edges, then x): not Mathf.SmoothStep, which interpolates between its first two by its third.

public static float SmoothStep(float edge0, float edge1, float x)

Parameters

edge0 float
edge1 float
x float

Returns

float