Moguri / panda3d-gltf

glTF utilities for Panda3D
BSD 3-Clause "New" or "Revised" License
82 stars 19 forks source link

Multiple references to the same light node disables lights. #89

Open Clockwork-Muse opened 3 years ago

Clockwork-Muse commented 3 years ago

In GLTF, it's possible to have "duplicate" nodes that are re-used, such as multiple objects re-using the same mesh data. This includes lights; it's possible for multiple nodes to reference the same light entry:

    "extensions" : {
        "KHR_lights_punctual" : {
            "lights" : [
                {
                    "color" : [
                        1,
                        1,
                        1
                    ],
                    "intensity" : 10,
                    "spot" : {
                        "innerConeAngle" : 0.3337942263919169,
                        "outerConeAngle" : 0.39269909262657166
                    },
                    "type" : "spot",
                    "name" : "Spot"
                }
            ]
        }
    },
    "nodes" : [
        {
            "extensions" : {
                "KHR_lights_punctual" : {
                    "light" : 0
                }
            },
            "name" : "Spot_Orientation",
            "rotation" : [
                -0.7071067690849304,
                0,
                0,
                0.7071067690849304
            ]
        },
// .... later
        {
            "extensions" : {
                "KHR_lights_punctual" : {
                    "light" : 0
                }
            },
            "name" : "Spot.001_Orientation",
            "rotation" : [
                -0.7071067690849304,
                0,
                0,
                0.7071067690849304
            ]
        },
    ]

This is done in blender similarly to how it handles duplicate mesh references: image

Doing this, however, disables the lights entirely, for some reason. For a simple scene it generates: test instead of the expected: test


simple repro. Note that I'm not entirely sure whether this belongs here, in simplepbr, or inside panda itself...

repro.zip