Skip to content

Use DrawArraysInstanced instead of geometry shaders for sprite rendering - #1704

Merged
nstlaurent merged 14 commits into
devfrom
entity-instanced
Jul 26, 2026
Merged

Use DrawArraysInstanced instead of geometry shaders for sprite rendering#1704
nstlaurent merged 14 commits into
devfrom
entity-instanced

Conversation

@nstlaurent

Copy link
Copy Markdown
Collaborator

This switches the geometry shaders used to generate vertices for sprite quads to use DrawArraysInstanced that selects the corner position in the vertex shader instead. Geometry shaders are effectively deprecated and are not supported at all on Mac OS. This uses the same basic idea where each entity sprite vertex is only generated once and is expanded and projected to a quad in the shader. This means the entity sprite vertex generation code stays practically the same with the majority of the changes being in the shader program.

This works by calling DrawArraysInstanced with a count of 4. gl_VertexID is used in the vertex shader to calculate which corner of the instance to use. Each vertex property sets the attribute divisor to one which advances the vertex once per instance of each invocation.

The performance seems to be the same but moves Helion out of the deprecated geometry shaders, simplifies the shader code by removing the geometry shader step, and allows for Mac OS support.

@nstlaurent
nstlaurent merged commit e38aad9 into dev Jul 26, 2026
1 check passed
@nstlaurent
nstlaurent deleted the entity-instanced branch July 26, 2026 11:49
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