Minimal proposal

  • Switch ClutterStage to an orthographic projection matrix.

  • Allow users to set up a perspective projection on a per-actor basis.

Rationale

Clutter has always used a perspective projection by default on the Stage; a perspective projection has the advantage of easily show the 3D transformations available with Clutter, but it does complicate the life and expectation of users that wish to have a pure 2D UI, with a specific 3D viewport only when needed, or no 3D viewport at all.

Going from a perspective projection to an orthographic one on a per-actor basis is also complicated by the need to unroll part of the matrix stack to avoid nodes in the scene graph to go out of sight.

Clipping is also complicated by the fact that we have to take into consideration a complex transformation scenario, even if most of our user base won't end up into it.

By switching to an orthographic projection as the default for ClutterStage we would have a default behaviour that kept scaling, as well as rotation along the Z axis, which are the two most common transformations used by Clutter developers; perspective transformation could be provided as a simple opt-in for actors to apply to their children, simply by changing the ClutterActor:child-transform matrix to have a perspective component, for instance:

  ClutterMatrix aMatrix = CLUTTER_MATRIX_INIT_IDENTITY;

  float zDistance = 850.f;
  aMatrix.zw = 1.0f / -zDistance;
  clutter_actor_set_child_transform (container, &aMatrix);

Implementation/changes

  • ClutterStage should set up an orthographic projection on the viewport.

  • Setting the ClutterActor:transform property provides an initial transformation, instead of a full replacement of the transformation.

    • This allows setting up a perspective transformation on an actor without clobbering the decomposed transformation API.

New API

  • No new API is necessary for this feature

Issues/discussion

Attic/Clutter/Strawman/Projection (last edited 2024-04-11 15:39:36 by EmmanueleBassi)