Author Topic: Help with frustum culling and perspective  (Read 1716 times)

Offline phlux

  • byte
  • *
  • Posts: 13
    • View Profile
Help with frustum culling and perspective
« on: August 20, 2013, 08:44:21 pm »
Hi,

I'm quite helpless in figuring out how to choose the correct FOV and also adjusting the nearPlane so my objects are not cut off. As mentioned in previous threads I'm working on some kind of dungeon crawler (eg Grimrock or Dungeon Master, Realms of Arkania). In the old games it is possible to stand directly in front of a wall and see the complete facing wall and some portions of the floor and ceiling. This is exactly the perspective I'm aiming for. Here is an example:



one step closer (standing direct in front of the wall)



Okay you can see here that at least a small area of floor is visible.

My implementation
Each tile (wall, floor, ceiling) is a 2x2 units small Object3D. So if a floor tile is created with the coords (0,0) (2,0) (0,2) (2,2) I position the camera at point (1,1) for example.
When I rotate the camera 90 degrees, walls will be cut off during rotation and you can see what's behind that block. From my limited 3D graphics knowledge I knew that I need to fiddle with the clipping planes in order to reduce this effect. I reduced the nearPlane to a size of 0.78f which suited my needs at first.

Same scene as the first screenshot.



Now going one step forward...



*donk* looks like I'm hugging the wall.

I tweaked the nearPlane and also the world cams FOV, nearPlane size of 0.4f and FOV of 1.2f



step closer



Looks better but editing the two values anymore makes it looks like an alien view, especially when rotating the camera. Anyone got an idea how to accomplish the desired perspective?

Here's also a movie, showing off what I got till now. It was taken with just the adjusted nearPlane: https://www.youtube.com/watch?v=7HDvKI6M5y0

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Help with frustum culling and perspective
« Reply #1 on: August 21, 2013, 07:32:22 am »
Have you set http://www.jpct.net/doc/com/threed/jpct/Config.html#glIgnoreNearPlane to false when adjusting the near plane?

Offline phlux

  • byte
  • *
  • Posts: 13
    • View Profile
Re: Help with frustum culling and perspective
« Reply #2 on: August 21, 2013, 09:20:32 am »
Yes I did, also forgot to mention this uses the hardware renderer.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Help with frustum culling and perspective
« Reply #3 on: August 21, 2013, 12:20:47 pm »
To me, it looks like as if in your positive example, the camera isn't centered. I.e. you are seeing a part of the floor, because the camera is closer to it.

Offline phlux

  • byte
  • *
  • Posts: 13
    • View Profile
Re: Help with frustum culling and perspective
« Reply #4 on: August 21, 2013, 01:49:56 pm »
Haha ;D I never noticed that. Thanks for pointing that out. I will try and lower the cam a bit. When I look at the lines it also looks like the camera is tilted a bit downward.

Offline phlux

  • byte
  • *
  • Posts: 13
    • View Profile
Re: Help with frustum culling and perspective
« Reply #5 on: August 22, 2013, 09:03:20 pm »
Okay, i tweaked the nearPlane value a bit and added 10 degree tilt to bottom. Works veeery well:



Step closer.



Thanks Egon!