Faster Render by using the same object?

Started by Zyphuris55, May 31, 2012, 03:57:43 AM

Previous topic - Next topic

Zyphuris55

Currently my scene has 222 visible objects (1,296 faces). 37 of the objects (216 faces out of the 1,296) are unique, the rest are copies from the original, but translated 10 points to the left. In each group of 37 objects, 24 of the faces are using transparent textures.

The world has 2 lights (ambient + 1 light with low intensity) right now, and I don't yet see a need to add any more lights

= Object breakdown
- 12 objects (2 faces each), transparency enabled
- 12 objects (12 faces each), no transparency
- 12 objects (2 faces each), no transparency
- 1 object (24 faces), no transparency


When running the game, I get an average of 10 fps. The sections of the program which use the most cpu are:
World.renderScene (@ 57.1%)
- Object3D.transformVerticies (@ 46.8%)
- Object3D.render (@ 41.3%)
- VisList.sort (@ 10.1%)

World.draw (@40.5%)
- GLRender.drawVertexArray (@ 100%)

note: All of those classes are from the engine


My question is, instead of creating all 222 objects, I just create the 37 objects. Then each time the scene needs to be rendered, it's moved to the leftmost visible object spot, textures are applied, render to framebuffer, move 10 to the right, re-texture, render again, and repeat till the object is out of the camera view. Or would this just lower the memory requirement and keep the cpu still at a high (or higher) amount?

I can not merge the objects into 1 whole object, because I would lose the object names (assumed). The names are needed so the 3 groups of 12 objects can have their textures changed dynamically during game play.


Attached is an image of what the objects look like. All of the per-object details have been stripped for the example image, the framerate is still the same though.

EgonOlsen

No, that would make things worse. 10fps doesn't mean anything as long as you don't tell, which device you are getting this performance on...
You can try (in case you haven't already) to use http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#shareCompiledData(com.threed.jpct.Object3D). That might help a little, because it's nicer to the GPU caches.

Zyphuris55

#2
I'm running the game on the Samsung Captivate Glide, which has a "1Ghz Dual-core Nvidia Tegra 2 AP20H Processor". It's a non-rooted phone (in case that matters).

I'll try the suggestion now and see what happens.


Edit:
I have no clue how/ why this happened, but after I added in some code to test how long it would take for the first frame to be rendered...my fps dropped to 7.3 fps.
As for the advice you gave, it dropped the time needed to render the first frame from 5.3026 seconds to 3.5209 seconds. The fps was unaffected.

EgonOlsen

222 visible object doesn't sound that much...but maybe it's a little too much in this case especially with transparency enabled. Can't you merge multiple objects into one? So that one of these "wheels" is one object? Is there any reason why this can't work in your game?

BTW: Which version of jPCT-AE are you using? If it's the official release, try the latest beta (http://jpct.de/download/beta/jpct_ae.jar) to see if that can improve things.

Zyphuris55

I'm using the 1.24 version, but I'll try the beta after this reply.

The reason I can't merge the objects is because the blocks which are on the wheels change during game play. The most I could merge the objects is by attaching the block bottoms to the side of the blocks. But the transparency parts of the blocks must stay as their own objects because of how often it'll be changed and how many different ways it can be changed.

I'll also try merging the bottoms to the sides and see if that fixes anything.

EgonOlsen

Which Android version are you using btw?

Zyphuris55

2.3.6, kernel 2.6.36.3.

I haven't done anything with it (modding wise) yet, been too busy programming, lol.

Zyphuris55

Sorry about the delay, I had class today and other things on the todo list. I just tried the beta version you recommended and it made a dramatic improvement. The game is now running at 16 fps :-D.

Btw, why is that version still in beta if it's running so smoothly? And would it be stable enough for me to release the game with it? (It's still in the alpha phase right now).

EgonOlsen

The beta is actually a release candidate. I'll try to make it an official release within the week.

I'm a bit confused about why it's so much faster. I did some optimizations for higher objects counts, but i wasn't expecting nor have i ever experienced a 60% gain from that...