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

SurfaceTool normals can't be smooth when UVs are added #6146

Closed
Zylann opened this issue Aug 13, 2016 · 4 comments · Fixed by #68034
Closed

SurfaceTool normals can't be smooth when UVs are added #6146

Zylann opened this issue Aug 13, 2016 · 4 comments · Fixed by #68034

Comments

@Zylann
Copy link
Contributor

Zylann commented Aug 13, 2016

Tested on Godot 2.1 beta and 2.1 stable, Windows 10 64 bits

When generating a surface with SurfaceTool and the add_smooth_group(true) method, it's impossible to get smooth normals if UVs are added to vertices.
I found that it specifically happens when UVs are not increasing from one vertice to another. So if every quad of a surface has UVs going from 0 to 1, the quad will be rendered with hard face normals.
Because of this I am forced to generate normals myself.

Not sure if it's a bug because I believe it was implemented so it does that. But as I said, it's possible to have smooth normals even in that case, so this can be enhanced.

Repro:
SurfaceToolSmoothShading.zip
Launch the main scene, see the generated surface on the left with UVs has hard faces, the one on the right doesn't and has smooth faces, while both have a smooth group.

@Toshiwoz
Copy link
Contributor

Toshiwoz commented Jun 29, 2018

HI @Zylann I was googling in search of the correct way to smooth a code generated mesh and I stumbled upon this.
I am using godot 3.0.4 and, using add_smooth_group as you are I am getting it correctly rendered, with UV.
[edit] I have to correct myself, the issue is still there, but I have to specify, as Zylann did in the code, that it works only if UV are spread over the mesh, but not when repeated for every quad:

# If UVs are spread, normals are smooth.
  var t00 = Vector2(p00.x, p00.z) / Vector2(sx,sy)
  var t10 = Vector2(p10.x, p10.z) / Vector2(sx,sy)
  var t11 = Vector2(p11.x, p11.z) / Vector2(sx,sy)
 var t01 = Vector2(p01.x, p01.z) / Vector2(sx,sy)

@Calinou
Copy link
Member

Calinou commented Jun 7, 2020

@Zylann Can you (or anyone else) still reproduce this bug in Godot 3.2.1 or 3.2.2beta4?

@Zylann
Copy link
Contributor Author

Zylann commented Jun 7, 2020

It still happens:
SurfaceToolSmoothShading.zip

I believe it happens because SurfaceTool assumes smoothing can only happen if vertices are shared, and to be shared vertices must have equal attributes. While it's true this case makes them have different UVs, smoothing should still be possible with two vertices with different UV, but giving two normals having the same value.

@akien-mga
Copy link
Member

Fixed by #68034.

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.

5 participants