Command Palette

Search for a command to run...

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

Reading and writing the same texture

1282 is the WebGL error code INVALID_OPERATION. Two targets taking turns (ping-pong) avoid it.

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?

Reading and writing the same texture
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

a shows a: 1282 (1282 = INVALID_OPERATION: reading and writing one texture)
a shows b: 0
b shows a: 0 (two targets, taking turns: ping-pong)