Skip to content

Commit b3a0901

Browse files
author
Florian Maas
committed
better node sizing on mobile devices
1 parent 0e12f40 commit b3a0901

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

frontend/src/shaders/instancedQuad.vert

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,23 @@ void main() {
4747
// At zoom 1: scale = 1.0, at zoom 25: scale ~= 1.8
4848
float zoomScale = 0.8 + 0.2 * sqrt(zoom);
4949

50+
// Reduce point size on smaller screens to prevent overlap when zoomed in
51+
// Reference: 1200px width = 1.0 scale, smaller screens get smaller points
52+
float screenScale = clamp(resolution.x / 1200.0, 0.5, 1.0);
53+
5054
// Calculate world size from pixel size
5155
// frustumHeight / resolution.y gives world units per pixel
5256
float pixelToWorld = frustumHeight / resolution.y;
5357

5458
// Point size with space for soft glow
55-
float worldSize = instanceSize * 1.3 * zoomScale * pixelToWorld;
59+
float worldSize = instanceSize * 1.3 * zoomScale * screenScale * pixelToWorld;
5660

5761
if (instanceSelected > 0.5) {
5862
// Selected: larger for emphasis
59-
worldSize = instanceSize * 1.8 * zoomScale * pixelToWorld;
63+
worldSize = instanceSize * 1.8 * zoomScale * screenScale * pixelToWorld;
6064
} else if (instanceHovered > 0.5) {
6165
// Hovered: same size as normal (no shrinking to prevent flicker)
62-
worldSize = instanceSize * 1.3 * zoomScale * pixelToWorld;
66+
worldSize = instanceSize * 1.3 * zoomScale * screenScale * pixelToWorld;
6367
}
6468

6569
// Billboard transformation

0 commit comments

Comments
 (0)