Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (855)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  LWJGL - 3D Frustum Issue  (Read 2970 times)
0 Members and 1 Guest are viewing this topic.
Offline KudoDEV

JGO Ninja


Medals: 79
Exp: 6 years


Game Dev Hobbyist


« Posted 2014-10-10 02:11:08 »

What is a typical set up for frustum culling?

I've looked at example codes but the culling is coming out wrong.

Chunks that shouldn't be rendering are rendering and some aren't rendering.

This is how I'm setting it up:
1  
2  
3  
4  
Matrix4f.mul(projMatrix, viewMatrix, combinedMatrix);
invProjViewMatrix.load(combinedMatrix);
invProjViewMatrix.invert();
frustum.update(invProjViewMatrix);


And I'm extracting the planes the typical way.

this is how I update my viewMatrix:
1  
2  
3  
4  
5  
setIdentity();
rotate((float) Math.toRadians(camera.getPitch()), new Vector3f(1, 0, 0));
rotate((float) Math.toRadians(camera.getYaw()), new Vector3f(0, 1, 0));
Vector3f cameraPos = camera.getPosition();
translate(new Vector3f(-cameraPos.x, -cameraPos.y, -cameraPos.z));



What's wrong?


EDIT: Heres what it looks like with me rotating the camera around: (It only renders wire mesh when its "outside" frustum. For debugging purposes.)

http://i.imgur.com/uvrYtGc.gifv


Big gif. Takes awhile to load.

Offline KudoDEV

JGO Ninja


Medals: 79
Exp: 6 years


Game Dev Hobbyist


« Reply #1 - Posted 2014-10-10 03:14:12 »

UPDATE:

Analysis: When I point the camera at the origin (0,0,0) all chunks render (I have it counting chunks rendered). And as I rotate over to 180degrees away from the origin the chunks stop rendering at a consistent rate as I approach 180degrees. Then if I continue towards 360 back to origin they start rendering as same rate they were disappearing.

I'm stumped... 

Offline ziozio
« Reply #2 - Posted 2014-10-10 06:17:10 »

I think you need to confirm your camera works 100% first, then you will have a correct in to screen vector.

Things to remember when you have a camera like rotation

1) When you start, up and down rotates around the x-axis
2) When you rotate left/right around the y axis 90 degrees, up and down now rotates around the z axis
3) When you rotate the camera matrix, rotate the frustrum at the same time or just rotate the in to the screen vector and then build the frustrum from that

Your image is what it is because your frustrum hasn't been rotated (it just looks like the viewing angle you had at the start).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline KudoDEV

JGO Ninja


Medals: 79
Exp: 6 years


Game Dev Hobbyist


« Reply #3 - Posted 2014-10-10 13:00:45 »

Thats what I figured. But the camera is rotating fine. So doesn't that mean my viewMatrix is rotating? And the projectionMatrix shouldn't change, right?

Offline KudoDEV

JGO Ninja


Medals: 79
Exp: 6 years


Game Dev Hobbyist


« Reply #4 - Posted 2014-10-13 21:57:56 »

Can anyone point me in the right direction?

Offline jmguillemette
« Reply #5 - Posted 2014-10-14 14:59:23 »

Not sure im following what your issue is..

can you be specific on what you want to have happen, expect to have happen and what your experiencing.

Will do my best to help

j.

-=Like a post.. give the author a medal!=-
Offline basil_

« JGO Bitwise Duke »


Medals: 418
Exp: 13 years



« Reply #6 - Posted 2014-10-14 15:15:59 »

can you be specific on what you want to have happen, expect to have happen and what your experiencing. Pointing
 
i'm also not sure whats going on tbh.
Offline KudoDEV

JGO Ninja


Medals: 79
Exp: 6 years


Game Dev Hobbyist


« Reply #7 - Posted 2014-10-16 15:01:05 »

My frustum isn't culling properly when I move the camera around. Its hiding chunks and showing chunks completely incorrectly.

Offline pitbuller
« Reply #8 - Posted 2014-10-16 18:42:00 »

Minimal stateless c++ implementation that I use for everything. http://pastebin.com/3uJmYXPT

It's work in any space you want.(Object, world, view)

If you have lot of shared state you can make it faster and precalculate most of the things but its already really fast(hundred million aabbs per seconds)
Offline basil_

« JGO Bitwise Duke »


Medals: 418
Exp: 13 years



« Reply #9 - Posted 2014-10-16 19:06:42 »

check out http://www.iquilezles.org/www/articles/frustumcorrect/frustumcorrect.htm

he's pointing out what is usualy made wrong when culling frustum.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pitbuller
« Reply #10 - Posted 2014-10-16 23:45:29 »

check out http://www.iquilezles.org/www/articles/frustumcorrect/frustumcorrect.htm

he's pointing out what is usualy made wrong when culling frustum.

I tested that method on one of our game and it improved frustum culling accuracy by big 0.2% margin. Using object space aabb's instead of world space was much bigger win with around 2.5% more objects culled.
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1574 views)
2018-06-10 19:43:48

EgonOlsen (1658 views)
2018-06-10 19:43:44

EgonOlsen (1145 views)
2018-06-10 19:43:20

DesertCoockie (1573 views)
2018-05-13 18:23:11

nelsongames (1174 views)
2018-04-24 18:15:36

nelsongames (1664 views)
2018-04-24 18:14:32

ivj94 (2421 views)
2018-03-24 14:47:39

ivj94 (1631 views)
2018-03-24 14:46:31

ivj94 (2719 views)
2018-03-24 14:43:53

Solater (884 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!