Author Topic: can the engine disable frustum cull ?  (Read 2474 times)

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
can the engine disable frustum cull ?
« on: September 11, 2016, 07:34:45 am »
for some special case , an app may do frustum cull by itself, if the engine does frustum cull also, then the work is done twice. so i wish the engine can disable frustum cull.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: can the engine disable frustum cull ?
« Reply #1 on: September 11, 2016, 02:34:45 pm »
It shouldn't really matter if you call it twice. Or did I get the question wrong?

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
Re: can the engine disable frustum cull ?
« Reply #2 on: September 11, 2016, 03:03:50 pm »
there is an API for frustum cull? i didn't find it.
i think in world.renderScene or world.draw , each Object3d is tested of frustum cull. if it's not in view , it's not sent to GPU.
in app, sometimes i need to test it too. for example if animation update of a group of Object3d is complex, i prefer to test frustum cull before updating animation.
if not in view, i just hide the objects.
for the non-hidden objects,
the test result is not communicated to the engine, so engine will test again.
if the world is rendered multiple times, frustum cull is tested multiple times. but in fact, it only need to be done once for a frame.
so it's better to turn of frustum cull in engine, in my case.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: can the engine disable frustum cull ?
« Reply #3 on: September 11, 2016, 09:36:50 pm »
Ok, that was a misunderstanding then. I thought that you were talking about setting the frustum via GL commands. Well...desktop jPCT has an option to disable the frustum culling, but I've removed it for jPCT-AE, because there's actually no point in disabling it. I've never experienced a single situation where it helped to disable it and I really tried. So I removed it. The check itself is really cheap and it's even cheaper if the object is visible anyway. I really don't think it will hurt in any way to do it twice. My RPG basically does the same thing. I once tried to skip the engine's own culling, but it didn't chance anything.
For animations and such, I'm using a different approach: Object3D has a method wasVisible() and I only update the animation if the object was visible in the last frame. Depending on how you manage object states, this might not work in your case though, because it might create goofy looking animations.

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
Re: can the engine disable frustum cull ?
« Reply #4 on: September 12, 2016, 06:25:55 am »
i thought of another case where doing culling in app is more efficient than in engine. a group(say 20 or more) of Object3D are always stuck together, but they can rotate seperately, such as a vehicle. if i do culling on a bounding box/sphere of the group, the culling is done once instead of 20 times in engine. this advantage is multiplied by the quantity of object groups. i guess this can make a difference when quantity becomes large.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: can the engine disable frustum cull ?
« Reply #5 on: September 12, 2016, 08:21:18 am »
Maybe, but in that case, you would set the whole group to invisible anyway, so that the engine's internal culling won't be triggered.