Skip to content

Conversation

kblaschke
Copy link
Member

In preparation for future changes and to make the rendering process less verbose, I've refactored all code related to drawing geometry (points, lines, triangles, quads, ...) into a small number of wrapper classes which store and manage the vertex data. Since I've reworked all rendering code in projectM in this changeset, here's an overview of what has changed:

  • The shaders used by TextureCopier are now cached.
  • Geometry/vertex attribute data is now stored in individual buffers instead of one single, interleaved block.
  • A new Mesh class manages the most frequently used buffers: position, color and texture coordinates.
  • The Mesh class always uses indexed rendering, e.g. using glDrawElements().
  • A few effects (Warp/Composite) use aditional vertex attributes. The indices of these attributes have been adapted to not interfere with the predefined three indices in the Mesh class.
  • The Warp effect now directly stores the grid vertex data in the Mesh class and draws the whole warp mesh in one draw call. This will require some testing on less capable hardware to see if this still exceeds some hardware limits!
  • The Motion Vector Grid no longer uses an attribute array for vertex IDs, as OpenGL provides this value in the predefined gl_VertexID uniform.
  • The Point data type in the default waveform implementations has been changed from the RenderItem type to the new Point class in the libprojectM::Renderer namespace.
  • A small wrapper around blend-mode-related functionality has been added to further reduce direct GL calls within effects.

Besides reviewing the code, helping with regression testing with presets would be really nice! I've already tested each effect thoroughly while implementing the changes, but some small mistakes may still be present.

@kblaschke kblaschke added this to the 4.2 milestone Sep 30, 2025
@kblaschke kblaschke self-assigned this Sep 30, 2025
@kblaschke kblaschke added the enhancement The feature is considered an enhancement. label Sep 30, 2025
@kblaschke kblaschke force-pushed the refactor-geometry-rendering branch 2 times, most recently from 6ec8ece to bfad7d1 Compare September 30, 2025 22:21
Reduced draw calls from 4/8 to 1/2 by specifying 8 vertices accessed via indices to draw each border in a single call.
Also get rid of the additional index attribute array, as gl_VertexID contains the same information and is free.
Now using the generated grid vertices and indices directly, drawing the warp mesh in a single draw call. This will increase the number of drawn vertices, but all GPUs made in the past decade can easily deal with 100K triangles or more.
@kblaschke
Copy link
Member Author

kblaschke commented Oct 1, 2025

Cherry-picked a commit from @kholbrook1303 from PR #907 on top of my changes.

Fixes issue #903

@kblaschke kblaschke force-pushed the refactor-geometry-rendering branch from 28435d5 to a242999 Compare October 8, 2025 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement The feature is considered an enhancement.

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

[DEV BUG] Sprite feature (4.2 release) has an issue causing the sprites to be vertically flipped

2 participants