Skip to content

Viewer: daylight look for the colored appearance; Quality tiers and a sky panel - #1217

Merged
wass08 merged 12 commits into
mainfrom
wawa/enhanced-rendering
Nov 5, 2026
Merged

wass08 merged 12 commits into
mainfrom
wawa/enhanced-rendering

Conversation

@wass08

@wass08 wass08 commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Gives the viewer's colored appearance a physically based daylight look, and reworks its settings. The monochrome appearance is unchanged.

Daylight rendering (@pascal-app/viewer)

  • A real sun position (site location and date) with a single shadowed key light, a PMREM sky environment, clouds, a ground that fades to the horizon, stars at night, and metered exposure with eye-like white balance.
  • A room light system: rooms, window portals and openings are found from the scene; lamps light their rooms (virtual ceiling lamps where a room has none); light comes through windows by day and spills out at night. Exterior lamps keep their spot cones.
  • Tuned materials: glass, EON rough diffuse, an albedo clamp (sRGB 40–243), and lamp emitters that follow their lamp's switch.
  • Outside at night, the exposure and white balance also take the lit rooms in view into account, so lamplit interiors no longer blow out from outside.
  • Exterior lamps shine at their authored intensity with plain N·L for spots, like the scene's real lights.
  • The shadow frustum reaches to where shadows meet the ground, so long shadows are no longer cut off.
  • three.js is bumped to 0.187. That release depads WebGPU readbacks itself, so snapshot (and feed) readbacks no longer depad a second time, which sheared captures into horizontal streaks.

Settings (@pascal-app/editor)

  • Quality: Auto · Low · Medium · High, replacing Solid/Rendered. Auto (the default) picks the tier from the device's capabilities: WebGPU availability, software adapter, GPU model, memory and form factor. It never uses frame rate. A manual pick still wins.
  • Edges are monochrome only, on/off.
  • Time & weather move to a chip beside the compass, in both the editor and the viewer, lined up with the bottom dock. It opens a Sky panel: drag the sun along its arc to any time, pick a preset (which eases the sun slowly), follow the live clock, or set cloud cover. The display menus point to it while it is mounted.

How to test

  1. Open a project in the editor or viewer with the colored appearance, then open the time/weather chip next to the compass.
  2. Drag the sun across the day and click presets (the light eases there); cycle the cloud cover from the chip.
  3. At night, compare a cutaway of lit rooms from outside with the view from inside a room, and check exterior wall lights and spots.
  4. Display → Quality: Auto shows the tier picked for your device; switch tiers.
  5. Take a snapshot at a canvas width that isn't a multiple of 64 px: the capture is intact.

Screenshots / screen recording

To be added before marking ready.

Notes

  • Known gaps: heavy baked scenes can run slowly on High (baked GLBs get no static mesh merging yet); thumbnails still use SSGI ambient occlusion.
  • Unit tests cover room lighting (hidden levels, viewed-room metering), device tiers, readback rows and the quality store.

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

🤖 Generated with Claude Code


Note

Medium Risk
Large changes to viewer lighting, post-processing, and UI state, plus a three.js minor upgrade that touches WebGPU readbacks and patched dependencies.

Overview
Introduces a physically based daylight look for the colored (textured) appearance and reorganizes how users control it. Solid/Rendered shading is replaced by Quality: Auto · Low · Medium · High (renderQuality), wired through shared QualityMenu components in the editor toolbar, viewer dock, and command palette.

Display menus now branch on a Colors toggle (textures): in colored mode users get DaylightMenu (or a link to the in-viewport control when SkyControl is mounted); in monochrome mode they keep scene theme and a simplified edges on/off toggle instead of soft/strong edge modes.

SkyControl adds a bottom-left chip (beside the compass, aligned with the dock) with time, weather cycling, and a panel for sun arc, presets, live clock, and cloud cover. The editor mounts it when colored mode is on (desktop, normal editing); capture presentFinished resets lighting to fair midday and restores the user's time/weather afterward.

three.js is upgraded to 0.187 (patched dependency and workspace overrides). PostProcessingResources now disposes effect nodes explicitly; ceiling-bracket tests stub destroyAttribute for the new WebGPU path.

Risk is concentrated in the rendering stack and dependency bump rather than auth or data handling.

Reviewed by Cursor Bugbot for commit 4295bd2. Bugbot is set up for automated code reviews on this repo. Configure here.

wass08 and others added 12 commits November 5, 2026 09:49
…und, time and weather presets

The colored appearance now renders with a built-in daylight atmosphere instead of the
scene theme's lights and backdrop; themes only tint the monochrome (clay) appearance.

- Sun from the site's location (parcel origin or dossier point; else a location the user
  granted with "Use my location", else a timezone guess) and its north rotation. Time-of-day
  presets (golden hour, midday, blue hour, night) are defined by sun elevation, not the clock.
