Command Palette

Search for a command to run...

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

A turning cube on a screen inside the scene

The cube is drawn into a 256 × 256 texture, and a plane in another scene shows that texture. Watch the status bar: the geometry count and texture count.

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 turning cube on a screen inside the scene
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

target: 256 x 256 | is a render-target texture: true
textures on the GPU: 1 | draw calls in the last render: 1
size of the picture: 262144 bytes (4 per pixel)