Skip to content

Conversation

@ergoxiv
Copy link
Collaborator

@ergoxiv ergoxiv commented Feb 1, 2026

General optimizations to the Line object rendering pipeline, which is used in Anamnesis for the rendering of the gizmo circles, as well as the skeleton visual in the 3D Pose View. The goal is to minimize rendering overhead as much as possible to minimize stutters and hitches in Anamnesis.

The optimizations are primarily focused on the following aspects:

  • Use of Matrix4x4 as much as possible as System.Numerics data types utilize SIMD-type vector instructions, whereas Media3D ones do not.
  • Use of a cached viewport to avoid traversing the visual tree on each render tick.
  • Array object renting during geometry rebuilding to alleviate pressure on the garbage collector.
  • Streamlining the line rendering pipeline via a LineManager, which calculates the view projection matrix once for all lines and reuses it, as opposed to calculating it for each line individually.

Here are some before and after comparions:

Before (Character page):

In this case, the gizmo is still rendered in the background.

image
  • TryTransformTo2DAncestor - 4.5% of total user code.
  • OnRender - 0.8% of total user code.
  • TryWorldToCameraTransform - 0.3% of total user code.
    => Total: ~5.6%

After (Character page):

image
  • OnRendering - 0.8% of total user code.
  • UpdateGeometry - 0.04% of total user code.
    => Total: ~0.84%

Before (3D Pose View):

In this case, both the gizmo and skeleton are rendered.

image
  • TryTransformTo2DAncestor - 9.8% of total user code.
  • OnRender - 2.2% of total user code.
  • TryWorldToCameraTransform - 1.0% of total user code.
  • GetProjectionMatrix - 0.6% of total user code.
  • GetViewMatrix - 0.5% of total user code.
  • GetHomogeneousToViewportTransform - 0.2% of total user code.
    => Total: ~14.3%

After (3D Pose View):

image
  • UpdateGeometry - 2.2% of total user code.
  • OnRendering - 0.7% of total user code.
  • RebuildGeometry - 0.07% of total user code.
    => Total ~2.97%

@ergoxiv ergoxiv force-pushed the line-render-optimizations branch from 0cd419c to a31d96c Compare February 1, 2026 13:07
@ergoxiv ergoxiv force-pushed the line-render-optimizations branch from a31d96c to 8584d9e Compare February 9, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant