Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Massive LOD terrain demo.

Author
Message
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jul 2007 02:27
Been meaning to upload this for a while, LOD terrain using a single mesh, gives a pretty good draw distance for about 20,000 polygons, runs really fast on even basic systems.

Green Gandalf made the shader, but feel free to use whatever you find useful.

There will be a long delay the first time you run it, because it has to create a terrain mask image, once it's got that massive bitmap created though it should load up really quickly, you can even add paths and stuff once it's created.

We're going down... in a spiral to the ground...

Attachments

Login to view attachments
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jul 2007 02:29
Screenage.

We're going down... in a spiral to the ground...

Attachments

Login to view attachments
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 21st Jul 2007 02:43
Awww, crashage.

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Ian T
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 21st Jul 2007 05:55 Edited at: 21st Jul 2007 06:23
Freezes up on start. Time to add some logging to that code, I'll get back to you with where the problem lies.

Edit: Way for me to not read the long-startup warning. I'll give it another five minutes.

Edit again: Brilliant, I can't believe how smoothly this runs and how small the code is. The size of the mask image relative to the terrain is the only thing about the system that bothers me; obviously it's necessary for the multi texturing, however (assuming, from what I've seen of the code, the whole 2048x2048 image is passed to the shader as a mask). Perhaps there's a way to store the mask data in a smaller file and pass the piece needed for the currently rendered block of terrain to the shader in the form of a more digestibley sized bitmap. Again, awesome system over all. Great job.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jul 2007 14:14
It actually started off doing that, like the image was split into sevaral smaller pieces, but so was the terrain. Thing is, it would need overlapping images, like they'd have to be bloated to allow a single mask image to do the same job, and that would eat up memory. I decided to just go for it and use a massive mask image so that it could be edited.

This is getting cut down a lot for my own needs though, gonna add more texture layers and shrink down the terrain, for a RTS type game so it won't need to be so big.

We're going down... in a spiral to the ground...
Jna99
18
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 21st Jul 2007 15:08
....well it freezes here too

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jul 2007 16:27
Does it freeze, or is it just taking ages to draw the bitmap?

I'll see if I can upload a version with the image already rendered.

We're going down... in a spiral to the ground...
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jul 2007 17:22 Edited at: 21st Jul 2007 18:58
[Original post deleted by GG!]

2nd Edit

When I first run the demo it takes approx 21 minutes to finish loading/processing the mask image - and then the scene is too dark (as in the attached image).

However, when I run it again it takes only 2 mins (because it is using the previously prepared and saved mask image) and the scene is fine. I think this is another symptom of an obscure bug on my PC and nothing to do with your demo.

I tried some simple optimizations to your mask creation code but these seemed to have no effect.

I like the final result. I guess what you are doing is similar to my other shader which textures the terrain according to the terrain's altitude and slope - except you do all this once at the beginning by preparing the masking bitmap. Your solution should be more efficient (once the bitmap has been prepared).

Attachments

Login to view attachments
Omen
17
Years of Service
User Offline
Joined: 7th Nov 2006
Location: Maple Grove, MN US
Posted: 21st Jul 2007 18:54
Works fine here. After the terrain mask BMP is built, it takes about 20 seconds to load and I'm getting 350fps for 20k polys on my ancient ATI Radeon 9600 card. Turning off the texture and shader, I get 490fps.

Awesome job Van B !!!
David iz cool
18
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 21st Jul 2007 18:55
hey van i tried to run your project but dbp gets an error,says it doesnt understand commands.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 21st Jul 2007 19:19
Did you see the screen shot? 20000 poly - 1000+ FPS?

I don't know about you guys - but if I get 100fps - with ONE cube - I'm content

Know way too many languages - Master of none
Omen
17
Years of Service
User Offline
Joined: 7th Nov 2006
Location: Maple Grove, MN US
Posted: 21st Jul 2007 19:39
@Jason,

I think that's because Van B has traveled forward in time and brought back a video card from the year 2126... it's the only logical conclusion
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 21st Jul 2007 20:02
GG, it saves out the bitmap, so you'd have to delete it before you would see your changes. It is a damn slow way to do it, but I'm thinking that it'll be able to cast shadows from buildings etc as well, which should be pretty cool. I should really try and optimise that. I'm gonna make an editor that lets me paint the textures onto the terrain manually, because I want to have roads and stuff.

For some reason the pre-rendered version (16mb) won't upload.

My gfx card is great, I'd hug it if I thought it wouldn't electrocute me - 7950 GX2, I had 2 but gave one to my brother for helping with nanoid. I don't know how much of a difference it would make to SLI them, but from what I've seen they're amazing cards, one is plenty!.

I'm not sure where the bugs would come from, it is a fairly big texture I know - maybe I should make a mini version instead, like with a 512x512 heightmap.

We're going down... in a spiral to the ground...
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Jul 2007 20:38
Quote: "GG, it saves out the bitmap, so you'd have to delete it before you would see your changes"


I did that.

Actually, since it's only a masking image, why not use a jpg file? To save time I've attached it here. I can't see any difference when I use it instead of the bmp file.

I think all you have to do in your code is change all the ".bmp"'s to ".jpg"'s.

Attachments

Login to view attachments
Randomness 128
17
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 21st Jul 2007 20:58 Edited at: 21st Jul 2007 21:00
I got from about 750fps to 1180fps depending on how much was on the screen.

I wouldn't say it runs fast on the most basic systems, though, since it requires shader model 2 to run.

Question: Since the mask image uses a resolution of 4096x4096, will it look any different if the video card doesn't support texture resolutions that are that high?

Scorpyo
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 21st Jul 2007 21:54
Awesome stuff man !!!
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 21st Jul 2007 21:59 Edited at: 21st Jul 2007 23:25
I get black screen for about 15-30 seconds

then "runtime error 1002 Bitmap does not exist at line 235"

Then my Pentium M froze while posting on this forum, looked at task list didn't look like it was busy, but no other windows would respond. (could have been IE having a problem)

"Runtime error 504 cannot grab image due to illegal area at line 308"

LOD = Landscape of Doom?

[UPDATE]
I changed everyong from 4096 to 1024 and it worked. i dunno why my PC refuses to make a 4096x4096 bitmap



here's the code if anyone else is having problems



DinoHunter (still no nVidia compo voucher!), CPU/GPU Benchmark, DarkFish Encryption DLL, War MMOG (WIP), 3D Model Viewer
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Jul 2007 00:48
Are you using the latest update?

The bitmap size limit bug is a fairly recent fix I think.

We're going down... in a spiral to the ground...
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 22nd Jul 2007 01:49 Edited at: 22nd Jul 2007 01:54
I thought it was my graphics card being in 8mb mode but just checked it and it's in 128mb mode, so not that.

My DBP is on 1.066, I'll go and check if it's been updated, i thought i was on the latest

[update] 6.6 is the latest update it says

I wonder what the problem is? it still took like 15mins to traverse a 1024 map though, nice.

DinoHunter (still no nVidia compo voucher!), CPU/GPU Benchmark, DarkFish Encryption DLL, War MMOG (WIP), 3D Model Viewer
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 22nd Jul 2007 07:22
Have you determined this landscape runs faster than advanced? Also... what are the data files? (I know a texture or textures) but is it height map based? I know I haven't DL'd and tested it - but I've been coding ALL day - so I haven't had time - but I am interested if anyone cares to share - Terrain is very important in my current project.

Know way too many languages - Master of none
GatorHex
19
Years of Service
User Offline
Joined: 5th Apr 2005
Location: Gunchester, UK
Posted: 22nd Jul 2007 12:08
OK here's my results with a similar large advanced terrain.



I think I'll stick with AT for now

DinoHunter (still no nVidia compo voucher!), CPU/GPU Benchmark, DarkFish Encryption DLL, War MMOG (WIP), 3D Model Viewer
Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 22nd Jul 2007 14:17
@Van B:
This is a really cool piece of code. Great work Van B

Do you mind if I use this as a base for the terrain system in WORLD?

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Jul 2007 14:38
Sure DBKing, no worries.

The thing about Advanced Terrain is...

Every AT landscape looks the same.
You get an error when you try and use a 2048x2048 heightmap.
There's missing bits quite often, like a strip of terrain limbs.

This is not designed to replace AT, it's a solution for large maps.

We're going down... in a spiral to the ground...
Syncaidius
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: United Kingdom
Posted: 22nd Jul 2007 16:43 Edited at: 22nd Jul 2007 16:44
Thanks Van B.

jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 22nd Jul 2007 18:15
@VanB Good work Then

I'm with GatorHex for now - but I'm aware of a different bug in advanced terrain you didn't mention (But haven't found the "missing strip" yet unless toy mean when you try to tile them.)

