Open qustrolabe opened 1 year ago
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.
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
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:
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.
Minimal reproduction project
Example.zip