BasePart shapes have unnecessary additional geometry

The geometry of all BasePart shapes currently has unnecessary geometry attached to each. I’ve made a simple list below displaying the current geometry of all shapes and fixed geometry:

Default Roblox Geometry

Block: 24 Vertices, 12 Triangles
Wedge: 20 Vertices, 10 Triangles
CornerWedge: 20 Vertices, 10 Triangles
Cylinder: 114 Vertices, 96 Triangles
Sphere: 294 Vertices, 432 Triangles

Fixed Geometry

Block: 8 Vertices, 12 Triangles
Wedge: 6 Vertices, 8 Triangles
CornerWedge: 5 Vertices, 6 Triangles
Cylinder: 50 Vertices, 96 Triangles
Sphere: 218 Vertices, 432 Triangles

I’ve also made two places displaying both the default roblox geometry for shapes and the fix for each shape. Both places can be downloaded. The FixedParts place will also perform way worse since its all parts are now using special meshes (results are the exact same with MeshParts, roblox pls fix).

Expected behavior

BasePart shapes should normally be using a lower amount of vertices and triangles than what they currently are using.

7 Likes

I’m not sure about the other shapes, but I know from first-hand experience that Cube meshes will always have to have 24 vertices instead of 8, because with only 8, some vertices will share normals and the lighting break, as well as it not working with texture UVs.

In fact, if I export the mesh back out of Studio, I end up with a mesh that has… 36 vertices…?

Not sure where the extra 12 came from, they might be because it’s not sharing the vertices between triangles on the same face or something.

Regardless, I assume that the mesh is being fixed during the import process, maybe when all the quads get converted to triangles, so that the mesh appears like it would in the modelling software.

4 Likes

When i fixed the old shape’s geometry, i specifically left them triangulated. Their triangles were never transformed into quads specifically because i wanted as closely of an example as possible to what roblox would by default have.

Also i’m not exactly sure how more (mostly unused) verts will fix lighting issues. Lighting issues will happen regardless, it just depends on how the mesh is built. Studio exporting back more geometry than initially made isn’t exactly a good thing either tbh, can’t tell if the geometry itself is just added during insertion or when exporting.

2 Likes

They are not unused. Every face of a cube points in a different direction, thus faces cannot share vertices with each other, because 1 vertex can only have 1 normal, and each face has to be comprised of vertices with normals corresponding to the direction of the face.

After some testing, it appears that Blender will automatically add the extra vertices to fix the lighting (because otherwise, the normals will be interpolated and the cube will be shaded really weird). I wrote a .obj by hand to verify that there are really 8 vertices. Upon exporting the file as a .gltf, and opening it in 3D Viewer, the vertex count had increased to 24:

8-vertex cube `.obj`
# 8-vertex cube @Judgy_Oreo 21/06/2024
# The winding order is incorrect, and the cube will be rendered inside-out with
# backface culling. Too bad!

# lower back left
v -0.5 -0.5 -0.5
# lower back right
v 0.5 -0.5 -0.5
# upper back right
v 0.5 0.5 -0.5
# upper back left
v -0.5 0.5 -0.5

# lower front left
v -0.5 -0.5 0.5
# lower front right
v 0.5 -0.5 0.5
# upper front right
v 0.5 0.5 0.5
# upper front left
v -0.5 0.5 0.5

# back face
f 1 2 3 4
# front face
f 5 6 7 8

# top face
f 1 5 6 2
# bottom face
f 3 7 8 4

# left face
f 1 4 8 5
# right face
f 2 3 7 6

I believe Blender is automatically adding the normals, realizing there aren’t enough vertices, and then tessellating the mesh during the export. There are 24 vertices, because each face has 4 verts, 4 * 6 = 24. 36 comes from triangles not sharing the same vertices on the same face, leading to an extra 2 verts per face, or 12 extra vertices.

3 Likes

Thanks for your question!
@Judgy_Oreo’s answer is correct (thanks @Judgy_Oreo :slight_smile: ) , the additional vertices are used for normals, colors, and textures.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.