Drawing models twice?

Hey all,



I just want to make sure about something.



Say you start a new project and create a basic cube and draw the scene.

Just an empty scene according the the stats takes:

14 objects

456 triangles

912 vertices



Drawing just the box goes to:

16 objects

480 triangles

960 vertices



So the box is taking 24 triangles and 48 vertices? Is it being drawn twice?



I’m starting to work on an android app and trying to get the fewest number of things drawn

seems to be one of the more important tasks so just wanted to make sure this is working as intended.



Or if there’s some setting I’m not aware of to turn off and get fewer things being sent to draw

on the screen.



Thanks,

William

yeah strange looks like it’s drawn twice could you post the code?

a JME cube has 24 vertices and 12 triangles.

Can we see the code for your test? It sounds like you are somehow adding the box twice.



For example, I just ran the TestAppStateLifeCycle and see only 15 objects when I look at the cube and 14 when I look away.



Source code is here if you want to compare: http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/app/TestAppStateLifeCycle.java

The model has to be redrawn for each non-ambient light

2 Likes
@Momoko_Fan said:
The model has to be redrawn for each non-ambient light


Ah, good point. Another good reason to see the code. :)

will deffered shading solve this issue with redrawing?

@mifth said:
will deffered shading solve this issue with redrawing?

You like to troll right?

no, really… if i set 5 light sources with deffered shading… will it render it only one time or 5 times?

I know there is no deffered shading in JME yet. But it will soon :slight_smile: .

@mifth said:
will deffered shading solve this issue with redrawing?

Your scene needs to have a substantial geometric complexity before deferred shading will payoff..

Yup it was the light. Was adding a point light every time to my tests.



If any are still curious the code was:



[java]

Mesh shapeBox = new Box(Vector3f.ZERO, 1.0f, 1.0f, 1.0f);

TangentBinormalGenerator.generate(shapeBox);

Geometry cube = new Geometry("Test",shapeBox);

cube.setMaterial((Material)assetManager.loadMaterial("Models/box/box-submesh0.j3m"));

rootNode.attachChild(cube);



PointLight pl = new PointLight();

pl.setColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));

rootNode.addLight(pl);[/java]



So guess stick to an ambient light for my android tests.



Thanks so much,

William

wait…if you have one point light and one ambient light this should not happen.

Ambient pass is computed during the first non ambient light pass, so in your case there should be one pass really.

Could you post the complete code please?

Okay I think what happened was I added a light to the imported model with the SDK so I could see it with the SceneComposer. But I think I also had a light in the code. So the final output was with two lights. Sorry about that.



But learning that the scene is drawn for every different light was valuable. So thanks guys.



William