tecs.gfx.meshes

Per-view 3D lighting, shadows, ambient probes and environments.

A View owns one lighting configuration. Directional rays, point lights and spotlights illuminate all mesh materials except unlit ones. Three texel-snapped directional cascades and a local-light shadow atlas retain their maps until the scene, camera or relevant settings change. Ambient cubes and environments are independent: one provides diffuse irradiance, the other roughness-dependent specular reflections and the sky.

const lighting = tecs.gfx.meshes.newLighting()
lighting.shadows = true
lighting.ssao = true
world:spawn(tecs.gfx.View({
    camera3D = tecs.gfx.newCamera3D({y = 2, z = 6}),
    lighting = lighting
}))

Module contents

Types

TypeKindDescription
LightingrecordLights meshes with a directional source, optional fog and an ambient cube.

Functions

FunctionKindDescription
newLightingfunctionCreates independently mutable lighting settings with the documented defaults.

Types#

Lightingrecord#

record Lighting ...
@derive(nupp.derive.Debug)

Lights meshes with a directional source, optional fog and an ambient cube. A View owns these settings. Changes take effect on its next rendered frame.

Members

NameKindDescription
directionXfieldCaller-writable.
directionYfieldCaller-writable.
directionZfieldCaller-writable.
rfieldCaller-writable.
gfieldCaller-writable.
bfieldCaller-writable.
intensityfieldCaller-writable.
ambientfieldCaller-writable.
fogfieldCaller-writable.
fogStartfieldCaller-writable.
fogFinishfieldCaller-writable.
fogRfieldCaller-writable.
fogGfieldCaller-writable.
fogBfieldCaller-writable.
probefieldCaller-writable.
probeIntensityfieldCaller-writable.
shadowsfieldCaller-writable.
shadowScalefieldCaller-writable.
shadowDistancefieldCaller-writable.
shadowSplitLambdafieldCaller-writable.
shadowSplitBlendfieldCaller-writable.
shadowDepthPaddingfieldCaller-writable.
shadowStrengthfieldCaller-writable.
shadowBiasfieldCaller-writable.
shadowSoftnessfieldCaller-writable.
ssaofieldCaller-writable.
ssaoScalefieldCaller-writable.
ssaoRadiusfieldCaller-writable.
ssaoBiasfieldCaller-writable.
ssaoIntensityfieldCaller-writable.
ssaoPowerfieldCaller-writable.
localShadowsfieldCaller-writable.
localShadowSizefieldCaller-writable.
localShadowCapacityfieldCaller-writable.
localShadowBiasfieldCaller-writable.
localShadowSoftnessfieldCaller-writable.
environmentfieldCaller-writable.
environmentIntensityfieldCaller-writable.
skyboxIntensityfieldCaller-writable.
environmentRotationfieldCaller-writable.

directionXfield#

directionX: number

Caller-writable. Sets the X direction in which light rays travel.

directionYfield#

directionY: number

Caller-writable. Sets the Y direction in which light rays travel.

directionZfield#

directionZ: number

Caller-writable. Sets the Z direction in which light rays travel.

rfield#

r: number

Caller-writable. Sets non-negative directional red in linear space.

gfield#

g: number

Caller-writable. Sets non-negative directional green in linear space.

bfield#

b: number

Caller-writable. Sets non-negative directional blue in linear space.

intensityfield#

intensity: number

Caller-writable. Scales directional radiance.

ambientfield#

ambient: number

Caller-writable. Sets uniform ambient irradiance before the cube probe.

fogfield#

fog: boolean

Caller-writable. Enables linear camera-distance fog for meshes.

fogStartfield#

fogStart: number

Caller-writable. Sets the world distance where fog begins.

fogFinishfield#

fogFinish: number

Caller-writable. Sets the world distance where fog becomes opaque.

fogRfield#

fogR: number

Caller-writable. Sets linear fog red from zero through one.

fogGfield#

fogG: number

Caller-writable. Sets linear fog green from zero through one.

fogBfield#

fogB: number

Caller-writable. Sets linear fog blue from zero through one.

probefield#

probe: {number}

Caller-writable. Supplies 18 non-negative irradiance values, RGB for positive X, negative X, positive Y, negative Y, positive Z, negative Z. An empty array disables the probe. The normal's squared axes blend faces.

probeIntensityfield#

probeIntensity: number

Caller-writable. Scales the six ambient-cube faces.

shadowsfield#

shadows: boolean

Caller-writable. Enables three texel-snapped directional shadow cascades.

shadowScalefield#

shadowScale: number

Caller-writable. Sets shadow-map resolution relative to the larger viewport dimension.

shadowDistancefield#

shadowDistance: number

Caller-writable. Limits shadow coverage in world units beyond the camera near plane.

shadowSplitLambdafield#

shadowSplitLambda: number

Caller-writable. Blends uniform and logarithmic cascade spacing from zero through one.

shadowSplitBlendfield#

shadowSplitBlend: number

Caller-writable. Sets cascade cross-fade width from zero through one half.

shadowDepthPaddingfield#

shadowDepthPadding: number

Caller-writable. Adds non-negative light-space depth for off-camera casters.

shadowStrengthfield#

shadowStrength: number

Caller-writable. Scales shadow occlusion from zero through one.

shadowBiasfield#

shadowBias: number

Caller-writable. Offsets receiver depth to suppress self-shadow acne.

shadowSoftnessfield#

shadowSoftness: number

Caller-writable. Sets the 3 by 3 PCF radius in shadow texels; zero uses one location.

ssaofield#

ssao: boolean

Caller-writable. Enables mesh-only screen-space ambient occlusion.

ssaoScalefield#

ssaoScale: number

Caller-writable. Sets AO resolution relative to the viewport, up to one.

ssaoRadiusfield#

ssaoRadius: number

Caller-writable. Sets the positive hemisphere radius in world units.

ssaoBiasfield#

ssaoBias: number

Caller-writable. Offsets the occlusion comparison in world units.

ssaoIntensityfield#

ssaoIntensity: number

Caller-writable. Scales non-negative ambient occlusion strength.

ssaoPowerfield#

ssaoPower: number

Caller-writable. Sets positive AO contrast before the edge-aware blur.

localShadowsfield#

localShadows: boolean

Caller-writable. Enables shadows for lights carrying LIGHTCASTSSHADOWS.

localShadowSizefield#

localShadowSize: integer

Caller-writable. Sets each local shadow face edge in pixels.

localShadowCapacityfield#

localShadowCapacity: integer

Caller-writable. Limits shadow-casting lights in stable extraction order.

localShadowBiasfield#

localShadowBias: number

Caller-writable. Offsets local shadow receiver depth.

localShadowSoftnessfield#

localShadowSoftness: number

Caller-writable. Sets the local-shadow PCF radius in texels.

environmentfield#

environment: string?

Caller-writable. Selects the stable name returned by models.loadEnvironment.

environmentIntensityfield#

environmentIntensity: number

Caller-writable. Scales non-negative specular environment radiance.

skyboxIntensityfield#

skyboxIntensity: number

Caller-writable. Scales the sky background; zero hides it while retaining reflections.

environmentRotationfield#

environmentRotation: number

Caller-writable. Rotates the environment around world Y in radians.

Functions#

newLightingfunction#

function newLighting(): Lighting

Creates independently mutable lighting settings with the documented defaults.

Returns

TypeDescription
Lighting

caller-owned settings to attach to a View