Culling advice.

Started by
10 comments, last by Dark_Light 19 years, 5 months ago
Hi People, I am looking for advice on culling. As you all know each of us are always looking for the best way of doing things. Now this is the situation. I have a landscape (very large) A camera (this moves around like it was a space ship) The landscape is split into zones. Each zone being 1 mesh. All the zones are held in a 2 dimensional array. Now I know about the far plane and a near plan but I don’t really know details about what this really means to me as a programmer. How can I get the best culling for my landscape!?!? I have a few solutions but I am after the best! Thanks
Advertisement
Seems to me you are in need of a technique called Geomipmapping to put your landscape into patches, these patches have differing level of details ( different amount of vertices ), so say you have a patch of 16x16, you could have say 4 level of detalis for this patch and dependent on where your camera/ship is you could change the patches level of detail, the closer the ship to the patch, the higher the detail. Ok, so what about culling, well for this once you get the geomipmapping to work you could then work on your culling. There are plenty of culling tutorials on the net about this and how to get the planes from the viewing frustum. Of course, checking all your objects in your game to cull is very expensive, especially checking the landscape, a good technique to use here is a quad tree, again, there is a very good tutorial on game dev about this, sorry I don't know the link but if you do a search you will find it.

Regards,
Steve

If it isn't working, take a bath, have a think and try again...

Thanks

You have hit the nail on the head, I have chopped the world up just so I can have details levels etc, I wanted to keep the question short so I left that bit out.

Let me try and explain what I am doing, its not to hard but may sound complex at first.

Ok the world is in a grid.
First I take the camera position and work out what grid it is in.
Then using that I can very quickly know what zones are local to the camera.

So at this point any zone outside the local area ie camGrid – 4 to camGrid + 4 etc is not drawn.

The local zones are then check from centre point to see if they are close enough to be drawn using sqr(power a-b,2 + blar blar blar

Then for each corner of each zone that is local and within a radius of n I check its angle against the camera look position. If any point is between 0 and 180 degrees then the zone is in front of the camera and so it’s drawn. Anything else is not.

Hope that clear.
Ok so knowing all that, would you say that is the best way to do it?
Sounds ok to me, I take it each 'zone' has a bounding coordinate so you don't have to check each quad within it ?
Does sound like the same principle a quad tree works on.

Your project sounds interesting, do you have any screen shots ?

Regards,
Steve

If it isn't working, take a bath, have a think and try again...

Steg.
Each zone is a square ad I do a check on each corner of the square to see if any are in the viewable area. If ANY are then the whole zone is processed. If none are then I just forget about it.

Before doing that I check the distance of the zone from the centre of the square to the centre of the camera.

I don’t have any screen shots as yet. I am having other issues with lights at the moment so I would like to wait for the full effect before showing anyone.

Thanks
Ok, sounds like you are kind of using bounding coordinates, although you may be drawing too many quads if you only check if the camera is anywhere within this zone. Quad trees work on parent node, child node principle, where a parent node would have child nodes, a child node may have other nodes, this way, you can elimate many quads/vertices you don't need to draw.

Out of interest, how big are your patches ?

Regards,
Steve

If it isn't working, take a bath, have a think and try again...

BTW, here is the link for quad trees :

http://www.gamedev.net/reference/articles/article1303.asp

Regards,
Steve

If it isn't working, take a bath, have a think and try again...

Quote:Original post by Dark_Light
...sqr(power a-b,2 + blar blar blar...

Answers already given are good, and you have probably already realised this, but if you are just comparing distances, you can compare the squares and save on the sqr. That is why people say sphere tests are really trivial:

Inequality 5 > sqr(x*x + y*y + z*z)
Square both sides 25 > x*x + y*y + z*z
Steg:
I’m just about to go and read that link you posted, but I believe I understand the principle of the quad tree. It simply subdivides over and over. This is good but I would think my method is faster as…

To find out what grid you are in all you do is X \ 128 Y \ 128 and you know the x y grid you are in, then all you need to do is loop thro X-5 to X +5 and Y – 5 to Y + 5. NOTE The numbers are arbitrary. This means i only ever look at zones that have a remote chance of being in use.

From what you know would you say this is better than the quad tree?

Also the zones are 1024 + 1 in size, the + 1 is where they overlap. This is a reason for this but I don’t want to discuss the geo mapping in this thread.

Dr GUI:
I must say I had never thort of that but now you have suggested it it is blindingly obvious. Should save a few clock ticks.

Thanks.
Did you manage to read the link ? What do you think ?

Your method sounds very similar to quad trees or some type of partioning technique. I take it your zones are also split into varying patches with different LODs ? You don't actually draw a full zone do you ?

Regards,
Steve

If it isn't working, take a bath, have a think and try again...

This topic is closed to new replies.

Advertisement