Giant terrain, draw distances, culling.

Blitz3D Forums/Blitz3D Beginners Area/Giant terrain, draw distances, culling.

Ian Martin(Posted 2010) [#1]
I have been programming 2D in Blitz3D for quite some time. I have a lot of questions about a large scale 3D game based on very large terrain. I haven't done any 3D projects, so this would be the first and second games in 3D. Both involve very large terrains. If anyone has done this sort of thing before, could you answer any of these questions or point me in the right direction? I can't wrap my head around the necessary data structure and have a type of writer's block because of it :(
What draw distances and relative sizes are you using? How far away are you drawing? If you had a game where you could drive anywhere in an open environment that models an actual area, for example, Kansas (easy for 3D as it's flat) and you were driving a car and tracking giant robots 500 foot to one mile high, how would you handle draw distances, culling out objects, etc.? I realize most games use mountains, pinch points, and so forth to limit draw distance and cull out what needs not be drawn. However, if you HAD to draw everything in a completely flat environment, how would you go about it?! Let's say you are doing the entire state of Kansas, how would you handle only having part of it in memory? Would you load smaller pieces? Load one piece with 8 pieces around it and then unload the extra pieces and add pieces when moving to a new (center) piece? How have other people handled a 'huge world' game?
Any help most appreciated!

Ian


_PJ_(Posted 2010) [#2]
I recall an ideal scale is from 1:1000 so the CameraRange near and far values follow that ratio

ie.
CameraRange Camera,0.1,100.0

However, it's possible that more modern graphics and processing capabilities may cope adequatiely with greater distances.

As for the actual memory constraints of large worlds, there's a few options,

1) Tile Terrains. Rather than use a single mesh or terrain for level geometry, build many of them in a tile format, for examp[le 3x3 terrains to make an area 9x larger than a single terrain mesh.

2) 'portalling' whhereby only specific regions are loaded at a time. New areas are loaded when the polayer traverses through a 'portal',. This is ideal for buildings with multiple rooms, since the 'portals' can be doors between the rooms, but for open areas, it's not always a good idea,.

3) Occlusion and on-the-fly loading:
By hiding, destroying and creating/loading small amounts at regular intervals, you get the best of both worlds. Minimal loading time with the effect of a virtually continuous play area. This method does require a complex organisation structure though.

There may be more and better sugggestions, but I think these are the most common that I'm aware of, and the ways in which I would tackle the idssue.


Ian Martin(Posted 2010) [#3]
Thanks Malice!

I think I will have to go with a combination of Tile Terrains and Loading and Unloading on the fly. I am just wondering what I will do about objects that should be visible but aren't on the tiles that are currently loaded - like a huge one mile high robot. I guess robots could just be separate objects that are always visible? That would probably work.

I'm still unsure about how far away it is practical to draw something. If a house is a mile away, will it be just a dot or two? Maybe I don't need to draw it then? I HATE the idea of using fog to block out distant objects. I think it is very cheesy are ruins immersion. Superman 64 for the Nintendo 64 is an example of how bad this can look - Kryptonite Fog, heheh Anyone have opinions on how far it is practical to draw houses, barns, silos, phone polls, roads, etc.?


_PJ_(Posted 2010) [#4]

If a house is a mile away, will it be just a dot or two?

Again, this is really dependant on scale, since a 'mile' for your game may be hundreds or thousands of "Blitz3D units", whilst someone else's (such as space games etc., a Mile may be just a fraction of one unit.

But I see your point, and from your mention of a house and a mile, it sounds like you're using a scale perhaps of 1 Blitz-unit equals about a metre or so.

Draw distance is a pain in the backside I think for any game programmer, since evferyone wants to have that realistic depth of field vision, but with a lot of polygons rrendered or objects coliding etc. things slow down fast.

There are tricks to combat this though without relying on fog to blatantly blur out the distance.

1) LOD changes:
LOD (Level Of Detail) can be altered for objects depending on the distance. At close range, the objects will be fully rendered in all theiur glory, further away, they may lose levels of texturing (including lighting effects or 'decal' sprites attached) as well as actually deforming the mesh itself, thus lowering the number of polygons involved. This is evident in games such as Spore, where distant objects lack much of the finer details

2) Substitution
Instead of actually messing with your objects, you can simply 'Hide' them from the camera view and instead 'Show' a lower-quality version, or even a flat mesh (sprite even?) instead.

3) Use 'Carded' backgrounds
For very distant, static backgrounds, you can place 'Cards' which are effectively flat meshes* or sprites which give an impression of treelines or mountains or distant buildings etc. With careful placement of these at varying distances around the "unreachable" distant areas opf your playing field, the impression is given that there is a more vast world.
This is used a lot to great effect in Half-Life 2 (moreso in the episodes), especially with the "Combine Citadel" which appears to tower away in the distance.

--

Either way, fortunately, if it's only houses/barns etc you really are concerned with, the advantage is that these things are mostly cuboid in shape, the LOD tricks can be really advantageous here, where at the minimum, you may only need 4 triangles to make a virtual cube (since two back faces and the top and bottom will not be visible to a player from the ground level) These 4 triangles can be textured to give the appearance of whatever details will be apparent at closer range. It may even be possible to take a good screenshot of the close-up fully rendered object to use as the texture for the distant version.
Never underestimate the potential of a good texture to save on some mesh details :)

*these flat meshes may be curved slightly to give a more 3-D appearance as the view moves around


Ian Martin(Posted 2010) [#5]
These are some great suggestions, thank you!

I think LODs are going to be the way to go, substituting lower quality stuff the farther away it gets. I think this will work great with the houses/barns/etc. I'm thinking Iron Giant stuff here. I want to be able to smash the houses and tear down electric poles, but only if they are close enough to see. I can just fake them smashed if far enough away I think.

I'm going to have to figure out scale once I get things up and running, I would say. I think I will make something totally rough with very low poly everything to figure out scale and gameplay and then work out making everything look and act right later.

Resident Evil 4 did some great things with LODs...they would draw the zombie closest with the most detail...no one ever notices the zombies that aren't almost eating you! I've seen Spore but don't remember LODs changing, I guess I didn't pay that much attention. They must have done it right since I didn't notice.

I'm thinking sprites would work pretty well for very distant stuff. I doubt I would need it if I have houses made of six polys. I should be able to have a bunch of those at some great distance. The background will no doubt need to be a flat mesh or sprite. At some point you are drawing a skybox anyway. I think I just need to figure a way to more the farthest back background back if the huge thing is farther away than the background. I like what you said about carded background like in HL2. I need to take another look at the part in Episode 2 where you are fighting all of the walker thingies outside. That scene is very large looking.

Copying a screenshot to use as a texture is a great idea! This would definitely make the stuff look great at distance. Textures in general can add a lot of definition. I would love to have an 8 poly house far away, and then render a house board for board close up. Then I could have mr. giant robot step through it, throwing everything through the air. I figure this is only going to happen to a few houses simultaneously, so it could work. I guess it could bog down very quick if too many pieces are involved. Only experimenting is going to give the answer to that I know. The kinda bad thing is my target computer is not what I'm developing on...so it may look fine on this one and kill a dual core.

When you say curve the meshes slightly, you mean curve them AWAY from the player, so they don't notice the edge?

Anyway, thanks for all the help. I think I have a good idea what I need to try now :)