devuiGuideDemosAPIGitHub

Textures

gui.texture(label, source) accepts:

GPU texture views need a WebGL2 context or a WebGPU device: a WebGL1 texture isn't shown.

Clicking a thumbnail opens an inspector:

A view starts as its texture's values are: sRGB for a canvas's, Non-colour for depths, integers, one- or two-channel floats and targets that hold data (three's normal, depth and distance materials write them), Linear otherwise. The thumbnail's header says how it's shown where that isn't plain light.

A view can start set up: gui.texture('depth', source, { channels: 'r', autoRange: true }), and any of level, layer, exposure, tonemap (clip, reinhard, aces, agx), channels (rgb, rgba, rg, r, g, b, a), black, white, encodeSRGB, layout, axis, attachment, depth and capture. What you change in the inspector is saved with the layout, and wins over these.

Pixels are shaded in your own GPU context and copied to the panel on the GPU. The numbers are computed there too, then read back a few bytes at a time, asynchronously:

Both backends share one set of display shading (tone mappers, overlays, false colour), so a texture looks the same in either.

renderer.render(scene, camera);
gui.update();   // optional: lets texture views copy from the frame you just drew

Without gui.update(), WebGL views fall back to asynchronous readback (a frame behind, never stalls). WebGPU textures outlive the frame, so WebGPU views don't need it.

Capture timing. A view normally shows a texture as it is at the end of the frame. A scratch target that's reused within a frame needs one of these:

const blur = gui.texture('blur 2', rt, { capture: 'manual' });
blurPass(rt);
blur.capture();   // a snapshot right now, so later passes into rt don't change what you see

gui.texture('ping', pingRT, { capture: 'on-write' });   // three.js: every write; `write: n` picks the nth

capture() takes a GPU snapshot at the moment it's called (with WebGPU, of the work submitted so far). With the three.js extension, on-write snapshots a render target each time rendering into it finishes, when setRenderTarget moves on. The view shows the last write of each frame, or the nth one. Snapshots happen only while the view is on screen.