Page 1 of 2

Terrain pager

Posted: Sat Jul 19, 2008 9:38 pm
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

Posted: Sun Jul 20, 2008 12:29 am
by BlindSide
Interesting, nice work.

Posted: Sat Aug 02, 2008 5:39 pm
by B@z
is it possible to use multiple textures for terrain?

Posted: Sat Aug 02, 2008 11:14 pm
by Nadro
It will be very useful, good work.

Posted: Sun Aug 03, 2008 2:40 pm
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.

Posted: Sun Aug 03, 2008 3:11 pm
by B@z
oh!!
i need that><
i'm sucks with shaders, so can you share it with me pls?><

Posted: Sun Jan 04, 2009 2:47 pm
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

Posted: Tue Jan 06, 2009 10:23 pm
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.

Posted: Tue Jan 06, 2009 11:27 pm
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.

Posted: Wed Jan 07, 2009 2:52 pm
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?

Posted: Wed Jan 07, 2009 3:16 pm
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.

Posted: Sun Jan 11, 2009 9:28 am
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.

Posted: Mon Jan 12, 2009 8:11 pm
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!

Posted: Tue Feb 03, 2009 12:17 am
by isfk
I've looked at the code and can't find why we are getting those black seams, does anyone have a clue?

Posted: Mon Feb 09, 2009 3:25 pm
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);*/
		}
	}
}