godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.1k stars 21.18k forks source link

various issues with obj importer #9524

Closed fracteed closed 7 years ago

fracteed commented 7 years ago

Operating system or device - Godot version: Linux Mint and Win10

Issue description: Bug 1: When obj meshes are imported there is a visible shading discontinuity along the uv seams. However the same mesh imported as a dae/collada is fine. The meshes have been exported from blender. See project file and image below.

Bug 2: Most likely related to the above issue, but while this model has no uv's, the vertex normal information is not importing from the obj correctly. It looks similar to if the model in blender has the "autosmooth" normals button turned off. That is, it has smooth shading on, but the normals are being auto detected rather than using the custom normals information. As a test I imported this obj (from blender) into Unity, Substance, Cinema 4d, Houdini as well as back into blender. They all imported it correctly. See project file and image below.

Feature Request: The ability to import material groups/polygon selections via the obj importer. Blender and other packages support obj export via the "material groups" flag in the exporter. This allows 2 or more polygon/material selections for a single mesh.

Ideally Godot would be able to import a single obj mesh into a scene and expose these material groups, in the same manner that dae import works. This would allow separate materials for each material group. As far as I can tell, the material selection poly faces are tagged in the .obj file and the .mtl is not actually required unless there is need for the actual material(color, spec, etc) information.

I have included a basic blender file with an object split into 3 material groups. These should import into blender as the same 3 groups, and with the color (red, green, blue) information if there is also a .mtl file. The .mtl file should be considered as optional, since the user may not need the original material properties just to get the material group selections. Having a .mtl for every .obj file could clutter up a project, so it should be up to the user.

basic_obj_material_selections basic_obj_material_selections.blend.tar.gz

Steps to reproduce: Import an obj mesh and add material and environment.

Link to minimal example project: Bug1: This scene shows a sphere on left imported as dae with no artifact. The sphere on right is from obj importer and shows the uv seam artifact.

obj_seams

uvseam_test.tar.gz

Bug2: This screencap shows Blender(far left is the model as it should be with correct normals, next to it is the same model with "autosmooth" normals toggled off) and Godot3 (displaying the model imported as an obj with incorrect normal information). The zip file contains the blender file and the exported .obj

cubish2_compare

cubish_obj_normals_comparison.tar.gz

reduz commented 7 years ago

I can no longer reproduce any of these issues in master, so closing image image