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 unable to set_smooth_group(-1) for create_from #75414

Open
qustrolabe opened this issue Mar 28, 2023 · 2 comments
Open

SurfaceTool unable to set_smooth_group(-1) for create_from #75414

qustrolabe opened this issue Mar 28, 2023 · 2 comments

Comments

@qustrolabe
Copy link

Godot version

4.0.1.stable

System information

Windows 11, Vulkan API Forward+, NVIDIA GeForce GTX 1650

Issue description

Using SurfaceTool there is no way to create surface using create_from() so that it will have "flat shaded" faces. set_smooth_group(-1) works only for all next add_vertex(...) but it's impossible to set that value while importing another mesh using create_from() function.

I believe that's an issue because you can clearly set_smooth_group for every vertex you add but those values nowhere to be edited in any way and SurfaceTool's commit_to_arrays as I see doesn't have array for them either.

Steps to reproduce

Simple steps are:

  1. Create mesh
  2. Use SurfaceTool's create_from(mesh_name, 0) to create surface based on that mesh
  3. Notice how no matter where and how you put set_smooth_group(-1) \ set_smooth_group(1) etc it doesn't matter and model always created smoothed

Reproduction project added that demonstrated default set_smooth_group(-1) behavior (on the left) and on the right simillar mesh created from PlaneMesh via SurfaceTool and small vertex editing via GDScript. Scene also has rotating DirectionalLight3D to better see how different those meshes are shaded.
1

Minimal reproduction project

Example.zip

@clayjohn
Copy link
Member

SurfaceTool is a tool for creating surfaces. create_from allows you to have a partially constructed surface pulled from a mesh. The surface will have the same properties that the mesh it was created from had (i.e. if the mesh was smooth shaded then the surface will be as well).

It sounds like you want to modify a mesh that was smooth shaded and make it flat shaded. In which case you should look into using the MeshDataTool, or manually editing the mesh arrays.

@qustrolabe
Copy link
Author

For sure, create_from works as it should. And I even managed to do the thing that I wanted by manually iterating over the
mesh arrays vertices and adding them one by one to the SurfaceTool with the required smooth group. I also managed to do exact same ( at least visually) thing with shaders ( NORMAL = -normalize(cross(dFdx(VERTEX), dFdy(VERTEX))); ).

It's just hard to understand what a smooth group actually is. From what I understand it's seems like some abstraction over normals. Maybe it's irrelevant to be able to edit them, but I can imagine how it would perfectly fit as an additional array in the mesh arrays. But if smooth groups are just another level of complexity over normals, then we already have ways to edit them and I believe the issue could be closed

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

No branches or pull requests

3 participants