I found a AdvTerrain bug where if the Meight map is say 257x257 and the texture is say 512x512 it blows up. The "killer" here is the 257x257 odd height map. I have GeoScape3d and it can export a height map with an extra row of pix to allow tiling seamlessly - well... Advanced terrain refuses to allow this.

As For advanced terrain always looking the same - I agree - has athe one detail texture tiled everywhere and the smoothing is predictable - however for a base its serving me ok for now. I DID get excited when I saw I could tile them - but the seams were crazy - unless I did some sort of manual edge height map manipulation and I suspect they would have to pretty level to not get a seam OF bevel edges down and overlap - which is doable but makes get terrain height x/y a bit tricky for a smooth transition (I know grab heighest of both as you cross would likely work)

I'm currently getting QUITE a feeling of depth for that tank game. I practically rewrote it - broke every code category into separate files - so each area is like a mini program in it of it self - Animations (like explosions, smoke, flames etc. go here), Tanks Source, Terrain Source, Music Source, Sound Source, etc. Now I was getting dogged out frame rates before - mostly because of trees etc - but I got a decelty high FPS using the Adv Terrain and the "scales" I'm using now - SO FAR - and some scenes are so big it looks like parallax scrolling background - I'll report back with progress - and a movie soon I hope.

P.S. The tank treads now are pretty darn close to perfect as is the momentum. And I also totally changed how the timing routines work - well - how I implemented the numbers - I had a flaw which is why the "object speed" was so dramatically effected by FPS. I was dividing where I should of been multipling.. and the funny thing is that I knew that but did it wrong anyway - I even named the results things like: SpeedMult# etc. haha

