Author Topic: frustum culling  (Read 12953 times)

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
frustum culling
« on: January 12, 2011, 01:32:02 am »
have a look at the image below. in the upper part, half of tile is invisible. it's cut. is there anything to prevent this? it also happens in desktop JPCT.


Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: frustum culling
« Reply #1 on: January 12, 2011, 09:08:06 am »
try to set higher value in nearPlane...
Code: [Select]
Config.nearPlane = 2; // default = 1

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: frustum culling
« Reply #2 on: January 12, 2011, 09:31:09 am »
But remember to adjust Config.glIgnoreNearPlane too. Otherwise, setting the near plane will show no effect.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: frustum culling
« Reply #3 on: January 12, 2011, 09:34:01 am »
but by default is true, is not it?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: frustum culling
« Reply #4 on: January 12, 2011, 09:49:13 am »
Yes...which means that the setting for the near plane will be ignored.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: frustum culling
« Reply #5 on: January 12, 2011, 10:02:16 am »
I see  :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: frustum culling
« Reply #6 on: January 12, 2011, 10:11:05 am »
Just in case that somebody wonders why it is the way it is: It's a relic from desktop jPCT, where the near plane for software and hardware renderer works differently.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: frustum culling
« Reply #7 on: January 12, 2011, 07:24:30 pm »
thank you :D increasing near plane solves this issue but creates another. it behaves like fov is increased (zoom in). same applies to sky box too. i dont want this behaviour should i play with fov to compensate this or what ?

i also wonder why increasing near plane solves this rendering artifact?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: frustum culling
« Reply #8 on: January 12, 2011, 08:23:18 pm »
Increasing? Maybe it cuts it earlier, so that it isn't noticable any more? I would have expected a decrease to help. The change in fov (it isn't exactly that, but it looks like it...) is normal behaviour when adjusting the near plane. I would try to compensate with real fov.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: frustum culling
« Reply #9 on: January 12, 2011, 09:22:10 pm »
i hadn't tried decreasing. now i tried it. it didnt help on AE and has some very weird artifacts on desktop. have a look at below images. it's more noticable in action.
 




i've also noticed that, when nearplane is modified, blitting location goes wrong on both AE and desktop. if near plane is decreased, blitted images move to center and vice versa. the blitted text in above images are normally 5px close to edges when near plane is default.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: frustum culling
« Reply #10 on: January 12, 2011, 11:02:31 pm »
Try these: http://jpct.de/download/tmp/jpct_jars.zip

They should fix both issues. Adjusting the near plane is a bit of a hassle, because software and hardware renderer are behaving totally different...

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: frustum culling
« Reply #11 on: January 12, 2011, 11:29:08 pm »
thanks, in desktop jPCT both issues are solved. however in AE, if near plane is modified no blits are visible. i've tried 0.9 and 1.1

btw, i still dont get how near plane value helps my original issue. and looking at first screenshot again, now it seems as rendering is correct.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: frustum culling
« Reply #12 on: January 12, 2011, 11:32:23 pm »
you have removed Config.glAvoidTextureCopies in this last AE jar, so i guess Texture.keepPixelData only determines if texture data is kept ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: frustum culling
« Reply #13 on: January 12, 2011, 11:34:42 pm »
Thinking about it, you might be right. As adjusting the near plane only moves everything closer or away, the clipping behaviour itself on that plane will remain the same. Personally, i think that the rendering is correct...you are moving into the geometry, so clipping is unavoidable.

Anyway, i'll look into the AE issue tomorrow. May it be useful or not, it should be fixed.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: frustum culling
« Reply #14 on: January 12, 2011, 11:36:32 pm »
you have removed Config.glAvoidTextureCopies in this last AE jar, so i guess Texture.keepPixelData only determines if texture data is kept ?
Yes. Having both created a flawed logic, so i got rid of one.