Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / library / map / src / main / rust / shaders / pick.frag

pick.frag14 lines · 642 BRaw
1#version 450
2// Id-buffer pick fragment: write this feature's 1-based pick slot to the R32_UINT target, so
3// reading back the tapped pixel yields the slot (0 = nothing). The slot is carried as the bit
4// pattern of a float in the push block's `color.x` — `floatBitsToUint` recovers the exact u32,
5// which a plain float-to-uint cast would round. The whole quad writes the id: a marker's tap
6// box is its rectangle, which is what a generous touch target wants.
7layout(location = 0) out uint outId;
8layout(push_constant) uniform Push {
9 mat4 tileToClip;
10 vec4 color;
11} push;
12void main() {
13 outId = floatBitsToUint(push.color.x);
14}