Skip to content

WebGL / Use only two attributes instead of four for storing the hit detection color#17031

Merged
jahow merged 1 commit into
openlayers:mainfrom
jahow:webgl-pack-hitdetection-color
Aug 13, 2025
Merged

WebGL / Use only two attributes instead of four for storing the hit detection color#17031
jahow merged 1 commit into
openlayers:mainfrom
jahow:webgl-pack-hitdetection-color

Conversation

@jahow

@jahow jahow commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

This PR packs the hit detection color in two bytes (instead of 4) in the WebGL buffers. This gives the following gain in the examples:

  • Points example: memory usage from 304MB to 230MB
    Gain: 24.3 %
  • Trajectories heatmap example: memory usage from 278MB to 246MB
    Gain: 11.5%
  • WebGL vector example: memory usage from 270MB to 203MB
    Gain: 24.8%

Following suggestions by @nssang00 in #16898

@github-actions

Copy link
Copy Markdown

📦 Preview the website for this branch here: https://deploy-preview-17031--ol-site.netlify.app/.

@jahow jahow force-pushed the webgl-pack-hitdetection-color branch from 81b32fd to 150278c Compare August 13, 2025 13:58
This will not cause any loss in precision
The UNPACK_COLOR_FN shader function was adjusted because its computation wasn't
quite exact and caused errors
It is also now always added to shaders in order to simplify logic (this won't
have an impact if it is not used in the shader)
@jahow jahow force-pushed the webgl-pack-hitdetection-color branch from 150278c to a4b7f70 Compare August 13, 2025 14:22

@ahocevar ahocevar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement. Thanks, @jahow !

@jahow jahow merged commit 4ef7d22 into openlayers:main Aug 13, 2025
8 checks passed
@jahow jahow deleted the webgl-pack-hitdetection-color branch August 13, 2025 14:42
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.

2 participants