Terrain pager

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
ikam
Posts: 46
Joined: Sun Jun 24, 2007 4:46 pm
Location: France

Terrain pager

Post by ikam »

Hi

I'm working on a paging terrain based on the excellent terrain class released by Copland. (http://forum.irrlicht.fr/viewtopic.php?id=336). Many thanks to him.

Pager source code

Interrest of paging are possibility to render huge world for a low cost memory.

About the terrain class : terrain is tiled in meshbuffers so only the wanted tiled are render (tweakable distance between camera and render limit) + frustum optimisation and we can use heightmap size higher than 129 (irrlicht terrain scene node default). support internally VBO (with latest irrlicht svn version) and many other features.

About the pager : It takes many parameters in entry to set up paging (load distance, render distance, mapsize, quality, scale, position, heightmap list, etc...). It organises buffer zones where to load terrain and it check if a terrain need to be load or unload depending of the load and unload distance values.

I don't use threads for loading terrain, I found that it was not necessary because it doesn't freeze on load in release mode compilation (in debug there is a freeze loading) but heightmap size need to be lower than 257 that is a very correct heightmap size (for improve more speed you could use heightmap size lower than 257 : 129 :p)

There is two texturing methods :
- 1 colormap and 1 detailmap
- possibility to use shader

I'm also working on a terrain shader for use blending textures with alphamaps and atlas texture for possibility to use more than 4 textures, but I still have some small problems so maybe on a next version :p

some screen of pager :

Red boxes are terrain loaded.

Image
Image


bye
Last edited by ikam on Mon Jul 21, 2008 7:35 am, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Interesting, nice work.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

is it possible to use multiple textures for terrain?
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

It will be very useful, good work.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
ikam
Posts: 46
Joined: Sun Jun 24, 2007 4:46 pm
Location: France

Post by ikam »

thnks
is it possible to use multiple textures for terrain?
No, just 1 solid texture and 1 detail texture on fixed pipeline per terrain.

But you can use texturing shader like splatting or anything else like that.

I'm actually working on a texturing shader with alphamaps and texture atlas to blend more than 16 texture per terrain. It works fine but need some improvment.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

oh!!
i need that><
i'm sucks with shaders, so can you share it with me pls?><
Saumane
Posts: 27
Joined: Wed Jul 09, 2008 6:14 pm
Location: Finland

Post by Saumane »

ikam wrote:thnks
is it possible to use multiple textures for terrain?
No, just 1 solid texture and 1 detail texture on fixed pipeline per terrain.

But you can use texturing shader like splatting or anything else like that.

I'm actually working on a texturing shader with alphamaps and texture atlas to blend more than 16 texture per terrain. It works fine but need some improvment.
That sounds wicked.. Cant wait to see that! How's the progress with it?

Edit: Forgot to mention, i do have a few problems with the terrain.. I get these weird seams (take a look at the picture I've uploaded), and sometimes when i move around the terrain, the program just crashes.

Image
trnrez
Posts: 28
Joined: Wed Dec 27, 2006 5:56 pm
Location: Murfreesboro, TN
Contact:

Post by trnrez »

Looks awesome! What is the license on the code?

I believe I have found one issue though. I use 16-bit pngs for my heightmap. After I run your application it splits the image into multiple sections those sections are now 8-bit pngs. Would be really awesome if it maintained the quality of the image coming in.
Jon Jones
Portfolio - needs updating
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

How do you load 16bit pngs? There's no color format for this. I guess it'd be better to use 16bit RAW images. These are properly loaded by the terrain scene node.
trnrez
Posts: 28
Joined: Wed Dec 27, 2006 5:56 pm
Location: Murfreesboro, TN
Contact:

Post by trnrez »

hybrid wrote:How do you load 16bit pngs? There's no color format for this. I guess it'd be better to use 16bit RAW images. These are properly loaded by the terrain scene node.
Does Irrlicht use 16-bit grayscale images for heightmap creation as well as 8-bit?
Jon Jones
Portfolio - needs updating
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, as I said you can use the usual image loaders (but there's no way to load 16bit images AFAIK) or RAW format. The RAW laoder allows to specify the bitwidth and also loads float values directly.
Frank Dodd
Posts: 208
Joined: Sun Apr 02, 2006 9:20 pm

Post by Frank Dodd »

I may be wrong here as I haven't had time to run through the source code but as a suggestion those dark lines look like problems I had with tiling terrain objects where the normals at the X=0 Z=0 edges are not calculated or calculated correctly.

If your code has lighting on this might be the case, if supported by the object you could enable the display of normals and quickly check if they are pointing in the right direction.
Shane
Posts: 16
Joined: Fri Mar 23, 2007 8:16 pm

Post by Shane »

The download is extremely slow. I think this is sourceforge worthy, any chance you could upload it there? Nice job by the way, I can't wait to see your work!
isfk
Posts: 24
Joined: Tue Jul 17, 2007 8:12 pm

Post by isfk »

I've looked at the code and can't find why we are getting those black seams, does anyone have a clue?
link3rn3l
Posts: 81
Joined: Wed Nov 15, 2006 5:51 pm

Post by link3rn3l »

CRASH BUG , is in unload code, to fix crash error
comment this line in cterrainpager.cpp :

Code: Select all

void CTerrainPager::render()
{
  	scene::ICameraSceneNode* cam = SceneManager->getActiveCamera();
	const scene::SViewFrustum* frustum = cam->getViewFrustum();
	video::IVideoDriver* Driver = SceneManager->getVideoDriver();
	core::vector3df Pos = cam->getPosition();
	Pos.Y = getPosition().Y;
	Driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);

	size_t size = zoneList.size();
	for (u32 i=0; i<size; i++)
	{
		f64 ActualDistance = zoneList[i]->getBoundingBox().getCenter().getDistanceFrom(Pos);
		bool load = zoneList[i]->isLoaded();

		if(ActualDistance < Param.DistanceLoad && load == false)
		{
			loadTerrain(i);
		}
		else if(ActualDistance > Param.DistanceUnload && load == true)
		{
			/*delete zoneList[i]->getObjectInside();
			zoneList[i]->setLoaded(false);*/
		}
	}
}
Bennu (Best 2d and 3D dev-tool)
http://bennupack.blogspot.com

Pixtudio (Best 2D development tool)
http://pixtudiopack.blogspot.com

Bennu3D(3D Libs for bennu)
http://3dm8ee.blogspot.com/

Colombian Developers - Blog:
http://coldev.blogspot.com/
Post Reply