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.

Dark GDK / Terrain Lod

Author
Message
NoviceNate333
4
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 30th Oct 2016 07:06
Hello, my name is Nathan. I have been using gdk for a while now. im trying to rap my head around terrain lod. I have a general idea of how to do it but im hoping for your guys's input to help me along the way.

Here is how i plan to implement this.
Create a Large heightmap maybe 4096 for whole world
use a for loop to iterate through chunks of the image maybe 256x256 and use dbPoint() to return color and save that in either a mem block or maybe an 2D array im not sure yet. im fuzzy on memblocks in gdk lol or maybe use dbCopyBitmap command
then create a terrain objects for each chunk from the image.
have a second image half the normal size... 2048 divide it equally then scale to 2X larger i hope this would give the desired outcome.

a question can you exclude terrain and show the lower detail over a certain distance. i see no exclude, hide, or mask command in the terrain section.

if this is the case i could use the matrix commands and convert the color input to height data my self .

What do you guys think the best approach is and experience terrain lodders out their with some insight or past experience.

Im going to fiddle around with it tonight and post my progress.


Also i have the unofficial gdk update r114 or something like that and i think this is new. ...
dbSetTerrainSplit(id,sections);
does this command actually work?
NoviceNate333
4
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 30th Oct 2016 10:47
UPDATE:

so i have been messing around with prototypes using dbCopyBitmap() tis is what i have so far and it seems to work pretty well. Keep in mind this is my ruff draft nothing very clean about it lol.

+ Code Snippet

Attachments

Login to view attachments
WickedX
8
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 30th Oct 2016 21:58
Quote: "a question can you exclude terrain and show the lower detail over a certain distance. i see no exclude, hide, or mask command in the terrain section. "


An Advanced Terrain is an object like any other. dbExcludeObject, dbHideObject and dbMaskObject will work for the terrain.

Quote: "Also i have the unofficial gdk update r114 or something like that and i think this is new. ...
dbSetTerrainSplit(id,sections);
does this command actually work?"


I did not add this command. As far as I know it has always been a part of DarkGDK. Yes it works.
NoviceNate333
4
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 31st Oct 2016 01:36
OK awesome! thank you for that helpful reply, so if I was to split the chunks of terrain would that increase the fps more what is this command doing behind the screens. Is this some sort of built in lod. It doesn't seem to make any difference when I use the command.
WickedX
8
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 31st Oct 2016 03:42 Edited at: 31st Oct 2016 03:48
To avoid confusion understand their are three non compatible sets of terrain functions. Matrix Terrain, Basic Terrain dubbed Advanced Matrix which like the Matrix Terrain can not be manipulated with basic object commands and Advanced Terrain which can be manipulated. The attached demo is of the latter. A dbTerrainSplit of 8 will create a terrain made of 8x8 or 64 meshes.

Quote: "OK awesome! thank you for that helpful reply, so if I was to split the chunks of terrain would that increase the fps more what is this command doing behind the screens. Is this some sort of built in lod. It doesn't seem to make any difference when I use the command."


In theory a higher split will create more limbs. The object limbs not in the camera frustum will be excluded.

Attachments

Login to view attachments
NoviceNate333
4
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 31st Oct 2016 04:53
Hi! I looked at the demo you provided. i tried to create my own test terrain in Mapscape by evolved. I got an allocation error... what steps did you take to create the terrain? does it have to be in .dbo format, or can i use .x? Is Advanced terrain already in gdk or is that one of the libraries you have to buy from this site?
WickedX
8
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 31st Oct 2016 05:25
Advanced Terrain functions are included in DarkGDK. The demo builds the terrain using a heightmap image. After the terrain has been created you can save it in a DBO file for inclusion in the final game source. I don't think it will work with the X file format. You can however load a saved Advanced Terrain as an object. If Mapscape can output a DBO file and the terrain is built in a compatible manner, it may work.
NoviceNate333
4
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 31st Oct 2016 06:14 Edited at: 31st Oct 2016 08:08
Ok that is nice to know. Thank you for all of your help when i get a good lod system going i will post my code to help others who are struggling with it too. if there are anymore gdk users out here lol. Either way i think the ideology would remain the same just different programming. I Do have one more question. would it be more efficient to store the various lod levels of the chunked meshes or to store just the different height map chunks? would it use more resources to switch between low and high quality height maps or to just load all of the meshes in when the program starts?


Edit:

Im trying to create a mesh from the terrain data, but this isnt working. do you know why?
+ Code Snippet
it works with more simple objectbut not terrain
WickedX
8
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 31st Oct 2016 16:55
I forgot that in my demo, I am loading a previous saved terrain. Attached is the DarkGDK documentation and samples project which includes an Advanced Terrain demo.

Have you seen Evolved's LODTerrain demo for DBPro. You could port this to DarkGDK and optimize it with internal and DirectX functions wherever possible.

Attachments

Login to view attachments
NoviceNate333
4
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 1st Nov 2016 03:17
None of these demos show how to export the terrain. or create the mesh. I think i read it was a polygon issue. ive tested it it on normal objects and it can export to .x and i can use the d3d viewer to see the mesh, but nothing is exported with terrain and it completely ignores the command in debug mode.
NoviceNate333
4
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 1st Nov 2016 03:38
Double post! so i lowered the height map size to 64*64 and it exported just fine. Anything above that the function just crashes. so if i load a large heightmap... say 2048 and break it up into 64x64 chunks, which will create 1024 different heightmap images... thats a lot of data!
NoviceNate333
4
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 1st Nov 2016 05:38
Triple Post! ... I am having a problem with the terrain clipping together. for some reason there are small gaps between the terrain.

CODE:
+ Code Snippet

I have also attached a picture to show the problem.

Attachments

Login to view attachments
NoviceNate333
4
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 2nd Nov 2016 13:42
I have made a ton of progress with my lod terrain. my code is still pretty messy. i haven't started implementing classes or culling or anything so im getting around 25 fps right now. here is a screen. 20,000 instances of grass and like 500 trees and some rocks.

Attachments

Login to view attachments
Morcilla
14
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 4th Nov 2016 12:03
Quote: "if there are anymore gdk users out here lol."


Yeah, some of us are still around

Glad you got it working and so, how did you solve those ' small gaps between the terrain'?
NoviceNate333
4
Years of Service
User Offline
Joined: 7th Dec 2012
Location: United States
Posted: 5th Nov 2016 06:58
It was kind of weird... the program im using "World machine saves them by default 1 additional pixel, so instead of 512x512 it would be 513x513 so i was loading in a part of terrain that wasn't selected with i copied the the height map in chunks
Morcilla
14
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 8th Nov 2016 10:06
Aha, alright, no DGDK problem then, understood

Keep on the good work, that terrain is looking good

Login to post a reply

Server time is: 2017-11-20 13:27:38
Your offset time is: 2017-11-20 13:27:38