Ok Later

Know way too many languages - Master of none
Ian T
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 22nd Jul 2007 23:37
AT is absolutely riddled with problems, many listed above, and unlike this code you can't debug it or tweak it to suit ones' own needs. Obviously it might work for some individuals, but this system seems a lot more useful for my purposes right now.

If I succeed in optimizing the code in any significant way I'll post it here.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Jul 2007 02:04
Quote: "AT is absolutely riddled with problems, many listed above, and unlike this code you can't debug it or tweak it to suit ones' own needs."


I haven't noticed any significant problems with AT - and I've got several shader demos using AT in which I have "tweaked it to suit ones' own needs".

But Van B's demo is nice.
TinTin
17
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 24th Jul 2007 12:27 Edited at: 24th Jul 2007 12:28
This is nice Van_B...
A few crashes to start but then it started and ran beautifuly with no modification.

The shader used from GG isn't the best he's done and looked a little basic, although I'm not sure what level his current shader is at.

I spotted that you had a fog setup routine, but on my system the fog wasn't visible, I've not looked into why yet, I will when I get a chance.

I also noticed the following piece of code...


wouldn't this be better coded like this...??

this would eliminate a divide calculation and possibly speed things up a little, even though it runs super fast at the moment.

I've spotted a few routines that I may modify and use for my Terrain project, Credit will be given.

