Exporters: the outerConeAngle of lights needs to be divided by 2

Created on 22 Nov 2019  路  8Comments  路  Source: BabylonJS/Exporters

I think you are exporting there the FOV angle instead the value the specs require:

image

Notice the angle goes from the center to the edge, and that is half the angle.

Oh! And the same thing goes for the innerConeAngle.

bug maya

All 8 comments

Ah, looks like a simple fix, but I want to setup a test scene just to confirm that the spotlight angle according to the Maya API is measured centered on the direction ray, while the glTF spec expects it to be measured _from_ the center of the direction ray:

image

Ok, I think I have a functional test for this:

I have a simple scene where there are a nimber of spotlights positioned 1m above a plane, pointed downwards.

The spotlights have a varying "angles" in Maya: 5.625, 11.25, 22.5, 45.

If maya shares the same convention as glTF, I'd expect the resulting penumbras to have radii of:
radius = 1m * tan胃
[~.1m, ~.2m, ~.4m, ~1m] = 1m * tan([5.625, 11.25, 22.5, 45])

constructed in Maya, we get:
image

Where our widest light has a penumbra radius of ~.5m (given that the spotlight projection plane has a width of 1m.

Ok, you're completely right here.

TestSpotlightAngle.zip

Importing the .babylon exported scene, it looks like they share the same convention. Babylon must be performing some falloff and attenuation of the spotlight cone, so I had to increase the intensity to a ridiculous 100000:

image

Eeh, close enough. I'd interpret it as our largest light having a radius of ~1.

Testing the gltf export we get:
image

Crap. There must be some issue with how we are resolving the light orientation. I'll have to get back to this Monday to fix that as well.

In the meantime, manually applying a +270deg X rotation yields:
image

Which supports our original hypothesis. Looks like we should only modify the angle during our Babylon -> glTF export phase. I want to come back to this Monday to check that the behavior in 3dsMax is similar before making a change to the shared codebase.

Looking at 3dsMax, this appears to share the same "cone angle" nomenclature:

image

Exported to .Babylon, we get:
image

And to glTF from Max we get:
image

crap again. I'll open #696 to address the orientation issue as well.
Adjusted, looks like the issue is how we convert our in-memory babylon scene to glTF, this should be made to the shared exporter:
image

Fix looks good, after all that talking and testing, it was a single line:
image

Currently we don't support lightInnerAngle, but I'm interested in improving that support as well.

Currently I'm struggling to find some examples in the schema that show its behavior, and how to use it properly in Maya/3dsMax but if you can help with some samples that show the expected behavior, I'd be happy to make those changes as well.

Was this page helpful?
0 / 5 - 0 ratings