mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
docs: Import Clutter Rendering Model
wiki page
This one was overlooked when we migrated the wiki to the repo, so let's add it before we delete the wiki. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3485>
This commit is contained in:
parent
50936e9953
commit
40305f53f0
45
doc/clutter-rendering-model.md
Normal file
45
doc/clutter-rendering-model.md
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# Clutter Rendering Model
|
||||||
|
|
||||||
|
Clutter renders the stage and actors in a 3D space. Most of the time, all the scene is composed of only 2D actors. Remember that common operations, like rotating on the Z axis, and scaling and translating on the X or Y axis, do not make actors 3D, which allows Clutter to optimize rendering for 2D.
|
||||||
|
|
||||||
|
## Camera
|
||||||
|
|
||||||
|
ClutterStage builds the view matrix (i.e. the matrix that transforms world coordinates into camera coordinates) assuming that the camera is placed at (0, 0, 0) with a normal (0, 0, -1). That means the camera is pointing *down*:
|
||||||
|
|
||||||
|
![camera](data/clutter_camera.png)
|
||||||
|
|
||||||
|
The camera is implicit, and as of now, hardcoded.
|
||||||
|
|
||||||
|
## Perspective
|
||||||
|
|
||||||
|
When setting up the projection, ClutterStage uses a traditional perspective projection, with the addition of a "2D plane". The 2D plane (`z-2d`) is a plane in the Z axis that all the stage will be rendered into. The perspective projection is build with the following parameters:
|
||||||
|
|
||||||
|
* **field of view Y**: 60º (hardcoded)
|
||||||
|
* **aspect**: width / height (depends on monitor configuration)
|
||||||
|
* **z-near**: 1.0 (hardcoded)
|
||||||
|
* **z-2d**: `z-near + z-near * 49,36` ( = 50,36)
|
||||||
|
* **z-far**: `z-2d + z-2d * tan(30°) * 20` ( = 631,97)
|
||||||
|
|
||||||
|
![view cone](data/clutter_view_cone.png)
|
||||||
|
|
||||||
|
## Culling
|
||||||
|
|
||||||
|
Figuring out what **not** to draw is an important optimization of the rendering process. Clutter relies on clip frusta to detect which actors it can skip drawing.
|
||||||
|
|
||||||
|
### Depth Culling
|
||||||
|
|
||||||
|
The z-near and z-far values above are used to build the clip frusta, which culls out actors based on their position. If they're below than z-far, or above z-near, they are not rendered:
|
||||||
|
|
||||||
|
![view cone with z-culling](data/clutter_view_cone_with_z_culling.png)
|
||||||
|
|
||||||
|
### Clip Regions
|
||||||
|
|
||||||
|
Clutter supports defining which regions of the 2D screen changed. Suppose you hover a button; only the rectangle that that button cover is redrawn, instead of the entire screen. For example:
|
||||||
|
|
||||||
|
![clip region](data/clutter_clip_region.png)
|
||||||
|
*GNOME Shell with 3 clip regions (green)*
|
||||||
|
|
||||||
|
This is translated to the 3D scene by using multiple clip frusta. Each frustum is a slice of the view cone, and only those actors and geometry and intersects it is rendered. If an actor doesn't touch any of the frusta, it is skipped when drawing.
|
||||||
|
|
||||||
|
![clip frusta](data/clutter_clip_frusta.png)
|
||||||
|
*View cone with 3 clip frusta (green)*
|
@ -11,6 +11,7 @@ Hardware acceleration pipeline abstraction layer. Handles things like allocating
|
|||||||
Compositing toolkit, containing an actor and render node based scene graph, and has features such as input event routing, transformation and animation. Handles compositing, both Wayland surfaces, X11 windows, and is the basis of the UI toolkit implemented by [GNOME Shell](https://gitlab.gnome.org/GNOME/gnome-shell). Originally a fork of [the Clutter project](https://gitlab.gnome.org/GNOME/clutter).
|
Compositing toolkit, containing an actor and render node based scene graph, and has features such as input event routing, transformation and animation. Handles compositing, both Wayland surfaces, X11 windows, and is the basis of the UI toolkit implemented by [GNOME Shell](https://gitlab.gnome.org/GNOME/gnome-shell). Originally a fork of [the Clutter project](https://gitlab.gnome.org/GNOME/clutter).
|
||||||
|
|
||||||
* [Frame Scheduling](clutter-frame-scheduling.md)
|
* [Frame Scheduling](clutter-frame-scheduling.md)
|
||||||
|
* [Rendering Model](clutter-rendering-model.md)
|
||||||
|
|
||||||
## Mtk
|
## Mtk
|
||||||
|
|
||||||
|
BIN
doc/data/clutter_camera.png
Normal file
BIN
doc/data/clutter_camera.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
BIN
doc/data/clutter_clip_frusta.png
Normal file
BIN
doc/data/clutter_clip_frusta.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 887 KiB |
BIN
doc/data/clutter_clip_region.png
Normal file
BIN
doc/data/clutter_clip_region.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1012 KiB |
BIN
doc/data/clutter_view_cone.png
Normal file
BIN
doc/data/clutter_view_cone.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 185 KiB |
BIN
doc/data/clutter_view_cone_with_z_culling.png
Normal file
BIN
doc/data/clutter_view_cone_with_z_culling.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 MiB |
Loading…
Reference in New Issue
Block a user