Keep up the good work, and well done...

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Jul 2007 12:38
Nah, it has to work out the X# in hundreds because the tiles are 100x100 units wide, this is used to reposition the terrain object on a grid of 100 units wide y'see.

I used that particular shader because of the control it affords. I mean I know he's done a few terrain shaders since that one - but personally I really like the idea of rendering my own shadows onto the terrain, so I use that one. It should be easy enough to add another 3 textures as well, so for my needs it's perfect, I want to be able to draw paths and stuff onto the terrain.

We're going down... in a spiral to the ground...
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Jul 2007 13:47
Van B

Glad you're finding the shader useful. It sometimes pays to keep things simple.

One problem I noticed when I ran your code is that, while the FPS is good (60+), as I move around the terrain the system would seem to freeze for a moment and then start again. My guess is that the terrain updating procedure is slowing things up on my machine every time I cross a "boundary". Is that likely?
Epimetheus
20
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Naples, Florida
Posted: 24th Jul 2007 14:37
@ Van B

Does this code do culling of limbs that aren't in screen?

Kinda like in this thread:

http://forum.thegamecreators.com/?m=forum_view&t=67369&b=6

When combined with the LOD system, it might have the speed advantage over advanced terrain.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Jul 2007 15:11
GG, it sure is . I think that delay is probably down to the time it's taking your PC to offset the vertices. There is a way to weld a mesh, I was meaning to look into that, like shave off those un-needed vertices so there's less of them to offset.

Epi, No it doesn't use limbs at all, it uses a 20,000 poly terrain mesh that is moved every so often then moulded onto the terrain. As I said though, it's not comparable to advanced terrain, because if you consider that AT can't use 2048x2048 heightmaps, you'd actually be lucky to do the same with 4 terrains at 1024x1024, don't even know if AT can go that high.

I'll add in the vertice welding and make a smaller version, see if that runs better. Instead of offsetting 60,000 vertices it could get by on 10,000.

We're going down... in a spiral to the ground...
Epimetheus
20
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Naples, Florida
Posted: 24th Jul 2007 21:44
@ Van B

You think it might be possible to cull unused vertices though? I think this could really become the ultimate terrain system if it uses LOD along with culling. Although, by going through and checking vertex by vertex it might get slower. Maybe some type of node system would do it then?
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 24th Jul 2007 22:49
the key is to make your mesh with already welded vertices.

see my previous post:
http://forum.thegamecreators.com/?m=forum_view&t=110679&b=1
it creates up to a 100x100 matrix with already welded vertices.
Small, and fast, and can create the mesh in real time. Once you create one, just make a mesh, lock the vertexdata, and set the y values for each vertice. Vertices are ordered at 0,0 bottom left, and 10201 at top right. Welding verts after can also be done with my weld vertice function, but this matrix is way faster.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Jul 2007 23:12
Will check that out Visigoth cheers, for some reason I have to load the mesh as a DBPro mesh then create an object from that, so it probably looses it's welds, this should sort it right out though.

