vertex:
    inout: |
        // SSBO Layout - Default column_major matches Panda3D's internal layout
        layout(std430) buffer transforms {
            mat4 transform_data[];
        };
        
        // Input from Vertex Color (Baked ID)
        in vec4 p3d_Color;

    transform: |
        // Decode Local ID (p3d_Color stores Local ID within chunk)
        int low = int(p3d_Color.r * 255.0 + 0.5);
        int high = int(p3d_Color.g * 255.0 + 0.5);
        int id = high * 256 + low;
        id = clamp(id, 0, 65535);

        // Fetch Matrix from per-chunk SSBO
        mat4 model = transform_data[id];
        
        // Transform Position
        vOutput.position = (model * p3d_Vertex).xyz;

        // Transform Normal
        vOutput.normal = normalize(mat3(model) * p3d_Normal);

    post_transform: |
        // Motion blur disabled for performance
        
fragment:
    inout: |
        

    material: |
        vec4 tex_color = texture(p3d_Texture0, vOutput.texcoord);
        if (tex_color.a < 0.5) discard;
