Author Topic: Performance with many objects  (Read 4397 times)

Offline jpro

  • byte
  • *
  • Posts: 20
    • View Profile
Re: Performance with many objects
« Reply #15 on: November 09, 2010, 04:26:34 pm »
Given the results we've gotten so far I went ahead and came up with an algorithm that generates a "chunk" of 8x8x8 cubes with no inner faces. I say "cube" but each part of the overall chunk is no longer a cube persay, but an object that is capable of creating only the faces (which are planes) that it's instructed to. So an inner cube has no faces at all where an outside one has 1-3.

Previously I was creating (8^3)*6 faces = 3,072 faces for a chunk of this size. Now it's (8*2)*6 = 96. However, after plugging this back into my dynamic terrain generation and generating about 15 chunks I was disappointed to find the FPS dropping quickly. 15 chunks is about 1,440 planes, half of which are back culled, which I would assume can be rendered quite easily. My computer isn't too old.... Core 2 Duo @ 3.0 GHz, 4 GB RAM, modern graphics card, but I get about 30 FPS.

Are these results typical? I tried reusing the same plane and compiling it like we discussed above, but the results were similar.

Edit: I want to thank you again for looking into these issues. I'm a professional developer but don't have a lot of experience (yet) with graphics. It really is a whole new set of challenges.
« Last Edit: November 09, 2010, 04:33:16 pm by jpro »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11913
    • View Profile
    • http://www.jpct.net
Re: Performance with many objects
« Reply #16 on: November 09, 2010, 08:20:50 pm »
Sounds pretty low to me...then again, i'm not really sure if i understood correctly what you are doing there. A screen shot and the log output (as usual... ;)) might help. Also make sure that vsync is disabled or at least set to "application request" in your graphics card's settings.

This terrain demo renders at around 65 fps on a similar setup to yours. The terrain consists of 130.000 faces and is rendered four times for each frame (2 times for the texture blending and 2 times for the water reflection effect). In addition, up to 1500 trees are visible per frame.




Offline jpro

  • byte
  • *
  • Posts: 20
    • View Profile
Re: Performance with many objects
« Reply #17 on: November 09, 2010, 08:43:17 pm »
Yeah, that's pretty conclusive. There's something I could/should be doing to my plane creation to make it render faster... I assume the same compile, clone steps as above? I will do a thorough test of those techniques tonight.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11913
    • View Profile
    • http://www.jpct.net
Re: Performance with many objects
« Reply #18 on: November 09, 2010, 08:53:15 pm »
Yes, should be the same steps as above. You'll spot it in the logs, if it actually compiles something...

Offline jpro

  • byte
  • *
  • Posts: 20
    • View Profile
Re: Performance with many objects
« Reply #19 on: November 10, 2010, 12:16:34 am »
Screenshot of what I'm rendering:



Log output:

Code: [Select]
run:
Java version is: 1.6.0_20
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Software renderer disposed
Current mode:800 x 600 x 32 @75Hz
Driver is: atiu9p64 aticfx64 aticfx64 atiu9pag aticfx32 aticfx32 atiumd64 atidxx64 atidxx64 atiumdag atidxx32 atidxx32 atiumdva atiumd6a atitmm64/null on ATI Technologies Inc. / ATI Radeon HD 4800 Series
GL_ARB_texture_env_combine supported and used!
FBO supported and used!
OpenGL renderer initialized (using 4 texture stages)
Loading Texture...res/grid.jpg
created new chunk
created new chunk
created new chunk
created new chunk
created new chunk
created new chunk
created new chunk
created new chunk
created new chunk
Compiling source object...
Subobject of object 1/object3 compiled using 2 vertices in 0ms!
Object 1/object3 compiled to 1 subobjects in 4ms!
Object 3/object5 precompiled!
Object 5/object7 precompiled!
Object 7/object9 precompiled!
Object 9/object11 precompiled!
Object 11/object13 precompiled!
Object 13/object15 precompiled!
Object 15/object17 precompiled!
Object 17/object19 precompiled!
Object 19/object21 precompiled!
Object 21/object23 precompiled!
Object 23/object25 precompiled!
Object 25/object27 precompiled!
Object 27/object29 precompiled!
Object 29/object31 precompiled!
Object 31/object33 precompiled!
Object 33/object35 precompiled!
Object 35/object37 precompiled!
Object 37/object39 precompiled!
Object 39/object41 precompiled!
Object 41/object43 precompiled!
Object 43/object45 precompiled!
Object 45/object47 precompiled!
Object 47/object49 precompiled!
Object 49/object51 precompiled!
Object 51/object53 precompiled!
Object 53/object55 precompiled!
Object 55/object57 precompiled!
Object 57/object59 precompiled!
Object 59/object61 precompiled!
Object 61/object63 precompiled!
Object 63/object65 precompiled!
Object 65/object67 precompiled!
Object 67/object69 precompiled!
Object 69/object71 precompiled!
Object 71/object73 precompiled!
Object 73/object75 precompiled!
Object 75/object77 precompiled!
Object 77/object79 precompiled!
Object 79/object81 precompiled!
Object 81/object83 precompiled!
Object 83/object85 precompiled!
Object 85/object87 precompiled!
Object 87/object89 precompiled!
Object 89/object91 precompiled!
Object 91/object93 precompiled!
Object 93/object95 precompiled!
Object 95/object97 precompiled!
Object 97/object99 precompiled!
Object 99/object101 precompiled!
Object 101/object103 precompiled!
Object 103/object105 precompiled!
Object 105/object107 precompiled!
Object 107/object109 precompiled!
Object 109/object111 precompiled!
Object 111/object113 precompiled!
Object 113/object115 precompiled!
Object 115/object117 precompiled!
Object 117/object119 precompiled!
Object 119/object121 precompiled!
Object 121/object123 precompiled!
Object 123/object125 precompiled!
Object 125/object127 precompiled!
Object 127/object129 precompiled!
Object 129/object131 precompiled!
Object 131/object133 precompiled!
Object 133/object135 precompiled!
Object 135/object137 precompiled!
Object 137/object139 precompiled!
Object 139/object141 precompiled!
Object 141/object143 precompiled!
Object 143/object145 precompiled!
Object 145/object147 precompiled!
Object 147/object149 precompiled!
Object 149/object151 precompiled!
Object 151/object153 precompiled!
Object 153/object155 precompiled!
Object 155/object157 precompiled!
Object 157/object159 precompiled!
Object 159/object161 precompiled!
Object 161/object163 precompiled!
Object 163/object165 precompiled!
Object 165/object167 precompiled!
Object 167/object169 precompiled!
Object 169/object171 precompiled!
Object 171/object173 precompiled!
Object 173/object175 precompiled!
Object 175/object177 precompiled!
Object 177/object179 precompiled!
Object 179/object181 precompiled!
Object 181/object183 precompiled!
Object 183/object185 precompiled!
Object 185/object187 precompiled!
Object 187/object189 precompiled!
Object 189/object191 precompiled!
Object 191/object193 precompiled!
Object 193/object195 precompiled!
Object 195/object197 precompiled!
Object 197/object199 precompiled!
Object 199/object201 precompiled!
Object 201/object203 precompiled!
Object 203/object205 precompiled!
Object 205/object207 precompiled!
Object 207/object209 precompiled!
Object 209/object211 precompiled!
Object 211/object213 precompiled!
Object 213/object215 precompiled!
Object 215/object217 precompiled!
Object 217/object219 precompiled!
Object 219/object221 precompiled!
Object 221/object223 precompiled!
Object 223/object225 precompiled!
Object 225/object227 precompiled!
Object 227/object229 precompiled!
Object 229/object231 precompiled!
Object 231/object233 precompiled!
Object 233/object235 precompiled!
Object 235/object237 precompiled!
Object 237/object239 precompiled!
Object 239/object241 precompiled!
Object 241/object243 precompiled!
Object 243/object245 precompiled!
Object 245/object247 precompiled!
Object 247/object249 precompiled!
Object 249/object251 precompiled!
Object 251/object253 precompiled!
Object 253/object255 precompiled!
Object 255/object257 precompiled!
Object 257/object259 precompiled!
Object 259/object261 precompiled!
Object 261/object263 precompiled!
Object 263/object265 precompiled!
Object 265/object267 precompiled!
Object 267/object269 precompiled!
Object 269/object271 precompiled!
Object 271/object273 precompiled!
Object 273/object275 precompiled!
Object 275/object277 precompiled!
Object 277/object279 precompiled!
Object 279/object281 precompiled!
Object 281/object283 precompiled!
Object 283/object285 precompiled!
Object 285/object287 precompiled!
Object 287/object289 precompiled!
Object 289/object291 precompiled!
Object 291/object293 precompiled!
Object 293/object295 precompiled!
Object 295/object297 precompiled!
Object 297/object299 precompiled!
Object 299/object301 precompiled!
Object 301/object303 precompiled!
Object 303/object305 precompiled!
Object 305/object307 precompiled!
Object 307/object309 precompiled!
Object 309/object311 precompiled!
Object 311/object313 precompiled!
Object 313/object315 precompiled!
Object 315/object317 precompiled!
Object 317/object319 precompiled!
Object 319/object321 precompiled!
Object 321/object323 precompiled!
Object 323/object325 precompiled!
Object 325/object327 precompiled!
Object 327/object329 precompiled!
Object 329/object331 precompiled!
Object 331/object333 precompiled!
Object 333/object335 precompiled!
Object 335/object337 precompiled!
Object 337/object339 precompiled!
Object 339/object341 precompiled!
Object 341/object343 precompiled!
Object 343/object345 precompiled!
Object 345/object347 precompiled!
Object 347/object349 precompiled!
Object 349/object351 precompiled!
Object 351/object353 precompiled!
Object 353/object355 precompiled!
Object 355/object357 precompiled!
Object 357/object359 precompiled!
Object 359/object361 precompiled!
Object 361/object363 precompiled!
Object 363/object365 precompiled!
Object 365/object367 precompiled!
Object 367/object369 precompiled!
Object 369/object371 precompiled!
Object 371/object373 precompiled!
Object 373/object375 precompiled!
Object 375/object377 precompiled!
Object 377/object379 precompiled!
Object 379/object381 precompiled!
Object 381/object383 precompiled!
Object 383/object385 precompiled!
Object 385/object387 precompiled!
Object 387/object389 precompiled!
Object 389/object391 precompiled!
Object 391/object393 precompiled!
Object 393/object395 precompiled!
Object 395/object397 precompiled!
Object 397/object399 precompiled!
Object 399/object401 precompiled!
Object 401/object403 precompiled!
Object 403/object405 precompiled!
Object 405/object407 precompiled!
Object 407/object409 precompiled!
Object 409/object411 precompiled!
Object 411/object413 precompiled!
Object 413/object415 precompiled!
Object 415/object417 precompiled!
Object 417/object419 precompiled!
Object 419/object421 precompiled!
Object 421/object423 precompiled!
Object 423/object425 precompiled!
Object 425/object427 precompiled!
Object 427/object429 precompiled!
Object 429/object431 precompiled!
Object 431/object433 precompiled!
Object 433/object435 precompiled!
Object 435/object437 precompiled!
Object 437/object439 precompiled!
Object 439/object441 precompiled!
Object 441/object443 precompiled!
Object 443/object445 precompiled!
Object 445/object447 precompiled!
Object 447/object449 precompiled!
Object 449/object451 precompiled!
Object 451/object453 precompiled!
Object 453/object455 precompiled!
Object 455/object457 precompiled!
Object 457/object459 precompiled!
Object 459/object461 precompiled!
Object 461/object463 precompiled!
Object 463/object465 precompiled!
Object 465/object467 precompiled!
Object 467/object469 precompiled!
Object 469/object471 precompiled!
Object 471/object473 precompiled!
Object 473/object475 precompiled!
Object 475/object477 precompiled!
Object 477/object479 precompiled!
Object 479/object481 precompiled!
Object 481/object483 precompiled!
Object 483/object485 precompiled!
Object 485/object487 precompiled!
Object 487/object489 precompiled!
Object 489/object491 precompiled!
Object 491/object493 precompiled!
Object 493/object495 precompiled!
Object 495/object497 precompiled!
Object 497/object499 precompiled!
Object 499/object501 precompiled!
Object 501/object503 precompiled!
Object 503/object505 precompiled!
Object 505/object507 precompiled!
Object 507/object509 precompiled!
Object 509/object511 precompiled!
Object 511/object513 precompiled!
Object 513/object515 precompiled!
Object 515/object517 precompiled!
Object 517/object519 precompiled!
Object 519/object521 precompiled!
Object 521/object523 precompiled!
Object 523/object525 precompiled!
Object 525/object527 precompiled!
Object 527/object529 precompiled!
Object 529/object531 precompiled!
Object 531/object533 precompiled!
Object 533/object535 precompiled!
Object 535/object537 precompiled!
Object 537/object539 precompiled!
Object 539/object541 precompiled!
Object 541/object543 precompiled!
Object 543/object545 precompiled!
Object 545/object547 precompiled!
Object 547/object549 precompiled!
Object 549/object551 precompiled!
Object 551/object553 precompiled!
Object 553/object555 precompiled!
Object 555/object557 precompiled!
Object 557/object559 precompiled!
Object 559/object561 precompiled!
Object 561/object563 precompiled!
Object 563/object565 precompiled!
Object 565/object567 precompiled!
Object 567/object569 precompiled!
Object 569/object571 precompiled!
Object 571/object573 precompiled!
Object 573/object575 precompiled!
Object 575/object577 precompiled!
Object 577/object579 precompiled!
Object 579/object581 precompiled!
Object 581/object583 precompiled!
Object 583/object585 precompiled!
Object 585/object587 precompiled!
Object 587/object589 precompiled!
Object 589/object591 precompiled!
Object 591/object593 precompiled!
Object 593/object595 precompiled!
Object 595/object597 precompiled!
Object 597/object599 precompiled!
Object 599/object601 precompiled!
Object 601/object603 precompiled!
Object 603/object605 precompiled!
Object 605/object607 precompiled!
Object 607/object609 precompiled!
Object 609/object611 precompiled!
Object 611/object613 precompiled!
Object 613/object615 precompiled!
Object 615/object617 precompiled!
Object 617/object619 precompiled!
Object 619/object621 precompiled!
Object 621/object623 precompiled!
Object 623/object625 precompiled!
Object 625/object627 precompiled!
Object 627/object629 precompiled!
Object 629/object631 precompiled!
Object 631/object633 precompiled!
Object 633/object635 precompiled!
Object 635/object637 precompiled!
Object 637/object639 precompiled!
Object 639/object641 precompiled!
Object 641/object643 precompiled!
Object 643/object645 precompiled!
Object 645/object647 precompiled!
Object 647/object649 precompiled!
Object 649/object651 precompiled!
Object 651/object653 precompiled!
Object 653/object655 precompiled!
Object 655/object657 precompiled!
Object 657/object659 precompiled!
Object 659/object661 precompiled!
Object 661/object663 precompiled!
Object 663/object665 precompiled!
Object 665/object667 precompiled!
Object 667/object669 precompiled!
Object 669/object671 precompiled!
Object 671/object673 precompiled!
Object 673/object675 precompiled!
Object 675/object677 precompiled!
Object 677/object679 precompiled!
Object 679/object681 precompiled!
Object 681/object683 precompiled!
Object 683/object685 precompiled!
Object 685/object687 precompiled!
Object 687/object689 precompiled!
Object 689/object691 precompiled!
Object 691/object693 precompiled!
Object 693/object695 precompiled!
Object 695/object697 precompiled!
Object 697/object699 precompiled!
Object 699/object701 precompiled!
Object 701/object703 precompiled!
Object 703/object705 precompiled!
Object 705/object707 precompiled!

... this goes on for awhile! Had to truncate it because the forum software wouldn't let me put this many characters in one post.

The class which creates the planes does so with methods like this:

Code: [Select]
private static void initModel() {
        if(MODEL == null) {
            MODEL = Primitives.getPlane(1, 1);
            MODEL.build();
            MODEL.compile();
        }
    }

public void drawTop() {
        renderable = true;

        Object3D plane = new Object3D(MODEL, true);
        plane.rotateX((float)Math.toRadians(90));
        plane.translate(position.x, position.y-0.5f, position.z);
        //plane.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
        plane.setTexture("grid");
        plane.build();
        plane.shareCompiledData(MODEL);
        plane.compile();
        planes.add(plane);
    }
public Object3D[] getObjects() {
        return planes.toArray(new Object3D[0]);
    }

In that screenshot I made 38 chunks 4*4*4 which is ((4*4)*6 ) * 38 = 3648 planes/quads/faces. Within each chunk there are no inner faces being created. There's nothing else in the scene. You can see the FPS I'm achieving there (obviously FRAPS kills this a bit).

I'm not running any Config flags, just using default settings. Renderer is:

FrameBuffer buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL, IRenderer.MODE_OPENGL);
« Last Edit: November 10, 2010, 12:26:09 am by jpro »

Offline jpro

  • byte
  • *
  • Posts: 20
    • View Profile
Re: Performance with many objects
« Reply #20 on: November 10, 2010, 03:41:05 am »
An important thing I should note is that the planes *between* chunks, the ones on the chunk edge, are always rendered. This was a design decision to allow chunks to be wholly separate entities. Each chunk does not know the contents of its neighbors and thus assumes it must render its outside faces. After this latest test I don't know if that design decision is going to hold up.

Offline jpro

  • byte
  • *
  • Posts: 20
    • View Profile
Re: Performance with many objects
« Reply #21 on: November 10, 2010, 03:39:30 pm »
I solved this by eliminating all shared faces. I had assumed that overdrawing between the chunks wouldn't be a big deal but that proved false. Thanks for all your help.