We're going down... in a spiral to the ground...
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 25th Jul 2007 01:17
Van B -
I'm sorry I didn't spend some time earlier looking at what it is you are doing. I've been real busy working on my thing, and it seems we have a common goal. To be honest, I didn't even know what the heck LOD meant until I did a search Anyway, I have an idea for doing different levels of detail that should work great for flightsims and another idea for what you are doing. It's all based on my matrix, but only because I know how mine works inside and out, but the concepts should work with pretty much any terrain system. I haven't worked at all with heightmaps (greyscale images), only real 32bit float values for heightdata. As for your meshes getting unwelded, I've run into that also, with my matrix even. It seems DBPro likes to remake the indexdata index to what it wants on certain operations. Scale object() for one really messes it up. So I make sure I have everything set before I run any DBPro operations on the object. I want to add, in the last month, I've never had so much fun learning how powerful this programming language is. And it seems the more I experiment, the more ideas I get, and seeing posts like yours inspire me even more. I think we've all just touched the tip of the iceburg(well, some of you guys are way into the iceburg ; together I think we can do something that can be incredible.
Hoozer
17
Years of Service
User Offline
Joined: 8th Sep 2006
Location: Bremerhaven (Germany)
Posted: 25th Jul 2007 01:48 Edited at: 25th Jul 2007 01:50
@ Visigoth: A combination of both methods could be something really unbeleaveable impressive (if it's even possbile)!
(When I use the metapher of the iceberg: well then I'm the one who thinks about how it would/could look like, but not even have seen an ice-cube in a glas!)


Hoozer

AMD64X24800+(939);2GB;GF6800LE (@12PS, 6VS; 380 MHz, RAM: 434 MHz)
DP-Sw-Mode-Comp-Entry (updated to V. 1.4):
http://forum.thegamecreators.com/?m=forum_view&t=109846&b=5&p=0
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 25th Jul 2007 01:58
@Visigoth - You mean one of us will actually finish a game? Just kidding. I love these terrain threads and I hope you know I'm kidding around

I've experimented with the AdvTerrain being tiled - and I'm wondering how well that could be useful. Why? Because it is smartenough to chunk an tile "ONE TERRAIN" internally - and they look good - It (in theory) hides offscreen tiles (hide object.. or limb) and it calc's the distance likely in C++ - so its fairly fast already - So I wonder if DBPro coders can leverage the power under the hood - in such a way to leverage the faster running C++ code underneath.

Otherwise - regardless of the excellent work done by all here - AWESOME demos - VanB's demo, The TerrainScape project, the guy making Terrain based on satelitte numbers etc....

Point I'm TRYINg to get at is the looping through things and the calculations etc - to decide to hide/show/change LOD etc - seem to be more suited to assembled C++ code with tighter assembly of machine code at the core - (E.G. Far Cry)

Also - the Whole "dark Cloud" is DB where loading and unloading objects alot after a while starts hammering performance - I just don't know... meaning I am still wriestling this with my current Tank Game project.

FPS are a main concern - Big Textures - I found out today ARE NOT GOOD - (Ran current copy of game on a end-user type machine - ALL WHITE TERRAIN! YUCK - North Pole.


I Would really like to be able to have a big enough landscape so flying a heli is not a 1 minute flight from edge to edge...


It would be nice to make a ground/flight hybrid - making my own jump and go world of war fun. That's what I'm "shooting for"

Jason

Know way too many languages - Master of none
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 25th Jul 2007 03:05 Edited at: 25th Jul 2007 03:14
@Hoozer-
I love positive thinkers and I love Germans. You guys rock, I have two brothers that live in Germany. They owe me some money, maybe you can collect it for me and send it to me? Just kidding Stick around for the ride, its gonna be a good one! And nothing is impossible.

@Jason-
Ok, here we go.
First off, forget about Advanced Terrain, blah blah blah. That's for newbies. The key to the whole thing is the vertexdata commands, which last I checked, ADT doesn't have any. You can easily create your own objects, in the FVF format you want. FVF just defines what data will be included in the mesh that you create. All meshes have vertexdata (the points that make a vertex) and indexdata (a list to the the vertexdata that makes a triangle). You have to fully understand how this works to make any custom object in DBPro. A matrix is just an object. To hide or show an object is no big deal. Creating an object is no big deal, if you designed the object properly. You have to learn about triangle strips and triangle fans, to create the type of object you desire. What you need to know is, where the vertex points are going to be. Creating an EFFICIENT object is a big deal. Texturing an object sucks up memory. Sucking up memory affects FPS. My thinking, do as little texturing as possible. How do we do that, you are asking? Well, we define the color values, specular, emmissive, etc on a vertex by vertex basis. Keep in mind, this is terrain we are talking about. Not trees, houses, people, etc. When you think about a terrain, and the properties it has, what do you think about? It has height, it has color, it has texture(rough, smooth, shiny, etc.) All these properties can be achieved using only vertex data commands on an object with the proper FVF format. This is what makes DX so F'n powerful. Terrain should not be your money shot. Big terrains are cool, but the higher the resolution, the more memory and disk space terrain is going to take up. As for writing things in C, C++, C#. Those are good languages. And they are fast, no doubt. They give you access to lower levels of programming than what the built in DBPro commands can give. But have you tried to do 3D programming in another language? This is where DBPro excels. I've been a Visual Basic programmer for years, mostly database stuff. I wanted to learn DirectX programming. Microsoft released with DX7 a DX interface for VB. Just to get a blue screen, it took like 20 lines of code in VB. It was a mess. What TGC has done is wrapped all this code into easier to understand code, but, still give you some access to some real power if you need it. And with todays hardware, I say screw C everything. It's obsolete, in my opinion.
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 25th Jul 2007 04:05 Edited at: 25th Jul 2007 04:06
and to explain about how you could do LOD, at least in theory. Consider this, you have a matrix, of very high resoultion, (100,100) positioned at 0,0,0. On top of that you have a matrix of half the resoultion (50,50) positioned on top of that. On top of that, you have a matrix 1/4 the resoulution (25,25), etc. All these matrixs are hidden, except for the top level one, which is only 1x1. Say you are falling to Earth, heading right at that top level matrix. At this point, it is just a plain, 2 triangles, with an image pasted on it. You set your initial camera height to fill the viewport of the camera. As you fall, towards the matrix, the outer limits of the matrix will spill past the viewport of the camera. You will see a smaller section of the image of the first matrix, framed by the viewport of the camera. When the camera reaches a certain altitude, you simply hide or destroy the top level matrix, and show the next level matrix. Pasted on top of this matrix is an image that fills the viewport of the camera at that position. You keep drilling down in the same manner until you reach the lowest matrix, which of course will be the highest resoulution one. This is how I think flight sims are done.
Epimetheus
20
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Naples, Florida
Posted: 25th Jul 2007 05:00
@Visigoth

So how is LOD handled for a walking player?

I assume you could have multiple terrains that are welded at the seams and when the player gets close enough to one or farther away from one the appropriate resolution is shown. But I'm not sure that would be the most efficient method.
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 25th Jul 2007 06:00 Edited at: 25th Jul 2007 06:50
a walking player would have to be handled differently than a flying player, no doubt. But, since the terrain the walking player is walking on has an object ID, you can get this with simple checks. Say you have a grid of 100 x 100 hi res tiles. That tile can do 100x100 grid, or 20k polys. The player is situated at the tile located at 3,4. If you number your tiles from right to left, and increment each row by one, assuming a 1 based tile numbering scenario, he would be on tile(object) number 18. Now, compared to my falling from the sky scenario, where you only have to increase the detail of the matrix you are heading for, with a walking player, you have to increse the detail depending on the direction he is going. So, we can either increase the detail of the tile the direction he is facing, or, we can increase the detail of the tiles all around him. This would be 8 tiles. If we went maximum, that would be 8 tiles x 20k polys, or 160k polys, which most pc's these days could handle. So where do the maximum,minimum,in between tiles come from? Same way we do the flight sim. We make terrain tiles in varying details, and hide them until we need them. Of course, there will be a limit to how many tiles we can load, due to memory, but, when have you ever seen a game that has unlimtited terrain and it was local? It cannot be done, unless you want to give up GIGABYTES of Hard drive space. So, if you want unlimited terrain, you store the terrain on a web server, and feed it to the player as he approaches it. All this is totally doable in DBPro. If I can load 1.6 million ppolys, which I can, then sending a 40k chunk across the internet should be no problem. If you are serious about building something wicked, I'm recruiting.
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 25th Jul 2007 06:09
Van B-
sorry, didn't mean to hijack your thread, but, I had to answer these questions.
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 25th Jul 2007 06:28 Edited at: 25th Jul 2007 06:34
Epimethheus-
dang, your name is hard to type
Let me clear something up. I've tested, and loaded 1.6 million polys at one time. If each hi res tile is 20k polys, and you need 8 preloaded, that is only 160k polys. that would be for a world based on a scale of 1 unit = 1 meter. It would be big, not huge, but big. If testing determines that 4 levels of detail are adequate, then for assuming the algorytm of divide by two for each tile, that one tile would take up a total of roughly 10,789 bytes of data, plus the overhead of the object itself, which I think is that number x 3,not sure, so one tile with 4 levels of detail would be 43,156 bytes. Now, if yopu really wanted to be stingy about this, you could cut that in half by using integers instead of floats. Integers are only 2 bytes, floats are 4. Would we really need floats? I don't think so. So, at the minimum, with 4 levels of detail. I could do a walking player at about 44k bytes using floats, 22k bytes using integers, per tile. Multiply that times the total tile you want for the world, and it will tell yo how much memory you are going to take just for terrain. So, if I go integer, and decide a 10 x 10 tile system of 4 levels of detail, it is going to take up roughly 100 x 22k or 2.2 megabytes of memory onm top of the normal overhead for DBPRo, so this is WAY acceptable.
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 25th Jul 2007 06:42
doh, I did my math wrong, hi -res, would be 4,804 bytes. Assuming the divide by 2 scenario, the next tile would be 2402 bytes, then the next tile would be 1201 bytes and the last tile would be 600.5 bytes, which would surely be a problem, but, I'd work around, so a single tile, with 4 leveles of detail at that algoritem would take up 9,008 bytes. Multiply that times the number of tiles you want and there you go.
Visigoth
19
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 25th Jul 2007 06:46 Edited at: 25th Jul 2007 06:46
and with walk along grids, the only I problem I see is when a low poly grid touches a hi poly grid. They are not going to line up exactly. But, since the camera will be so far away, it shouldn't matter.
Epimetheus
20
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Naples, Florida
Posted: 25th Jul 2007 08:29
Infinite terrains are possible(just look at Torque) but after a certain point terrain does become generated randomly on the fly.
TinTin
17
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 25th Jul 2007 12:34
The best way I can describe LOD is by generating a mesh of a certain size split into a reasonable amount of segments to give the required detail level, If you place the wiew point somewhere in the middle, the display will show the grid gradualy dissapear into the distance. The trick is, at some point on the grid the display won't be able to show much detail, so at this point the grid should be doubled in size.

Try this code to show what I mean.

This uses 4 Matrices, and has an unholy amount of polygons, done properly, the middle sections of the larger matrices would be missing that's a saving of 2048 polys per matrix.
If you look close you may be able to see where the smaller matrices end in this example, try texturing them and the edge dissapears. Using this method, expansive terrains can be generated that have massive draw distances with the minimum amount of verts.
the trick is to keep the matrix centered around the player.

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
Epimetheus
20
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Naples, Florida
Posted: 25th Jul 2007 23:35
@TinTin


Good method, but wouldn't the edges not match up when the matrix has be heightmapped or distorted somehow?
TinTin
17
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 26th Jul 2007 17:28 Edited at: 26th Jul 2007 17:30
@Epimetheus
No...
There are no edges between the different scaled sections, there would be a jointing section 2x1 with 5 verts 3 polys, see below...

the above example was only to show what it would look like, the larger matrices would have their middle sections missing where the smaler matrices cover.


This eliminates the possibility of 2x2 poly edges not matching the adjoining 2off 1x1 poly edges..

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.

Login to post a reply

Server time is: 2024-05-04 09:49:30
Your offset time is: 2024-05-04 09:49:30