#version 430 // No SSBO — vertices are already in world space. // Just read vertex color for object ID and output it. in vec4 p3d_Vertex; in vec4 p3d_Color; uniform mat4 p3d_ModelViewProjectionMatrix; flat out int v_instance_id; void main() { // Decode object ID from vertex color R/G channels int low_byte = int(p3d_Color.r * 255.0 + 0.5); int high_byte = int(p3d_Color.g * 255.0 + 0.5); v_instance_id = low_byte + (high_byte << 8); // Standard transform — vertices already in world space gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex; }