Skip to content

Updated Inner Cone formula for Spot Lights in GLTF - #6078

Merged
kimkulling merged 2 commits into
assimp:masterfrom
crazyjackel:crazyjackel-update_gltf_falloff
Jun 5, 2025
Merged

kimkulling merged 2 commits into
assimp:masterfrom
crazyjackel:crazyjackel-update_gltf_falloff

Conversation

@crazyjackel

@crazyjackel crazyjackel commented Mar 31, 2025 •

Copy link
Copy Markdown
Contributor

Noticed an easy TODO whilst going through the code.

Updated the Inner Cone formula such that exponent values of 0 result in no inner cone and large exponent values result in a inner cone being most of the cone angle-wise.

GLTF 1.0 spec for KHR_materials_common is rather lack-luster in detailing falloffExponent. https://github.com/KhronosGroup/glTF/tree/main/extensions/1.0/Khronos/KHR_materials_common

Updated the Inner Cone formula such that exponent values of 0 result in no inner cone and large exponent values result in a inner cone being most of the cone angle-wise.
@sonarqubecloud

Copy link
Copy Markdown

@turol

turol commented Apr 1, 2025

Copy link
Copy Markdown
Member

Can l.falloffExponent be -1.0? If so, this will end up dividing by zero.

@crazyjackel

Copy link
Copy Markdown
Contributor Author

Can l.falloffExponent be -1.0? If so, this will end up dividing by zero.

The spec and the schema lists it as a number. So spec-wise, it can be -1.0, practically, I have no clue what this would actually mean. The spec is very undetailed on this field, but gltf 1.0 is mostly deprecated anyway, just need to provide a way to convert to gltf 2.0 or the rare case wherein you want to use older unmaintained software with newer models.

I think using absolute values should be fine for the algorithm.

ail->mAngleInnerCone = l.falloffAngle * (1.0f - 1.0f / (1.0f + std::abs(l.falloffExponent)));

@tellypresence tellypresence added Lights Bugs related to the light data glTF1.0 Bugs related to the glTF1.0 format. labels Apr 9, 2025

@kimkulling kimkulling left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine for me. Let's give it a try.

@kimkulling
kimkulling marked this pull request as ready for review June 5, 2025 07:41
@kimkulling
kimkulling merged commit 8621d52 into assimp:master Jun 5, 2025
@kimkulling

Copy link
Copy Markdown
Member

Merged, thanks for your contribution.

@sonarqubecloud

sonarqubecloud Bot commented Jun 5, 2025

Copy link
Copy Markdown

kimkulling added a commit that referenced this pull request Jul 1, 2026
Updated the Inner Cone formula such that exponent values of 0 result in no inner cone and large exponent values result in a inner cone being most of the cone angle-wise.

Co-authored-by: Kim Kulling <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

glTF1.0 Bugs related to the glTF1.0 format. Lights Bugs related to the light data

Projects

Development

Successfully merging this pull request may close these issues.

4 participants