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

Problems loading .obj with groups. #12542

Closed
prominentdetail opened this issue May 18, 2022 · 4 comments
Closed

Problems loading .obj with groups. #12542

prominentdetail opened this issue May 18, 2022 · 4 comments
Labels
bug in progress Someone is currently working on this issue loaders

Comments

@prominentdetail
Copy link

I have a user reporting a problem with their ability to import .obj file to babylon.js
https://steamcommunity.com/app/1244040/discussions/0/3280321332558564130/

I believe this is a bug in babylon.js

If you check the obj specifications: http://paulbourke.net/dataformats/obj/

usemtl material_name

Specifies the material name for the element following it. Once a
material is assigned, it cannot be turned off; it can only be
changed.

So my understanding is that it shouldn't have to respecify the material to use for each group if it is already specified.

Here are test files to confirm the bug:
babylonGroups.zip

If you drag the files into the babylon.js sandbox, you can see that one of the groups does not have the material set:
https://sandbox.babylonjs.com/

In comparison, other programs load everything just fine because they can parse the data correctly.

@deltakosh
Copy link
Contributor

Hello! as mentioned in the GIthub issue template please open the discussion in the forum first :)

@prominentdetail
Copy link
Author

I don't have an account on the babylon.js forum, and I don't use babylon. But since I have a github account, I chose to report the issue here since this issue is easily validated. Babylon.js is parsing .obj files incorrectly based on the specification of the .obj format. A user reported the issue to me, so I made the extra effort to report the issue to the babylon.js and supply a reproducable example. It wouldn't take much effort to check it yourself and see that the material isn't being assigned to the group.

If you read this: http://paulbourke.net/dataformats/obj/
You can see it reference what they call an "element." A single face would be one element.

Elements

o point (p)
o line (l)
o face (f)
o curve (curv)
o 2D curve (curv2)
o surface (surf)

It also states what "usemtl" does:

usemtl material_name

Polygonal and free-form geometry statement.

Specifies the material name for the element following it. Once a
material is assigned, it cannot be turned off; it can only be
changed.

material_name is the name of the material. If a material name is
not specified, a white material is used.

In this case, it states that it sets the material for the element following it. Even though the word element is singular in this case, does that mean that you must specify the material for each and every face? Obviously not.
"usemtl" specifies the material for the elements. Groups are not classified as elements, so a group shouldn't influence what elements a material gets assigned to.

Take a look at how other programs handle it, and you can also confirm these statements.

@deltakosh
Copy link
Contributor

Pinging @sebavan for follow up

@sebavan
Copy link
Member

sebavan commented May 18, 2022

On it :-)

@sebavan sebavan added bug loaders in progress Someone is currently working on this issue labels May 18, 2022
deltakosh pushed a commit that referenced this issue May 19, 2022
* Fix Obj group material propagation: fix #12542

* Fix nme tangents back compat and instance color

* format fix

* Format again...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug in progress Someone is currently working on this issue loaders
Projects
None yet
Development

No branches or pull requests

3 participants