godotengine / godot

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

Normals in imported 3D model look different when importing obj vs other formats #38854

Open setzer22 opened 4 years ago

setzer22 commented 4 years ago

Godot version: Godot Engine v3.2.1.stable.official

OS/device including version: Arch Linux (rolling release, last updated at the time of submitting).

Issue description: I have a 3d model (included below) created in blender. When I export this as an obj mesh, it works fine in godot. However, when exporting in any other format, Godot will show a very strange shading that looks like incorrect normals. See the pictures below for a comparison.

I first reported the issue in the forums and was recommended to report it here on GitHub: https://godotforums.org/discussion/22889/mesh-normals-imported-from-blender-look-wrong-with-every-export-type-except-obj#latest

This is the model imported as an obj mesh. The shading is correct:

blender8

This is how the model looks when importing it in any other format (tested: gltf2, dae, dae using the better collada plugin and fbx).

blender9

This shows (on blender) how the normals are set up. Everything looks normal there (yes, pun very much intended :sweat_smile:).

blender3

As recommended by users in the forums, the attached screenshots in Godot were taken with a very bare-bones environment: No sky, just clear color. White ambient light, and a single directional light shown on the picture to pinpoint the issue.

Steps to reproduce:

  1. Just import any of the 3d models in the attached file (see below)

Minimal reproduction project:

FenceMeshIssue.zip

Calinou commented 4 years ago

Does this occur if you check Triangulate Faces in the Blender exporter's export dialog? In general, it's better to make the 3D DCC triangulate the mesh when exporting rather than letting the game engine do it automatically.

Alternatively, you can add a Triangulate modifier and check Apply Modifiers in the export dialog. This lets you preview the triangulation interactively.

setzer22 commented 4 years ago

@Calinou I've tried both: Triangulating as an export option, and manually triangulating using the blender tool. Things look slightly differently when triangulating, but they all look wrong. In fact, the pictures I uploaded already show the model triangulated in blender (in this case, using the export option, but I tried both and it's the same). Here's a picture showing the same model imported without triangulating:

image

EDIT: Changed the picture for one where the lighting was more similar to the previous screenshots.

ee0pdt commented 4 years ago

On a Mac it's even worse, imported models have fully inverted normals. Screenshot below shows import from SketchFab next to a CSGBox to show the issue

image

Calinou commented 4 years ago

@ee0pdt Can you link to the model in question, please?

Favkis commented 3 years ago

@Calinou I have same problem

Look at pockets, they have wrong normals, but in editor they're fine

cargo_pants.zip

Favkis commented 3 years ago

Ok so I think it's another bug coming form that bug. After I import into godot I save mesh as .tscn scene. The problem is that after I save it over existing old tscn it somehow doesnt save new mesh but uses old mesh. Even if I delete tscn and save it. My fix was to save it as cargo_pants_v2.tscn