[Explained] How many verices cube needs? 8?, 16? Nah ... 24!? What?

So what the heck story is about Unity Cube, with 24 vertices?
Is seriously 8 not enough? I think Unity in past used double of that, which was 16, if I am correct?

6 planes with 4 verts each = 24.

Of course the vertices can be shared, but if they’re shared then they’d also share normals and if they share normals it won’t really look like a cube anymore.

4 Likes

Oh ok, And I think this applies similar, to vertices color, per side?

you can have 8, but you would need a shader specifically for hard edges and I’ve no idea what kind of mess the uvs would be in. When using modelling packages, they typically disguise that they do the same thing.

How big/small impact of tripling number of vertices is, on ECS performance, with many thousands of cubes?
Would it be worth use imported Cube mesh and UV, from external 3D software? i.e. blender?

From 2011, Why does a primitive cube contain 24 verts?? - Questions & Answers - Unity Discussions

This is the wrong forum though. This has nothing to do with ECS/Jobs.

Thx. I do wonder however, how 3D software manage (3DS Max, Blender), to keep 8 vertices only per cube. Unless trick is that other 16 vertices are hidden normally behind the scene, while exposing only 8 for manipulation.

1 Like

DirectX and OpenGL both require 24 verts per cube if you need to provide colors or textures.

-edit-

I should add, as far as I’m ware there’s no real performance advantage of having less verts [if your triangle count doesn’t change] except for less memory being utilized.

The shader still needs to render every triangle. If you weld/reuse verts the number of triangles rendered doesn’t change, just the number of verts stored in memory.

Well, does makes sense. Which means vertices “trickery” (by pairing groups of 3) is used in the 3D software mesh rendering. Learning every day :wink:

They don’t, they lie.

2 Likes

Exactly, what I wanted to say. I had to explain this to the 3d artists in my team because they were saying that their models have fewer vertices.

The 3D software is independent of how the model is rendered. It normally uses per surface normals. Only for realtime rendering the vertices need to be split up and eg quads and higher order polygons have to be triangulated. So they don’t exactly lie. Eg for raytracing the per surface might be used instead.

1 Like

This is a bit of an aside: I’m don’t know about other software but 3DSMax doesn’t technically lie, it just has a far more complex data structure for meshes than games and real-time rendering do.

A cube will have 8 vertices but those vertices are just positional data. It has an entirely separate set of definitions for texture vertices and another for colours, etc. The way it stores normals are even more complex with vertex normals, face normals, smoothing groups, etc. Internally it associates the parametric vertices with the “actual” vertices. When it comes to rendering it translates all that data into the appropriate structure for the rendering method, after all it’s not just for rendering in realtime via DirectX or OpenGL in the viewport. Different exported file formats also handle the data in different ways which can be incompatible with what we as game developers know to be “correct”.

So when you select and move a vertex on a cube you are selecting and moving just one actual vertex in terms of the data, even though what’s being rendered in the viewport ends up as 3 vertices pushed through the graphics API. The graphics API’s representation of the mesh is entirely separate to the DCC’s representation of the mesh which you’re actually manipulating. I guess it’s all technicalities but saying the software lies isn’t a good representation of what the software is actually doing, especially when the software was designed before said graphics APIs actually existed on the platforms it was originally released on.

3 Likes

Agreed, I was exaggerating.

In the software’s context they show the correct number of vertices. (and some do tell you the OpenGL viewport numbers as well. Modo does, but only for tris)

It’s just computer graphic topic.
One vertex consists of information about:

  1. Position
  2. Normal
  3. UV Coordinates
  4. Other Stuff (color, tangent, binormal, etc)

If two vertices have the same position, normal, uv coordinates, other stuff, you can weld them together, so you get 8-vertices cube. Try create in blender for example cube with smooth shading, without uv coords (this means that all three vertices in one corner have same position, same normal, and same uv coords), and you will get 8-vertices cube after exporting obj file to unity.
P.S. Interesting thing that unity’s obj exporter-parser welds vertices manually, even if obj file describes all 24 vertices.

1 Like

…It will look like low-poly sphere.