New Tiled Terrain Scene Node [works with Irr 1.5]

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
roelor
Posts: 240
Joined: Wed Aug 13, 2008 8:06 am

Post by roelor »

hmm, strange. At ati catalist control centre I turned off AA and when I tried again. well my fps was the same.. 480..
p.s. the terrain is in total 1000x1000
thr
Posts: 3
Joined: Thu Oct 16, 2008 2:45 pm

Post by thr »

has this been tested with 1.5 ?
Darktib
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Post by Darktib »

I use this terrain with irrlicht 1.5 (in precision : irrlicht 1.5, svn revision 2136) and all works well
Last edited by Darktib on Mon Feb 09, 2009 4:23 pm, edited 1 time in total.
itx
Posts: 9
Joined: Thu Aug 10, 2006 12:46 pm

Bug?

Post by itx »

Im try to use tiles buts seems here bug with filtering

Im use this image:
http://mpog.ru/files/dirt_x_44.bmp

here a bug:
http://mpog.ru/files/bug.bmp
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

It isn't bug ...its feature! :) ...however unwanted one. It is caused by mipmaping. As mipmaps are generated automatically, pixels get blended, including those on border of our tiles.

hybrid promised he will provide access to mipmaps in the future in which case we can generate mipmaps ourself getting rid of this problem. However as far as Irrlicht 1.4 there was no such interface (I was not testing 1.5).

There is kind of workaround. You have to set your tiles few pixels smaller leaving border around. Pixels in the border should have the same color as tile pixels closest to them. Like this blending effect can largely happen in this border. Of course UV coordinates of tiles have to be set smaller too, to exclude border.
This will however not eradicate problem entirely and result depend largely on mipmap settings of your cardan and size of border. Less quality mipmaping & smaller border = more blending = uglier seams.

Another workaround is to turn off mipmaping. Not really good solution either.

So until hybrid fulfills his promise, no fix is really possible. Not with tiles like this.
Darktib
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Post by Darktib »

Sorry to dig this thread, but I think I've found a bug which is almost invisible (just a non-fatal heap corruption) : the array2d doesn't use the right operator for deletion.

The original code was:

Code: Select all

   virtual ~array2d()
   {
      if(w && h)
      {
         for(int i=0; i<w; i++) delete data[i];
         delete [] data;
      }
   }

   virtual void reset(int width, int height)
   {
      if(w && h)
      {
         for(int i=0; i<w; i++) delete data[i];
         delete [] data;
      }

      if(width && height)
      {
         w = width;
         h = height;

         data = new T*[w];
         for(int i=0; i<w; i++) data[i] = new T[h];
      }
      else
      {
         w = 0;
         h = 0;
      }
   }
and it should be:

Code: Select all

   virtual ~array2d()
   {
	   reset(0,0);
   }

   virtual void reset(int width, int height)
   {
      if(w && h)
      {
         for(int i=0; i<w; i++) delete [] data[i];
         delete [] data;
      }

      if(width && height)
      {
         w = width;
         h = height;

         data = new T*[w];
         for(int i=0; i<w; i++) data[i] = new T[h];
      }
      else
      {
         w = 0;
         h = 0;
      }
   }
The difference is the use of delete [] instead of delete.

I've not read the whole thread, so I apologize if it was already notified.
And sorry for my bad english.

Cheers,

~Darktib

PS: the 'updated for Irr 1.4' in the thread title can be deleted because it works perfectly for irr 1.5 and 1.6 SVN without any modif. :wink:
mjp5060
Posts: 3
Joined: Tue May 26, 2009 11:07 pm

quick question

Post by mjp5060 »

Hello, This is a very nice scene node by the way. Why do you call the drop() function on the terrain object before you are done using it?

Code: Select all

