High vertex count and clarifications

Hey,

So my model overall although a high vertex count atm (2 models i’m aware are 20k each so I just need to find replacements) i’m a bit unsure as to why it’s SO high in the stats window when playing. So overall the scene is 120k vertices according to the SDK.

However, when playing it shows vertices of over 1mill! Is that meant to happen? The model of a building is 110k vetices since you can go inside and outside of it. But when I go outside and look at it, it’s showing 900k vertices - would this suggest that culling isn’t working? Triangles are also high, pretty much a 1:1 ratio of triangles to vertices and I assume this shouldn’t happen? However, how is 1mill vertices generated from 100k?

Thanks =)

Where are you getting the 110k vertex stat? From blender?

Blender probably considers each unique location to be a vertex. But when rendered, a unique vertex includes normal, texture coordinate, tangent, etc… ie: more than just location. Also, some versions of the .blend loader didn’t optimize this at all and would just let each triangle have its own three vertexes. I don’t know what the current state of this is but a 1:1 suggests that some optimization is being done.

@pspeed said: Where are you getting the 110k vertex stat? From blender?

Blender probably considers each unique location to be a vertex. But when rendered, a unique vertex includes normal, texture coordinate, tangent, etc… ie: more than just location. Also, some versions of the .blend loader didn’t optimize this at all and would just let each triangle have its own three vertexes. I don’t know what the current state of this is but a 1:1 suggests that some optimization is being done.

Hey, thanks for the reply
Sorry no, not in blender, in the JMonkey SDK when I click a model and it’s root node.

Do you have shadows or multiple lights, or both?
Shadow will dramatically increase your object count, and of course your vertex count. Then if you have multiple lights, note that the scene is rendered once per light. So 2 lights will double your object/vertex count (except for ambient light).

To optimize shadows, you can try to use the DirectionalLightShadowFilter instead of a DirectionalLightShadowRenderer. The usage is a bit different, but all is detailed in the javadoc.
Then reducing the number of splits for directional shadows (3 is usually enough).

That’s all I can guess from your post, maybe you should be more specific on your scene so we can help you.

@nehon said: Do you have shadows or multiple lights, or both? Shadow will dramatically increase your object count, and of course your vertex count. Then if you have multiple lights, note that the scene is rendered once per light. So 2 lights will double your object/vertex count (except for ambient light).

To optimize shadows, you can try to use the DirectionalLightShadowFilter instead of a DirectionalLightShadowRenderer. The usage is a bit different, but all is detailed in the javadoc.
Then reducing the number of splits for directional shadows (3 is usually enough).

That’s all I can guess from your post, maybe you should be more specific on your scene so we can help you.

Sorry, i’ll post some pictures if that would help.

There are 4 point lights which represent lamps in ‘rooms’ of the house but no shadows at all. Would the pointlights still cause problems if not in view? I.e would it be useful to remove them if the user is not nearby? Lighting may actually be the problem, i’ll do a test and find out =). Thanks Neon.

EDIT: There’s 5 pointlights in total and 1 directional light - removing 3 of them definitely helped. Is there an obvious way apart from that which I described to optimise lighting? I’ll have a look anyway, I didn’t realise pointlights did that =).

Lighting = one render per light when the light touches the object. So if you have directional light and 5 points lights that all light your object then it is rendered 6 times.

Optimization: don’t use GL lights for everything and bake some lighting in instead. But that’s a modeling problem.

If you use a lot of lights you need something called Deferred Rendering. There are a few deferred rendering implementations for JME3 floating around but I don’t think any of them are complete yet…

@zarch said: If you use a lot of lights you need something called Deferred Rendering. There are a few deferred rendering implementations for JME3 floating around but I don't think any of them are complete yet...

I guess I didn’t think 5 lights were a lot - although I didn’t realise it could double the vertex count. Does it double the vertex count of the entire scene or simply the object that it touches? If I reduced the radius could that help reduce the vertex count?

The lights are in individual ‘rooms’ of the house as they represent lights in the room you can turn on and off. The only easy thing I can think of is adding doors in between rooms and changing the lights when the user enters. I’ll post some pictures after i’ve slept since I guess it’d be more useful =).

@avpeacock said: I guess I didn't think 5 lights were a lot - although I didn't realise it could double the vertex count. Does it double the vertex count of the entire scene or simply the object that it touches? If I reduced the radius could that help reduce the vertex count?

The lights are in individual ‘rooms’ of the house as they represent lights in the room you can turn on and off. The only easy thing I can think of is adding doors in between rooms and changing the lights when the user enters. I’ll post some pictures after i’ve slept since I guess it’d be more useful =).

@pspeed said: Lighting = one render per light when the light touches the object. So if you have directional light and 5 points lights that all light your object then it is rendered 6 times.

It could be that it’s not even that smart but you could divide your scene into zones each with their own parent node and add the lights to those parents.

…or back the lighting into the geometry.

Forward rendering renders the scene once for every light in it (ambient gets included with the first other light).

So 1 directional + ambient = 1 pass.

Every single light added after that adds another full rendering pass with the new light though!

@zarch said: Forward rendering renders the scene once for every light in it (ambient gets included with the first other light).

So 1 directional + ambient = 1 pass.

Every single light added after that adds another full rendering pass with the new light though!

But a pass may only render a subset of the scene depending on how the light was setup.

True. As far as I know it renders everything in the node its attached to and all children of that node?

Is there any distance based intelligence as well for example in point lights?

@zarch said: True. As far as I know it renders everything in the node its attached to and all children of that node?

Is there any distance based intelligence as well for example in point lights?

That’s the part I don’t know.

@zarch said: True. As far as I know it renders everything in the node its attached to and all children of that node?
yes
@zarch said: Is there any distance based intelligence as well for example in point lights?
no. That's what issue 510 is supposed to resolve.

I think @Pspeed is right. If you need thoses lights, you may add them only to the sub-tree it should light, and not in the main rootNode. This way, only the sub-tree will be rendered twice.

But that also means that you cannot light objects outside of your rooms (the sub-trees). Therefore, no window casting light outside (except if baked), and more annoying no lighting through doors since any object can only belong to one single sub-tree.

For the engine gurus: Do you think it would be possible to bake some “illumination tree” from the sdk? Then lights would render only from this instead of using the scene graph. This would solve that issue… It would remain mobile objects of course, but that’s not such a big issue…

Edit : @Nehon, where can this issue (and the others) could be found? I’ve not seen them yet.

Issue can be found here:
http://code.google.com/p/jmonkeyengine/issues/list?can=2&q=label:Product-jME3&sort=-id&colspec=ID%20Type%20Status%20Component%20Priority%20Difficulty%20Product%20Milestone%20Owner%20Summary

i guess;)

and this particular one
https://code.google.com/p/jmonkeyengine/issues/detail?id=510&q=label%3AProduct-jME3&sort=-id&colspec=ID%20Type%20Status%20Component%20Priority%20Difficulty%20Product%20Milestone%20Owner%20Summary