Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofmodule renderer.module·originates fromworld 07158574-5…

shadows

Shadow caching and its page breakdown, the skinned and blended batching switches and the skinning pose hold, the shadow configuration and sizing, the caster cutoff, shadow proxies, the shadow views and the shadow hero.

by◐lumi·posted 5d ago
What it does

renderer.shadows

Shadow caching and its page breakdown, the skinned and blended batching switches and the skinning pose hold, the shadow configuration and sizing, the caster cutoff, shadow proxies, the shadow views and the shadow hero.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

module renderer.shadows global renderer Shadow caching, the batching switches, the shadow configuration, caster cutoff, proxies, views and hero.

setShadowCaching(enabled: boolean) → void

Whether a shadow page that nothing changed is kept rather than drawn again. On by default: every light's pages — the sun's, and each spot, area and point light's — are drawn again only where a caster that changed reaches them. Off, every requested page is invalidated and drawn on every pass, which is what a shadow suspected of holding a stale image is compared against.

argtypedescription
enabledboolean`boolean`

examples

renderer.setShadowCaching(false)  -- draw every requested shadow page, every frame

shadowCaching( ) → boolean

Whether a shadow page may keep the depth it already holds.

watchShadowPages(runs: number) → void

Gather a breakdown of what the sun's virtual shadow map does on each of the main camera's next `runs` runs. Each run's counts come back from the GPU a few frames after it, and `renderer.shadowPageBreakdown()` hands them over. Nothing is gathered while no reader has asked. `0` stops a gathering under way.

argtypedescription
runsnumberHow many of the main camera's runs to gather.

examples

renderer.watchShadowPages(120)

shadowPageBreakdown( ) →

The breakdowns `renderer.watchShadowPages` gathered since the last call, oldest first, one per run of the main camera. `levels` has a row per clipmap level: `texelWorld` (world units per texel), the pages it `requested`, held (`resident`), drew (`rendered`) and had dirtied by the frame's caster changes (`invalidated`), the pages those changes reach in its window (`reached`) and the smallest size a change projects to there (`smallestRecordTexels`). `records` lists each caster change with its light-space `sizeWorld`, whether it is a `tick` (a caster whose shadow moves every frame, reaching the levels its frame refreshes) and, per level, the `texels` it covers and the `pages` it reaches; `staticRecords` counts the changes that reach the static cache. `populationRuns` lists each instanced population whose every member writes a change this frame (`firstSlot`, `count`, whether it is `static` or a `tick`, and whether it carries its `old` and `new` boxes), and `movedPopulations` each population whose placement changed, whose members that moved write one (`firstSlot`, `count`). `cull` is what the page cull walked (`slotsWalked` caster slots, `ncMembers` casters drawn from their own vertex buffers) and kept (`pairs`, casters `tested`, `admitted` and `cutOff`, `chunks`, `visible` clusters, `ncPairs`, `batchPages`). `pages` has a row per batch page: its `level`, the `casters` it drew and how many changed this frame (`dynamicCasters`), its `chunks`, `clusters` and `triangles` with the changed casters' shares, and its pairs of casters drawn from their own vertex buffers (`ncPairs`, `dynamicNcPairs`).

examples

