EG/ssbo_component/shaders/pick_id.frag
2026-02-25 11:49:31 +08:00

22 lines
458 B
GLSL

#version 430
// Input from vertex shader
flat in int v_instance_id;
// Output: Object ID encoded as RGB color
out vec4 fragColor;
void main() {
// Encode instance ID into RGB channels
// R = low byte, G = high byte, B = 0, A = 1
int low_byte = v_instance_id & 0xFF;
int high_byte = (v_instance_id >> 8) & 0xFF;
fragColor = vec4(
float(low_byte) / 255.0,
float(high_byte) / 255.0,
0.0,
1.0
);
}