See all glossary terms

Viewport

A viewport is a lens or view into our virtual game world. It's a rectangular area that captures visuals and sounds in the world and helps to output it to your computer display and speakers.
A game uses at least one viewport and can use as many as the developers need. The one required viewport is called the root viewport in Godot. In 2D, it is represented by the thin rectangle in the editor. If there is no Camera2D node in the game, the player will see the content of the rectangle. Otherwise, the viewport centers on the active camera node.
In 3D, a camera is required to capture the world's geometry, which is then used by the rendering engine to draw the game world.
When would you use more than one viewport?
We use more than one viewport for procedural drawing and visual effects. A viewport helps you to render an image. This image can be displayed directly on the player screen, but you can also use it as a node's texture.
A good example is split-screen co-op. When two players are at different locations in the game world, you need to draw two views of the game side by side. To achieve that, you use one viewport and camera per player.
Another good example is the game portal. When you create a portal, you see what's on the other side: A view of the world from a different place and angle. To draw this, you use another viewport and camera.
This technique is sometimes also used to draw mirrors in modern 3D games.