Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 15.1 — Render Targets
3D Web · Example 2 of 3

A target that did not resize, and what targets cost

Sizes are printed in real pixels. The last two lines are plain arithmetic: width × height × bytes per pixel.

A render target is a picture the GPU draws into instead of the screen. It becomes a texture you can show on a mirror, a screen inside the scene, or feed to an effect. It costs memory, and it does not resize by itself.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 4 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Compute the memory of a half-float target for a 1366 × 768 screen at ratio 1, and of a chain holding two.

02

Write the lines that draw photoScene into target and then world to the canvas, restoring whatever target was active before.

Explain it without notes

01

What is a render target, and when would a showroom need one?

02

Why does a render target not resize with the canvas, and how do you keep them in step on a phone with pixel ratio 3?

A target that did not resize, and what targets cost
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

start:   canvas 300 x 150 | target 300 x 150
resized: canvas 600 x 300 | target 300 x 150  <- the target did not follow
fixed:   canvas 1200 x 600 | target 1200 x 600
1920 x 1080, ratio 1 | 8-bit RGBA 7.9 MB | half-float RGBA 15.8 MB | a composer holds two of the half-float ones: 31.6 MB
390 x 844, ratio 3  | 8-bit RGBA 11.3 MB | half-float RGBA 22.6 MB | a composer holds two of the half-float ones: 45.2 MB