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

Flat-shaded OBJ mesh is imported with more vertices in Godot 4 #71085

Closed
Zylann opened this issue Jan 8, 2023 · 3 comments · Fixed by #75315
Closed

Flat-shaded OBJ mesh is imported with more vertices in Godot 4 #71085

Zylann opened this issue Jan 8, 2023 · 3 comments · Fixed by #75315

Comments

@Zylann
Copy link
Contributor

Zylann commented Jan 8, 2023

Godot version

Godot 4 beta10

System information

Windows 10 64 bits NVIDIA GeForce GTX 1060

Issue description

In my game I process meshes to generate some data needed for some features. After porting it to Godot 4, some weird issues appeared and I realized Godot 4 is not sharing vertices of triangles in flat faces. Instead, they are ALL duplicated. At least, that's what I see when I inspect vertex data with surface_get_arrays. I do expect some vertices to be duplicated if they are on different faces (with different normals for example), but I don't expect it to be the case on every single triangle when the mesh is a quad for example.

This not only changes the behavior of my game since vertices supposed to be shared no longer are, but it also makes indexed vertices completely useless, because flat-shaded meshes end up with all triangles being individual. In Godot 3, triangles within a flat face were shared.

Steps to reproduce

Make a plane in Blender, export it as OBJ, import it in Godot, compare vertex arrays using a script to print the results of surface_get_arrays.

Result I get in Godot 3:

4 vertices, 6 indices
Vertices: 
(1, 0, 1)
(-1, 0, 1)
(1, 0, -1)
(-1, 0, -1)
Indices: 
0
1
2
2
1
3

In Godot 4:

6 vertices, 6 indices
Vertices: 
(1, 0, 1)
(-1, 0, 1)
(1, 0, -1)
(1, 0, -1)
(-1, 0, 1)
(-1, 0, -1)
Indices: 
0
1
2
3
4
5

Minimal reproduction project

Godot 3: PlaneImport_Godot3.zip
Godot 4: PlaneImport_Godot4.zip

Run each one's main scene, compare what is printed.

@Zylann Zylann changed the title Flat mesh reporting 4 vertices in Godot 3 is reporting 6 vertices in Godot 4 Flat-shaded mesh is imported with more vertices in Godot 4 Jan 8, 2023
@Calinou
Copy link
Member

Calinou commented Jan 8, 2023

Can you reproduce this with glTF or Collada import?

@Calinou Calinou added this to the 4.0 milestone Jan 8, 2023
@Zylann
Copy link
Contributor Author

Zylann commented Jan 8, 2023

It does not reproduce with gLTF.

@Calinou Calinou changed the title Flat-shaded mesh is imported with more vertices in Godot 4 Flat-shaded OBJ mesh is imported with more vertices in Godot 4 Jan 8, 2023
@Calinou
Copy link
Member

Calinou commented Jan 8, 2023

It may be worth checking if this occurs after disabling vertex compression in the Import dock.

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

Successfully merging a pull request may close this issue.

4 participants