// set atributes of terrain
	s32 terrainWidth = 1000;
	s32 terrainHeight = 1000;
	s32 meshSize = 100;
	f32 tileSize = 1;
	core::vector3df terrainPos(0.0f, 0.0f, 0.0f);

	// setup camera
	MCameraFPS camera(smgr);
	camera.setNearValue(0.1f);
	camera.setFarValue(tileSize*meshSize/2);
	camera.setPosition(core::vector3df(terrainWidth*tileSize/2, 0, terrainHeight*tileSize/2) + terrainPos);

	// fog
	driver->setFog(video::SColor(255,100,101,140), true, tileSize*meshSize/4, tileSize*(meshSize-4)/2, 0.05f);

	// light
	scene::ILightSceneNode* light = smgr->addLightSceneNode(0, core::vector3df(0,0,0),
   video::SColorf(255, 255, 255, 255), 1000.0f);
	video::SLight ldata = light->getLightData();
   ldata.AmbientColor = video::SColorf(0.2f,0.2f,0.2f);
	ldata.DiffuseColor = video::SColorf(1.f,1.f,1.f);
	ldata.Type = video::ELT_DIRECTIONAL;
	ldata.Position = core::vector3df(-10.f,5.f,-5.f);
	light->setLightData(ldata);

	// create test scene node
	scene::IAnimatedMesh* testmesh = smgr->getMesh("media/test.3ds");
    scene::IAnimatedMeshSceneNode* test = smgr->addAnimatedMeshSceneNode( testmesh );
    test->setMaterialFlag(video::EMF_LIGHTING, false);
    test->setMaterialFlag(video::EMF_FOG_ENABLE, true);

    // create terrain scene node
    ShTlTerrainSceneNode* terrain = new ShTlTerrainSceneNode(smgr, terrainWidth, terrainHeight, tileSize, meshSize);
	[b]terrain->drop();[/b]

	// setup terrain node
	terrain->setMaterialFlag(video::EMF_LIGHTING, true);
	terrain->setMaterialFlag(video::EMF_FOG_ENABLE, true);

    terrain->setPosition(terrainPos);

    // set terrain to render around camera
	terrain->follow(camera.getNode());

    gui::IGUIStaticText *text[10];
    text[0] = guienv->addStaticText(L"RANDOMIZING TERRAIN", core::rect<s32>(250,140,400,160), false);
	text[1] = guienv->addStaticText(L"...please wait", core::rect<s32>(440,140,700,160), false);

    driver->beginScene(true, true, video::SColor(255,100,101,140));
	guienv->drawAll();
	driver->endScene();

	// randomize terrain
	makeRandomHills(terrain, 20000, 20);
	makeRandomHills(terrain, 100000, 5);
mjp5060
pera
Posts: 460
Joined: Wed May 14, 2008 1:05 pm
Location: Novi Sad, Serbia
Contact:

Post by pera »

looks very nice.

fog is doing the distance trick, but can it be used to make large terrains where you can see mountains in the distance?

how do they do it in oblivion? :)
mjp5060
Posts: 3
Joined: Tue May 26, 2009 11:07 pm

Post by mjp5060 »

pera are you referring to a skybox and there is a mountain drawn on it?
mjp5060
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

I think he means like this : http://xbox.kombo.com/images/media/oblivion_002.jpg

Those mountains aren't the skybox, you can actually go climb them.
pera
Posts: 460
Joined: Wed May 14, 2008 1:05 pm
Location: Novi Sad, Serbia
Contact:

Post by pera »

yes, real terrain, not a skybox. (nice picture)
how do they do that?
lets say whole map is divided into square patches (like this one), close one are rendered in details, and far ones are rendered simplified.
But still that mountain mesh in the picture is very detailed it doesnt get squery (or triangly).
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Maybe it's something like bitplane's render to skybox scene node:

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=13288

Or imposters:

http://www.youtube.com/watch?v=cHAfqwagk7I

There are probably quite a few more ways to do this. Also don't foget that Oblivion outdoors is quite resource intensive. When it was released even high end cards had trouble keeping over 30 fps on outdoor scenes.

If you had to render it in a simple fashion, I recommend using a very large zbuffer far value and near value, rendering far away things, and then clearing the z buffer and switching to a small far and near value for near things.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

mjp5060 >> When you create custom scene node and attach it to scene graph via passing parent scene node as argument in constructor (in this case root scene node is set as parent automatically ...look at constructor in ShTlTerrainSceneNode.cpp) its reference count is raised by 1 (means reference cont is 2) ...because parent now holds pointer to your node. That means I can drop() my node because from now on, scene will take care of it, lowering reference count back to one.

pera >> what you look for is called LOD ...level of detail and no, this node does not have LOD implemented. I was working on implementing LOD but for some time I don't work on this node anymore.
LOD means that geometry ...in this case terrain tiles are rendered with less and less detail, farther away they are from camera. Thats what you can see also in Oblivion. How they did it to achieve detailed look I don't know, but I would say texture does the trick.

Darktib >> which version of files do you use? I ask because I was correcting it already after some other people noticed it also. ShTlTerrainSources17042008.zip should include corrected version.
Darktib
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Post by Darktib »

I use the 17/04/2008 version.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

You are right, while destructor was corrected, reset() still have that bug. Thank you :) ...I will post corrected files.
Post Reply