Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FBXLoader: Loading FBX files with out-of-bounds material assignments lead to incorrect geometry groups and subsequent errors #30581

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

hybridherbst
Copy link
Contributor

@hybridherbst hybridherbst commented Feb 21, 2025

Description

The previous behaviour was a visual hole (invalid material) and hard-to-catch errors e.g. when using Mesh._computeIntersections or SkinnedMesh._computeIntersections.

In line with other FBX loaders (tested in Unity/Blender/F3D), a default material is now created. Note that "default material" is to be taken literal; the material looks different in all implementations I tested because their defaults differ, so I decided that's the most reasonable approach here as well.

Reproduction file:
response.fbx.zip

Screenshots

The hot pink parts have an invalid materialIndex already in the underlying FBX data (there's 6 materials in the file, the index here is "8"):
image

Unity just uses an existing default material for that problematic slot:
image

Blender just kicks out the wrong group and thus uses whatever the "last valid" material was, which is super confusing (e.g. if the last valid material was textured, that texture is now on random geometry).

This contribution is funded by Needle

…lead to incorrect geometry groups and subsequent errors

In line with other FBX loaders, a default material is now created.

if ( needsDefaultMaterial ) {

const defaultMaterial = new MeshStandardMaterial();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use MeshPhongMaterial here? FBXLoader already uses MeshPhongMaterial as a default material in parseMaterial().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants