Author Topic: Disable checking camera view for Object3D  (Read 4249 times)

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Disable checking camera view for Object3D
« on: February 06, 2012, 11:30:48 pm »
Please, could you add two methods for Object3D to enable and disable (default is enable) checking models when are in camera view? (so everytime Object3D will be send to GPU without checking) I think, that could be very helpful for very simple objects like particles or light halo.
And does jPCT-AE support multithreading for this? Galaxy S2 has almost same result as Galaxy S...

Sorry for my English, I do not how better explain it...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Disable checking camera view for Object3D
« Reply #1 on: February 07, 2012, 08:31:48 am »
That wouldn't make much sense...the visibility check for objects that are in view is very cheap. Both checks are just a simple if. About the multi-threading: No, it doesn't support this. The desktop version does but even there, it doesn't make much of a difference...if any. The additional overhead from maintaining multiple threads usually eats up the benefits in most cases (at least in this context).
On dual core phones, it might be feasible to do animations in different threads but not the geometry processing. At least not ATM.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Disable checking camera view for Object3D
« Reply #2 on: February 07, 2012, 09:35:18 am »
So, what is it so expensive? render scene takes 2.7ms and draw scene 7.8ms, when I disable particle system, render 2.1ms and draw 3.8ms. And it is just about 50 particles, so 50 triangles...
edit: in both cases particles are not in camera view
« Last Edit: February 07, 2012, 09:47:09 am by Thomas. »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Disable checking camera view for Object3D
« Reply #3 on: February 07, 2012, 10:28:54 am »
Visibility detection already happens in renderScene(), not in draw(). No idea what causes the draw()-call to take twice the time without any visible particle. How much "not in camera view" is "not in camera view"? Because the visibility detection can be coarse at times. You might want to add an IRenderHook to your particles to check out when they are actually processed by the gpu and when they don't.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Disable checking camera view for Object3D
« Reply #4 on: February 07, 2012, 11:45:30 am »
Particles are on the opposite side of the camera direction... If I understood correctly, when particles are not in camera view, methods beforeRendering and afterRendering are not called? Both are called and does not matter on camera direction and position. Position of particles seem be OK.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Disable checking camera view for Object3D
« Reply #5 on: February 07, 2012, 12:18:17 pm »
Yes, they shouldn't be called in that case. I'll check it out...which version of jPCT-AE are you using? If it's an older one, have you tried updating?

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Disable checking camera view for Object3D
« Reply #6 on: February 07, 2012, 01:16:43 pm »
Probably the newest version of beta (file size is 303 087B)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Disable checking camera view for Object3D
« Reply #7 on: February 07, 2012, 01:27:34 pm »
Ok, i'll have a look at the object gross culling to see if i can reproduce this behaviour.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Disable checking camera view for Object3D
« Reply #8 on: February 07, 2012, 01:41:00 pm »
Just to be sure: How are you creating the objects for the particles?

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Disable checking camera view for Object3D
« Reply #9 on: February 07, 2012, 01:43:47 pm »
by this:
Code: [Select]
public Particle() {
super(1);
addTriangle(new SimpleVector(-1, -1, 0), 0, 0, new SimpleVector(1, 1, 0), 1, 1, new SimpleVector(1, -1, 0), 1, 0);
getMesh().compress();
setBillboarding(Object3D.BILLBOARDING_ENABLED);
setAdditionalColor(RGBColor.WHITE);
setLighting(Object3D.LIGHTING_NO_LIGHTS);
enableLazyTransformations();
setVisibility(Object3D.OBJ_INVISIBLE);
//setRenderHook(rh);
build();
}

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Disable checking camera view for Object3D
« Reply #10 on: February 07, 2012, 09:06:32 pm »
You are right. While it works fine for "normal" objects, something is fishy when flat objects like planes or single polygons are displayed (or better: not displayed...). I'll look at it...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Disable checking camera view for Object3D
« Reply #11 on: February 07, 2012, 09:40:49 pm »
Ahem...it was an optimization that i had added for particle effects that broke the whole thing for...particles... ;) It's fixed now: http://jpct.de/download/beta/jpct_ae.jar

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Disable checking camera view for Object3D
« Reply #12 on: February 07, 2012, 09:53:28 pm »
YES alright now :) ... so, why is so expensive rendering 100 simple objects with one triangle?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Disable checking camera view for Object3D
« Reply #13 on: February 07, 2012, 09:56:06 pm »
Because it requires 100 render calls including enabling/disabling of some states...render calls are pretty expensive.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Disable checking camera view for Object3D
« Reply #14 on: February 07, 2012, 09:58:17 pm »
ok, thanks