renderer.watchShadowPages(30)
task.wait(1)
for _, run in renderer.shadowPageBreakdown() do print(run.frame, #run.pages) end

setSkinnedBatching(enabled: boolean) → void

Whether skinned instances holding one pose draw together. On by default: instances of one mesh wearing one material and posed alike read the same post-skinned vertices, so the camera's colour passes submit them as a single instanced draw. Off, each skinned instance draws on its own at its own slot in every pass that rasterizes it. The image is the same either way, which is what makes this the comparison a frame suspected of being formed by the batching is made against — `renderer.drawStats().draws` counts the difference and `renderer.skinningStats().poses` says how many distinct poses it holds.

argtypedescription
enabledboolean`boolean`

examples

renderer.setSkinnedBatching(false)  -- a draw per skinned instance

skinnedBatching( ) → boolean

Whether skinned instances holding one pose draw together.

setBlendedBatching(enabled: boolean) → void

Whether neighbours in a view's blended order draw together. On by default: alpha-blended geometry is submitted queue by queue, the lower queue its material states first, and farthest-first within a queue, and a stretch of neighbours in that order sharing a mesh, a material, a shader and a pose is submitted as one instanced draw over those neighbours, which puts the same members on screen in the same order out of a single submission. A run stops wherever a differently-drawn renderable sorts between two of its members, and a mesh of several primitives keeps a draw per renderable — both would otherwise move fragments through each other. Off, every blended renderable draws on its own at its own slot, so a transparent crowd costs a draw per member. The image is the same either way, which is what makes this the comparison a frame suspected of being formed by the batching is made against; `renderer.drawStats().draws` counts the difference.

argtypedescription
enabledboolean`boolean`

examples

renderer.setBlendedBatching(false)  -- a draw per blended renderable

blendedBatching( ) → boolean

Whether blended neighbours sharing a draw key draw together.

setSkinningPoseHold(enabled: boolean) → void

Whether a pose the skinning pass already wrote is read as it stands. On by default: the pass produces an instance's vertices from its joint matrices, its node transforms, its blend weight and its blend model, so the slice holding a pose already holds what running the pass over those same inputs would write. A frame binding a pose whose slice still holds it reads the slice and dispatches nothing, and skinning costs what the frame's poses CHANGED — a paused clip, a skeleton nothing drives, a cast standing in one pose, each cost compute the frame the pose arrived and nothing after it. Off, every pose a frame binds is dispatched again, which is the comparison a frame suspected of reading a slice that no longer holds its pose is made against; the image is the same either way and `renderer.skinningStats()` counts the difference as `dispatches` against `held`. A mesh whose vertices a compute pass writes is dispatched every frame however this stands.

argtypedescription
enabledboolean`boolean`

examples

renderer.setSkinningPoseHold(false)  -- dispatch every pose, every frame

skinningPoseHold( ) → boolean

Whether a pose already written into its slice skips its dispatch.

shadowConfig( ) → ShadowConfig

The sun's shadow settings now in force. `distance` bounds how far from the camera the sun shadows (the world's `render.shadow_distance`, else the quality tier's, until `renderer.setShadowConfig` sets it); `fadeFraction` and `softness` shape how the shadow is sampled. The sun's virtual shadow map follows each receiver's screen footprint, so its resolution follows the view. `punctualMipFloor` is the finest mip a spot, area or point light's map renders. `detailBias`, `budgetMegabytes`, `pagesPerUpdate`, `updateRate`, `filter` and `localLights` are what a caller stated, or `"default"` where the quality tier's stands (`renderer.qualityTier().defaults.shadows`); what the renderer sized the pages with is `renderer.shadowSizing()`. The table is one `renderer.setShadowConfig` takes back.

examples

print(renderer.shadowConfig().distance)

shadowSizing( ) → ShadowSizing

What the sun's virtual shadow map was sized with. Its pool of pages holds about twice the pages a frame asks for at the render resolution of every camera that draws in it (the main camera, a headset's two eyes, cameras drawing into textures), within the depth budget (the quality tier's `renderer.qualityTier().defaults.shadows.budgetMegabytes`, or the one `renderer.setShadowConfig` states). It is sized again when the render resolution, the detail bias or the budget changes, and when cameras that were not drawing begin to; cameras that stop leave it as it is. A run of any camera that finds no slot for a page it asked for grows the pool to hold the pages the cameras asked for, within the budget. Once the budget holds no larger pool, the spot, area and point lights the camera sees smallest give up their detail and then their pages first (each light's `share` in `renderer.shadowViews()`), and a starved page of the sun raises `overflowBias` by a level, up to 4, until the pool is sized again. `distance`, `fadeFraction` and `softness` are the shading the renderer's lookups of the sun's pages take. What `renderer.setShadowConfig` states reaches the renderer ahead of every render drawn after it, an offscreen capture among them, and these read it once it has: a reading equal to what was stated says every render from then on draws with it. `direction` is the direction the light the map is made for travels along: the sun, or the distant light that casts and brings the most light once the sun brings less. A light travelling along it reads the map's shadow; a light along another direction casts none. It is absent while the map is made for no light.

examples

print(renderer.shadowSizing().depthMegabytes)

shadowCasterCutoff( ) → ShadowCasterCutoff

How small, and how far away, a caster may get before it stops writing depth into any shadow page. A shadow page rasterizes a caster's whole triangle count whatever the shadow it produces ends up covering, so an object the viewer resolves a fraction of a pixel of, and one past the range the scene cares about, each cost a full depth draw per page it reaches for detail nothing reads. Both thresholds are 0 — released — until something sets them.

examples

local c = renderer.shadowCasterCutoff(); print(c.minRadiusPx, c.maxDistance)

setShadowProxy(mesh: string, proxy: string) → void

Rasterize `proxy` in place of `mesh` in every shadow page. A shadow is a silhouette resolved at the resolution of a shadow map, so the triangles that carry a mesh's close-up detail write depth no reader can resolve — a decimated version of the shape, a level of its own LOD chain, or a hand-built hull casts the same shadow for a fraction of the geometry. The registration is keyed by MESH, so one call covers every instance of it — entities and GPU-driven populations alike — and a crowd sharing that mesh stays one draw. The proxy is placed by whatever places the caster, its instance's own transforms, so it stands where the caster stands, at the caster's scale. An entity caster keeps its own geometry where a stand-in could not be placed or deformed correctly: it is skinned (it rasterizes the post-skinned vertices written for its own mesh), it blends morph targets (whose deltas describe its own mesh and are read by vertex id), or its proxy would be placed by a different node of its model than the source mesh is. Either caster keeps it where the renderer holds no geometry under the proxy's guid. Each of those is counted in `renderer.shadowProxies()`. Nothing else in the scene draws a proxy, so this call is what brings it onto the GPU, and it raises where it cannot. A proxy already resident there is registered as it stands.

argtypedescription
meshstringThe mesh a caster draws, as a guid or any mesh reference.
proxystringThe mesh it rasterizes into shadow pages instead.

examples

renderer.setShadowProxy(statueMesh, statueHullMesh)
print(renderer.shadowProxies().triangles, "vs", renderer.shadowProxies().sourceTriangles)

clearShadowProxy(mesh: string?) → number

Stop proxying `mesh`, so it rasterizes its own geometry into shadow pages again. Called with no argument, drops every registration.

argtypedescription
meshstring?The mesh to stop proxying. Omit to clear all of them.

examples

renderer.clearShadowProxy(statueMesh)
print(renderer.clearShadowProxy(), "proxies dropped")

shadowProxies( ) → ShadowProxyReport

The shadow proxies in force and what the shadow pages did with them. `triangles` and `sourceTriangles` are what the main camera's newest counted run submitted through proxies and what the same (caster, page) pairs would have submitted from the source meshes — the before/after of every registration, equal while nothing is proxied.

examples

local p = renderer.shadowProxies()
print(("shadow triangles: %d of %d"):format(p.triangles, p.sourceTriangles))

shadowViews( ) → ShadowViewReport

Every shadow-casting spot, area and point light's virtual shadow map on the main camera's newest counted run, one row each. `renderer.shadowCacheStats()` and `renderer.shadowPageStats()` sum these counts over every light; this is the same run one light at a time. The sun's pages are reported by `renderer.shadowPageStats()`. Each row names its light and says what its pages did: how many its receivers asked for, how many it holds, how many were drawn, dirtied, starved or left for a later run, and what the page cull did with the casters it walked for the light. `camera` carries the main camera's share of the instanced-compaction counters. The counts come back from the GPU a few frames after the run, and `frame` names the frame they belong to. A light that stops casting leaves `views`. The frame names its lights only while something is reading them, so this call asks the frames after it to publish theirs and waits out the first one. Nil on an engine that renders no frame at all.

examples

local report = renderer.shadowViews()
for _, view in report.views do
print(("%s %d (%s): %d of %d pages resident, %d drawn"):format(
view.role, view.index, view.light, view.pagesResident,
view.pagesRequested, view.pagesRendered))
end

setShadowHero(entity: string, padding: number?) → void

Give one caster a finer sun shadow, in a box around its world bounds. The sun's virtual shadow map resolves every receiver at the level its screen footprint selects, so a character standing in the view gets the texel density every surface at its distance gets. A registered hero widens its bounds by `padding` into a box, and every receiver inside it requests and samples a level `renderer.shadowHero().levelBias` levels finer — each level halving the world a texel covers — where that level's window holds it, crossing back to its footprint's level at the box's edge. Nothing else about the shadow changes: the same casters reach it through the same filter. that leaves the bind-pose box and for the filter that samples outside a silhouette. 1.0 holds them exactly.

argtypedescription
entitystringThe entity whose renderables the box is made around.
paddingnumber?How much room the box leaves around those bounds — for a pose

examples

local before = time.drawnFrameCount()
renderer.setShadowHero(player.id)
local h = renderer.shadowHero()
while h.frame <= before do
task.waitDrawnFrames(1)
h = renderer.shadowHero()
end
print(("hero shadow: %d levels finer over %.1f units"):format(h.levelBias, h.worldExtent))

clearShadowHero( ) → boolean

Release the hero caster, so every receiver samples the level its footprint selects again.

examples

renderer.clearShadowHero()

shadowHero( ) → ShadowHeroReport

The registered hero caster and what the last drawn frame's box was. A frame that made no box says why in `decline`. `entity` is the live registration; everything else is the box of the drawn frame `frame` names, and stands until the renderer draws another. So a reading taken straight after `setShadowHero` or `clearShadowHero` describes the registration before the call: read the drawn frame count as the change is made, and take the report once its `frame` is past it.

examples

local h = renderer.shadowHero()
print(h.active, h.levelBias, h.decline)
local before = time.drawnFrameCount()
renderer.setShadowHero(player.id)
task.waitDrawnFrames(1)
print(renderer.shadowHero().frame > before)

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.