Why Terrain run very slow ?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

Why Terrain run very slow ?

Post by Guest »

I use this code for create terrain from height map
but when i run it very slow ,can anyone tell me how
to make it faster ?
thank in advance :cry:

Code: Select all

video::IImage* iTerrain =  m_pDriver->createImageFromFile("../media/HeightMaps/Terrain.jpg");
//Terrain.jpg size is 512 x 512
video::IImage* iHeightMap =  m_pDriver->createImageFromFile("../media/HeightMaps/land_map.jpg");
//HeightMap.jpg size is 1024 x 1024
	
scene::ITerrainSceneNode* iTerrainNode =  m_pSceneMgr
      ->addTerrainSceneNode(NULL,2,iTerrain,iHeightMap,NULL);
Gonosz
Posts: 24
Joined: Wed Oct 29, 2003 4:21 pm
Location: Hungary (one joke and you're dead)

Post by Gonosz »

I'm not sure how Irrlicht handles heightmaps, but as far as I'm concerned having an 1024x1024 heightmap means 2 million triangles... If you really want to have such a large map, you should try implementing a CLOD algorithm like ROAM.

Gonosz
Chev
Posts: 37
Joined: Wed Nov 19, 2003 6:15 am

Post by Chev »

Currently "Level of Detail" is not implemented with terrains, which means there are a ton of triangles. Currently I get better performance creating a TerrainMesh first and then creating an OctTreeSceneNode. Also, Performance really takes a nosedive if the heightmap is larger than 256x256. However the Terrain texture can be 2048x2048 without much of a hit.
Here's how to create the mesh:

Code: Select all

video::IImage* iTerrain =  m_pDriver->createImageFromFile("../media/HeightMaps/Terrain.jpg"); 
//Terrain.jpg size is 512 x 512 
video::IImage* iHeightMap =  m_pDriver->createImageFromFile("../media/HeightMaps/land_map.jpg"); 
//HeightMap.jpg size is 1024 x 1024 
    
scene::IAnimatedMesh* iTerrainMesh =  m_pSceneMgr->addTerrainMesh(iTerrainMesh, iTerrain, iHeightMap); 

scene::ISceneNode* iTerrainNode = m_pSceneMgr->addOctTreeSceneNode(iTerrainMesh);
Mercior
Posts: 100
Joined: Tue Feb 24, 2004 1:53 am
Location: UK
Contact:

Post by Mercior »

There is an unofficial terrain renderer for irrlicht at http://zenprogramming.tripod.com/. It has a handy function to render terrain with less polygons than in the heightmap (ie you can load a 1024x1024 heighmap and then scale the mesh to 50% triangles).
guest2

Post by guest2 »

I'm a complete newbie as far as programming goes. I can follow the tutorials pretty well though. I was trying to load a terrain by modifying the quake 3 tutorial. It can load the terrain if I followed the first guests code. I tried your code above but it results in this error

'addTerrainMesh' : cannot convert parameter 1 from 'class irr::scene::IAnimatedMesh *' to 'const char *'

I'm sure it's something simple that I'm missing..

#include <irrlicht.h>

using namespace irr;

#pragma comment (lib, "Irrlicht.lib")

int main()
{
IrrlichtDevice *device = createDevice(video::EDT_DIRECTX8, core::dimension2d<s32>(640, 480), 16);
video::IVideoDriver* driver = device->getVideoDriver();

scene::ISceneManager* smgr = device->getSceneManager();
scene::ISceneNode* node = 0;

video::IImage* iHeightMap = driver->createImageFromFile("../../media/m43_bump_8bit_8k_sm.jpg");//this works
video::IImage* iTerrain = driver->createImageFromFile("../../media/e43_flat_8k_sm.jpg");//this works

scene::IAnimatedMesh* iTerrainMesh = smgr->addTerrainMesh(iTerrainMesh, iTerrain, iHeightMap); //<---Error is here
scene::ISceneNode* iTerrainNode = smgr->addOctTreeSceneNode(iTerrainMesh);
Chev
Posts: 37
Joined: Wed Nov 19, 2003 6:15 am

Post by Chev »

sorry about that, forgot the quotes, try this

Code: Select all

scene::IAnimatedMesh* iTerrainMesh = smgr->addTerrainMesh("iTerrainMesh", iTerrain, iHeightMap); 
I'm a newbie too! :oops:
guest2

Post by guest2 »

Wow thanks a bunch!! Works now. It takes forever to load a 2048x1024 heightmap, but then.. I'm only checking it out.
Chev
Posts: 37
Joined: Wed Nov 19, 2003 6:15 am

Post by Chev »

wait till you try to add a triangle selector :)

My 256x256 heightmap is currently taking 30 seconds to load the triangle selector.
I'm trying to remember but I think a 1024x1024 took about 10 minutes to load a triangle selector (for collision detection) :shock:
Post Reply