Simple cube having 72 vertices ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GameVisitor

Hi all,

I created a simple scene with just a rigid body with the following children:

screenshot

  • mesh node (cube expected to be 8 vertex ?)
  • collision
  • other stuff (such as audio , non visible nodes…)

The debug monitor is showing 72 vertices drawn… is this expected or I am missing something trivial ?

Thx

I don’t know about 72 vertices, but a flat cube will have at least 4*6=24 vertices, since for every side of the cube the normals can’t be shared, since they need to point straight into the direction of the side. If you wanna know what I mean, create a cube in Blender and switch it to smooth shading. That cube will have 8 vertices but won’t look like the cube you see in Godot.

omggomb | 2019-02-17 15:31

Hi @omggomb,

Thx for your feedback but i didn’t full understand it.
Also i tried the shading → smooth / flat switch in blender, it only changed visually, but blender kept on saying it is 8 vertices…

Hope you can clarify / prove your answer better.

Thx again :slight_smile:

GameVisitor | 2019-02-17 17:01

I am so confused, I added a plane mesh and counts 12, while cube has 72, seems like every vertices has another vertices for normals. idk

I also try creating mesh from code, and if my guess is true then my mesh made from code did not divide as couple of triangles but a whole square, but if my guess is false, well I do not know anymore XO

here is my script:

extends Spatial

var tmpMesh = Mesh.new()
var vertices = PoolVector3Array()
var UVs = PoolVector2Array()
var mat = SpatialMaterial.new()
var color = Color(1, 1, 1)

func _ready():

vertices.append(Vector3(-0.5, 0, -0.5))
vertices.append(Vector3(-0.5, 0, 0.5))
vertices.append(Vector3(0.5, 0, 0.5))
vertices.append(Vector3(0.5, 0, -0.5))
vertices.invert()

UVs.push_back(Vector2(0, 0))
UVs.push_back(Vector2(0, 1))
UVs.push_back(Vector2(1, 1))
UVs.push_back(Vector2(1, 0))

mat.albedo_color = color

var st = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLE_FAN)
st.set_material(mat)

for v in vertices.size():
	st.add_color(color)
	st.add_uv(UVs[v])
	st.add_vertex(vertices[v])

st.commit(tmpMesh)

$MeshInstance2.mesh = tmpMesh
pass

func _process(_delta):
$MeshInstance2.rotate_z(0.01)
pass

Decemberfrost | 2021-02-23 11:44

:bust_in_silhouette: Reply From: Alex Pires

I’m not sure about this, but possibly some sort of triangulation of the faces would create the 72 vertices.

Hmm maybe like this:
1 face = 2 triangles = 6 Vertices. That makes 6 * 6 = 36 Vertices. Considering that I think that every vertex is need twice for the cube to appear sharp, that would make 72 vertices.

omggomb | 2019-02-22 15:13

Can you clarify more why

every vertex is need twice for the cube to appear sharp

Also, more importantly, is this expected ? I just wanna make sure that 1 simple cube in Godot is made of X Vertices before adding more cubes to my scene. (whether X is 8 or 72 or smthg else).

Thx

GameVisitor | 2019-02-22 19:40

I recorded a short video explaining why I think this is true. I admit I’m not sure but to me it sounds reasonable. I think the vertex count in Blender and Godot are counted at different stages. Blender counts only the vertices you created while Godot counts the vertices that are sent to the GPU for rendering

Here’s the video

Edit:
To further test this, I exported a cube using smooth shading without an edgesplit modifier, and as expected it looks different that the cube you can create in Godot, however there are still 72 vertices drawn, so I’m actually no longer sure if I’m correct :).

Smooth shaded cube in Godot

omggomb | 2019-02-23 18:11

Thx a lot @omggomb for taking the time to do the video !
It did clarify ur point better,
I think the vertex on top count as 3 since there is also the “normal” upward ?

Anw, hope the creators of Godot or someone from the top 3 users
@zylann @volzhs @Calinou @eons can confirm this count.

GameVisitor | 2019-02-23 19:24