Author Topic: Faster Render by using the same object?  (Read 1844 times)

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Faster Render by using the same object?
« on: May 31, 2012, 03:57:43 am »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Faster Render by using the same object?
« Reply #1 on: May 31, 2012, 08:55:26 am »
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.

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Faster Render by using the same object?
« Reply #2 on: May 31, 2012, 09:20:51 am »
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.
« Last Edit: May 31, 2012, 09:30:15 am by Zyphuris55 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Faster Render by using the same object?
« Reply #3 on: May 31, 2012, 04:32:12 pm »
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.

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Faster Render by using the same object?
« Reply #4 on: May 31, 2012, 07:47:19 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Faster Render by using the same object?
« Reply #5 on: May 31, 2012, 08:15:46 pm »
Which Android version are you using btw?

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Faster Render by using the same object?
« Reply #6 on: May 31, 2012, 08:21:47 pm »
2.3.6, kernel 2.6.36.3.

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

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Faster Render by using the same object?
« Reply #7 on: June 01, 2012, 07:21:24 am »
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).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Faster Render by using the same object?
« Reply #8 on: June 01, 2012, 01:40:21 pm »
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...