- Home /
Why does one primitive Cube have 100 vertices??
I am having some performance issues with my Game. I have over 8 Mio vertices. So i tried to reduce the number. But what surprised me is that even when i start a new project and only add one primitive cube. My Vertex count is at 104. It is at 4 without the cube. The Skybox is arroud 4k vertices so i have turned it off. But why does one primitive cube add 100 vertices to the scene. Vertices are the corners of the Triangles that make up the mesh if I understand correctly. Each side of of Cube is devided into 2 Triangles so even if some of the corners are used multiple times it is never 100 vertices. I dont get it help pls
Answer by Bunny83 · Sep 07, 2020 at 09:43 PM
You probably talk about Unity's rendering statistics window? The vertex count does not necessarily correspond to the physically present vertices but how many times they are processed during rendering. This includes each pass your material uses as well as any auxiliary passes like shadow or light passes.
A primitive cube has exactly 24 physical vertices, 4 per face. So it might be rendered 4 times which would add up to 96 and maybe an additional full screen rect for post processing (or something like that). The number of vertices is pretty irrelevant for most hardware. The SetPass / draw call count is way more important.
Answer by iTzsKiLLeR · Sep 07, 2020 at 09:52 PM
Are you sure it says that for Mobile you should not be over 200.000 vertices i have read here: https://docs.unity3d.com/Manual/OptimizingGraphicsPerformance.html. Also i dont get how it has 24 vertices? A Cube has 8 corners. So the corners are counted multiple times? Sry I am very new to performance optimazation textures and meshes. Thx for the quick reply
I mean one vertex is being used by 6 Triangles if I am not mistaken. But it is couted multiple times?
A vertex is made up of several vertex attributes. The position is just one of those attributes. The others are the vertex normal as well as UV coordinates. Whenever any of those attributes is different, you have to split the vertex. A cube is made of 6 faces. Each face requires a unique normal vector in order to render the face properly. So you can not share the vertices at the corners since 3 faces will meet at each corner. That's why you need 3 times 8 vertices. Or to state it in a way that makes more sense: 6 times 4 vertices. Since each face is made up be two triangles that form a quad, each face requires 4 distinct vertices. I've explained that countless of times already. For example over here.
About performance optimisations: $$anonymous$$obile is a topic on its own. A huge issue with older mobile devices is that you generally have a very limited platform. So you're usually low on pretty much everything. You usually don't want to use Unity's Standard shader for mobile unless really necessary. The Standard shader is a monster. Have a look at this page.
Actually this is caused by realtime shadow pass. Depth pass to set depth map before rendering shadows, 2 extra draw calls for the shadows itself, final extra to render the mesh itself. 24 * 4 + 2 full screen blit ( a quad ) to be exact. Remove light or shadows, and you will get 28.