LWJGL Forum

Programming => OpenGL => Topic started by: newmangamers on December 10, 2012, 19:40:10

Title: Frustrum Problem
Post by: newmangamers on December 10, 2012, 19:40:10
i was trying to do Frustrum culling and there is a problem with my code, some tiles around the outside of the screen are clipped and not rendered. (note that my nfar is down to about 20 so the clipping away from the player is fine.)
(http://i.imgur.com/KF0zp.png)

Code:
File 1: http://pastebin.com/uKcz9QWq
File 2: http://pastebin.com/npbWdfDr
(you may want to copy the text into a file on your pc and read it in a program like notepad++ or eclipse as it is hard to read on pastebin)
I call
float size = 1f;
if(Meatis.INSTANCE.frustrum.isBoxInFrustrum(blockPos.x, blockPos.y, blockPos.z, blockPos.x+size, blockPos.y+size, blockPos.z+size)){
block.renderADVBlock(blockPos);
}
to check if it should be clipped. and i also call frustrum = FrustrumImpl.update(); every update.

If this code is a bad way of preforming this and you know a better, would you mind providing that way of doing this, if not would you mind help me fix my current code, Thanks,
Title: Re: Frustrum Problem
Post by: abcdef on January 21, 2013, 11:06:40
Not sure if you have solved this but it looks like you iterate through all your planes and if you find one that is out you return false. But what you don't do is continue to see if your object is inside another plane. If it is then your object intersects your plane and is neither in or out (overlaps)
Title: Re: Frustrum Problem
Post by: CodeBunny on January 21, 2013, 14:37:16
Also, it looks like you are separately drawing each tile, or at least checking each tile. I would seriously recommend batching chunks of them together - say, 8x8 regions which you check as a whole.