Files
fennec/planning/2D_GRAPHICS.md
2025-08-05 16:14:00 -04:00

2.0 KiB
Raw Blame History

2D Graphics (gfx2d)

Table of Contents

Introduction

This system handles the rendering of 2D meshes and textures.

Links:

Structures (gfx2d)

For the 2d rendering framework, Materials need to be rendered independently because we have
no size constraints for images. This disallows us from using a meta-shader like in
the 3d rendering framework.

struct Object
{
    vec2 location, scale; // A matrix would be 36 bytes, this is instead 20 bytes
    float rotation;
}
  • BVH

    • Quadtree
      • Leaf Size and Tree Depth should be calculated by the scene, constraints are as follows:
        • Min Object Size
        • Max Object Size
        • Scene Center
        • Scene Edge
      • Insertions and Updates are done on the CPU
      • Nodes
        • Start Index 32-bits
        • Object Count 32-bits
      • Objects
        • Buffer of Object IDs grouped by Octree Node
    • Culling
      • Starting at each Octree Leaf, traverse upwards.
      • Insert Visible Leaf IDs
        • Track using atomic buffer
    • Generate the Command Buffer for Culled Meshes from the Visible Leaf Buffer
      • Count Materials
      • Count Meshes per Material
    • Generate the Culled Object Buffer by copying objects from the Object Buffer
      • Adjust Buffer Size using the counts
      • Insert using another atomic buffer
  • Translucent objects will be sorted. We can cheat by using a z-index instead of a z-coordinate.
    This will allow us to sort objects as they are created. We can still bulk render each z-index,
    with meshes and objects being grouped by material.