[mutter] Add "Clutter Rendering Model" documentation



commit 71c96c6e59837a6abe10b53b695c77d1b280b6b0
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Oct 14 20:33:04 2020 +0000

    Add "Clutter Rendering Model" documentation

 Clutter-Rendering-Model.md | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
---
diff --git a/Clutter-Rendering-Model.md b/Clutter-Rendering-Model.md
new file mode 100644
index 0000000..0fb9500
--- /dev/null
+++ b/Clutter-Rendering-Model.md
@@ -0,0 +1,43 @@
+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*:
+
+![Clutter camera](uploads/cab69bf4891d2ca8d05f86c04c3e610c/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](uploads/bb933041d1ea66813411e5da78b54eca/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_](uploads/6f2cb3de6ab90e90a2da5a693020b09c/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](uploads/7944909989bcdda58b43f6528ea0aa10/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](uploads/8bd2b2d3acf5dfcdcb8891aff85a6e34/clip_frusta.png)
+*View cone with 3 clip frusta (green)*


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]