I was toying around with some lights, and created a Box. Then, I noticed something ‘strange’ in the stats.

The vertex count increased by 24. Now, if I understand correctly, this is how the vertex count is done:

3 X the number of triangles in a model X the number of lights in the scene.

Now, a box has 12 triangles, so shouldn’t the count have been increased by 36?

I am no expert in JME, but - depending on your code - the other 12 vertices are probably being culled (since there are 12 vertices hidden behind the box) and therefore not drawn, therefore being excluded from the vertex count. If you move the camera around the box, you may see a small variation in the vertex count.

But if I import my own model, the ‘correct’ vertex count is shown. For example, I imported a model with 414 triangles, and the resulting increase was of 1242. Thanks anyway

PS I also tried setting the CullMode to Never, although I’m not sure that’s the same thing, however the increase stayed at 24.

There are 4 vertices per face, 6 faces, 6 x 4 = 24

Remember that each side of the box is made from 2 triangles but those triangles share 2 vertexes each.

If the box was smooth-shaded you would only have 8 vertexes total.

Thanks wezrule. But why isn’t a box made of triangles? Whenever I import a model, all quads change into triangles. Also, when I set it to Wireframe, it was made up of triangles, which gives it 15 faces, no? Or is the box ‘special’ in any way?

@zarch, same thing with models though. They share a lot of vertices, but in the end, the calculation I use (and has been correct for all models except boxes) is 3 X number of triangles.

It is made up of triangles. But there are still 4 vertices per face.

Your calculation is only correct if you have a flat shaded model with no contiguous coplanar surfaces.

I imported some models, and you’re right zarch. However, the variation is very small. From three models, one respected the ‘equation’, another had +2 and the other had +4. So it doesn’t really matter.

Take a look at the index buffer and how it works, then you understand how the box works.

@memonick said:

I imported some models, and you're right zarch. However, the variation is very small. From three models, one respected the 'equation', another had +2 and the other had +4. So it doesn't really matter.

Well I have a model that goes from 1000 vertices to around 2500 if you switch it from smooth to flat shading so you can't count on that. Your formula will give you the maximum number of vertices. It will always be less than or equal to that. It's unlikely to be less than 1/3rd of that...but anything in between is entirely possible.

No, I think it gives the minimum. As I wrote, one increased by 2, and the other increased by 4. Also, how do I switch to smooth shading?

The absolute maximum number of vertices a valid model can have is 3 per triangle.

If it has more than that then your model has extra unused vertices wasting resources.

Flat/Smooth shading is an option in blender. Change it there before doing the export.

@memonick said:

No, I think it gives the minimum. As I wrote, one increased by 2, and the other increased by 4. Also, how do I switch to smooth shading?

You can think what you want but the fact is that if a vertex shares all of the same attributes with another vertex then it can be shared. If it doesn't then it can't.

Boxes have 24 vertexes because each side shares two vertexes across 2 triangles per face.

If you multiply the number of triangles * 3 that will give you the _maximum_ number of vertexes possible. Which may be a lot more than the actual number depending on whether normals, texture coordinates, etc. can be shared across vertexes.

@zarch, thanks. You were right - I had some polygons which weren’t quads. I don’t know how to switch from Smooth to Flat since I use 3DS Max. If anyone can help, I’d appreciate. Although I think I use Smooth.

@pspeed, thanks for the explanation. I’ll look into the reason why all of my models have 3X the number of triangles then. I didn’t realize vertices could be shared.

This is a (very old) blender page but it explains the difference, look for something similar:

http://download.blender.org/documentation/html/x2089.html

(For flat shading the vertexes have different normals for each face so you need two (or more) vertices - one for each face. For smooth shading they all have the same normal so the vertex is shared).

I found a place from where I auto-smoothed them, and the effect is exactly the same as the one you posted, zarch. However, the vertex count is exactly the same as before. Any ideas as to why?

@zarch said:

For smooth shading they all have the same normalso the vertex is shared

Just because the vertexes have the same normal does not mean they must be shared... they can be combined and shared as an optimisation which will reduce the vertex count, however this can result in other complications with the likes of texture coords later down the track (with custom mesh work anyway). It's far easier and simpler which switching between flat and smooth shading to simply change the vertex normals, rather than to reconstruct the entire model with a different set of shared verts.

@thetoucher, I didn’t say that. What I can’t understand is how vertices are shared. I did what seemed obvious from what I could understand - smoothed out the model instead of having it flat, but that changed nothing.

Thanks for your efforts guys.

The blender importer seems to automatically merge identical vertices. I think it has the intelligence to know about different texture co-ordinates too. I can’t comment on what the asset pipeline you are using is doing as I’ve never tried it