- Art-directed sky keyed on sun elevation, fbm clouds with weather presets (clear, fair,
  cloudy, overcast), analytic image-based lighting from the same sky (no PMREM), metered
  auto exposure and eye-like partial white balance. Lamps turn on from blue hour.
- Neutral squared ground to the horizon (parcel slightly lighter), distance fog capped by the
  camera's far plane plus an angular horizon haze, so low views meet the sky softly.
- Post-processing: Neutral tone mapping, daylight grade + white balance + vignette in every
  shading; rendered shading adds a quality tier — high: GTAO on indirect light, TRAA, bloom;
  medium: half-res GTAO + TRAA; low: none. TRAA resolves the composited picture (sky
  included) and keeps the direct backdrop away from geometry.
- Solid shading stays Lambert: the daylight grounds follow it, the sky reaches it as a
  hemisphere light. Snapshots share the daylight grade and white balance; sheet captures pin a
  fair midday; transparent captures pin a fair midday and keep their alpha.
- Built only for hosts with a presentation (canonical/bake renders keep the plain path); a
  plugin atmosphere mounted later still takes precedence.
- Display menus: Time of day, Weather and Quality when colored; Scene theme when monochrome.
  The OSS toolbar gains the Colors toggle. Shared `DaylightMenu` exported from the editor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…REM sky, tuned materials; three 0.187

Ports the rest of the enhanced-viewer reference so the colored appearance renders the same:

- Room light (game tricks, lib/daylight/rooms.ts): zone polygons → a per-level room-id map; window
  glass portals (sky + ground bounce, rectangle form factor), the sky patch on the floor, the
  internally reflected bounce, enclosure (sky IBL ×0.1 indoors), walkable openings between rooms
  (doorways, arches) carrying the neighbour's light with a threshold crossfade, lamps as sized
  analytic sources with a per-room soft cap and a virtual ceiling lamp in rooms without one. At
  night lit rooms throw a gobo of their main lamp and a pane glow out of their windows, lamps
  outside every room light exterior surfaces analytically, and window panes glow with their
  room's lamps. Built from the live scene (registry + node data) or a baked artifact's identity
  tree, rebuilt after edits (uniforms/textures only, no recompiles), fed into the material
  lighting through getGI/getAO. The item-light pools hand their lamps to it instead of mounting
  point lights in daylight.
- Materials (one prototype hook, daylight renderer only): albedo range 40–243, EON rough diffuse
  on matte surfaces, night emission boost for lamp shades, tuned glass (distance/Fresnel opacity,
  near-mirror, night glow).
- Sky environment is a PMREM of the visible sky (aureole, no disc) at ×1.15; one shadowed key
  (sun, or the moon below 1°) with the reference bias/normal bias/radius, a light-space frustum
  fit and 4096/2048/1024 maps per tier; metered exposure from the zenith sky, +2 EV inside rooms
  (room meter), room-aware white balance; display-space vignette; 6 km far plane and the
  reference ground fade to the horizon.
- Quality tiers apply to both appearances and replace Solid shading (retired: the store always
  resolves to rendered, saved Solid picks become Low): High = GTAO on indirect light + TRAA +
  bloom, Medium = ½-res GTAO ×0.48 + TRAA, Low = FXAA (no AO), DPR caps 1.5/1.25/1. TRAA resolves
  the composited picture. SSGI leaves the viewport.
- Edges: monochrome only, on/off. Display menus: Quality in both appearances; Time of day and
  Weather when colored; Scene theme and Edges when monochrome.
- Fixes found on the way: the theme environment left scene.environmentIntensity at 0.6 under any
  atmosphere (lit every atmosphere at 60%); themes no longer drive lamps in the colored
  appearance; lamps that load late join the time of day; baked foliage is alpha-tested; the baked
  site fill becomes the daylight parcel; `<Viewer daylight={false}>` replaces the implicit
  `presentation={null}` switch for canonical renders.
- three 0.187.0 (patch re-applied to 0.187; normalView replaces transformedNormalView; test
  doubles follow the new renderer internals).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… emitters follow their lamp

- The metered exposure (up to ×4.6 at night) is for lit surfaces. Unlit scene materials (pool
  water, guides), the zone layer (fills, perimeter gradients), editor overlays and selection
  outlines are scaled by 1/exposure, so they keep their designed brightness instead of glowing
  (blown cyan pools, white floors and wall-base strips at blue hour, a veil over façades).
- Lamp shades and bulbs follow their own lamp, as in the enhanced viewer: the exported hue at a
  fixed display brightness (×4 display white, ÷ exposure) while the lamp is on, dark when off,
  even by day. Meshes are tagged from the lamp feeds; the switch is per object
  (`userData.daylightLampOn`), so lamps sharing a material switch independently. Other emissive
  surfaces keep the night boost.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s keep their cone; only the key light

