Log inGet started
Package

renderScale.package

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

renderScale system

The scene's resolution as a budget rather than a constant.

Shading cost scales with pixel count and with nothing else, so how many pixels the scene is rasterized into is the one lever that buys frame time without taking anything out of the frame — no feature switched off, no geometry removed, nothing missing from the image. What it spends instead is sharpness.

The renderer owns the lever (renderer.setResolutionScale). This package owns the decision: read what the GPU frame actually costs and move the scale toward the cost you asked for.

By default

At the governed quality levels (medium and low) the scene's resolution already follows the frame budget in every world: the quality governor holds the frame to the level's GPU budget (14 ms at medium, 28 ms at low) between a floor of 0.5 and the scale the tier chose. A world turns that off with the setting quality.<level>.dynamic_resolution = false and moves the floor with quality.<level>.min_scale. At high the scale is the tier's until something here takes it.

Using it

Put DynamicResolution on any entity in the scene and give it a frame budget:

entity(id).component.add("DynamicResolution", { targetMs = 16.6 })

Every field is live: edit targetMs in the inspector and the controller aims at the new number from the next frame.

For code that wants the budget without a component — a settings screen, a benchmark harness — reach for the module:

local RenderScale = require("@builtin::systems.renderScale.renderScale")

RenderScale.set({ target = 16.6, min = 0.6 })  -- take automatic control
RenderScale.step()                              -- one step toward the target
RenderScale.get()                               -- what it aims for, and last read
RenderScale.setScale(0.7)                       -- set it directly
RenderScale.scale()                             -- what the renderer has
RenderScale.off()                               -- stop steering

What the knobs do

fieldeffect
targetMsThe GPU's own frame time to hold. 16.6 is 60 Hz, 33.3 is 30.
minScale / maxScaleThe range the scale may move in, within the engine's own [0.25, 1].
rateHow much of the distance to the target one step takes. Lower settles more slowly and holds steadier.
deadbandHow far off the target a frame must be before the scale moves, as a fraction of the target. Without it the scale never sits still.

How it steers

The reading is the GPU's own time per frame, profiler.frameCost's gpu.own: its median over a window of window frames (30 by default), not one frame, because one frame's figure is noisy and a controller fed it oscillates instead of settling. Each window opens as the last one is read, so every step reads frames drawn at the scale the step before chose. The GPU's own time leaves out the time the CPU spends between a frame's submits, so a frame the CPU holds up leaves the scale where it is.

Pixel count moves with the square of the scale, so the scale that would have hit the target is the current one over the square root of how far off the frame was. A step takes rate of the way there, which is what keeps one heavy frame from throwing the scale across its whole range.

Files

renderScale.package/
  DynamicResolution.component/  -- the budget, authored and persisted
  renderScale.module/           -- set / step / get / setScale / scale / off