- Lamp shades and bulbs follow their lamp through private node-material clones (the enhanced
  viewer's isolated emitters): emission = exported hue × display white ÷ exposure × that lamp's
  switch. Tagging meshes didn't reach glTF materials (the renderer converts them once, so the
  hook never recompiled) and switched-off lamps kept glowing. Clones are re-installed if an item
  swaps its materials and the originals come back when the daylight look leaves.
- Exterior lamps keep their spotlight cone (half-angle = angle / 2, soft edge = softness, as the
  light pools read them): wall washers light their cones and pools instead of the whole façade.
- In the daylight look only the key light is mounted: no moon slot, hemisphere or ambient light
  (they sat at 0 but still cost every material's shader).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
three r187 strips WebGPU's 256-byte row padding inside
readRenderTargetPixelsAsync. The snapshot pipeline depadded again, so any
capture whose width isn't a multiple of 64 px sheared into horizontal
streaks. The stride now follows the readback's exact length (readbackRows),
correct for both padded and tight buffers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the ground

The ortho shadow camera's depth was fitted to the casters alone, and three r187
reads a receiver beyond the far plane as fully lit, so long shadows were cut off
square. Extend the depth down each light ray to the ground; a shadow keeps its
caster's light-space x/y, so the map's texel density is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… indoors

- The star hash read negative cell seeds as one unsigned value, leaving half the
  sky empty: offset the cells positive (seed kept under 2^24). Stars are now
  small round dots at jittered spots, the brightest few crossing the bloom
  threshold for a faint glow.
- A camera over a level whose upper floors are hidden stood in those floors'
  rooms by height alone and was metered and white-balanced as a lamplit room.
  Only shown levels (and none above the focused one) count as indoors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Quality gains Auto, the default: the tier the device's capabilities call for
  (WebGPU or not, software adapter, GPU model, memory, form factor), detected
  once the renderer is up, before the first frame. A manual pick still wins.
- Time of day and weather move to a chip beside the compass (editor and viewer)
  opening a Sky panel: drag the sun along its arc for any time, presets, the
  live clock, cloud cover. The display menus point to it while it is mounted.
- The atmosphere takes an exact time (site sun clock) or the live clock; lamps
  follow the sun only when it crosses into or out of the evening.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… view

Outside, the meter read only moon and sky, so the exposure sat at its night cap
and lamplit rooms seen from out there blew out hot orange, while inside they
metered and white-balanced to their own light.

- The outside meter blends in the lit rooms in view, weighted by the share of
  the frame each fills (fully when open from above, a little through windows);
  rooms only ever lower the exposure, so daytime views are unchanged.
- Lamp light as drawn (not as metered) gives back most of what it is exposed
  above those rooms' indoor exposure, easing back to 1 indoors.
- The white balance adapts towards the rooms' light by their pull on the meter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…slowly

- The chip takes the bottom dock's height and offset (editor 58 px, viewer
  56 px, 24 px up) with the compass centred beside it, as in the design: a time
  button opening the panel and a weather button cycling the cloud cover. It
  drops its labels when the window-centred dock would crowd it.
- Presets and Reset ease the sun along its arc and the scene with it, the short
  way round the clock: 1.5–3 s by distance, easing in and out; dragging or the
  keys take over at once. The arc is solid as far as the sun, dotted beyond.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…shade plainly

Exterior lamps were lit with the rooms' metering value (log-compressed: a 7.2 cd
garage sconce became 13.1), boosted ×1.2, and shaded with wrap (0.75·N·L+0.25),
so a wall sconce painted bright hourglass cones up its own wall, edge-on and
close. They now use the light's authored candela (capped by the compressed
value, so physical-looking numbers stay tame), no boost, and plain N·L for
spots, as the scene's real lights do; omni lamps keep a little wrap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	packages/editor/src/i18n/locales/en-XA/messages.ts
#	packages/editor/src/i18n/locales/en/messages.ts
#	packages/viewer/src/components/viewer/glb-scene.tsx
@wass08
wass08 marked this pull request as ready for review November 5, 2026 22:14

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4295bd2. Configure here.

tween = requestAnimationFrame(step)
}
tween = requestAnimationFrame(step)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sun tween fights capture restore

Medium Severity

The sky preset ease is a module-level requestAnimationFrame loop that keeps calling setTimeOfDayMinutes until it finishes with setTimeOfDay. presentFinished never stops that loop, so a sheet capture that starts during the 1.5–3s ease still receives in-between times, and the tween’s done callback can overwrite the restore.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4295bd2. Configure here.

}
})
return compact
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dock check reruns every render

Medium Severity

useClearOfDock’s useLayoutEffect has no dependency array, so every SkyControl render tears down and recreates a ResizeObserver, re-queries the dock, and remounts window listeners. Preset eases and sun-arc drags write timeOfDayMinutes on every frame, so this work runs at animation rate while the light is changing.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4295bd2. Configure here.

@wass08
wass08 merged commit 54011f7 into main Nov 5, 2026
5 checks passed
@wass08
wass08 deleted the wawa/enhanced-rendering branch November 5, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant