Page 1 of 1

Placing Terrain Scene Nodes

Posted: Sat May 01, 2010 6:14 pm
by Insomniacp
I created two identical ITerrainSceneNodes using a 306x306 heightmap (17*18=306, so there is even patch size). I placed one at 0,0,0 and the other at 306,0,0. When rendering there is a gap between the two of them which is simply confusing as I would think that the terrain node would be the size of the heightmap. I have found the actual size is 304x304 but I would still like an explanation :). Only thing I can think of is the edges of the image aren't used.

Posted: Mon May 03, 2010 9:41 am
by bonsalty
The answer is simple:

When you create the terrainscenenode, you set the the patch size. If its 65, then your terrain can only be the multiplicative of 64. So if you have a terrain of 306x306 it will be 256x256 in real. If you use patchsize 33, the multiplicative of 32 will be created. 306/32=9,5632 , so 9*32=288 , 288x288 will be created. So there will be a gap. To solve this problem, Im loading the image first, then I calculate the size from width and height. When you know the size, resize it when you create the node.

Posted: Mon May 03, 2010 2:40 pm
by Insomniacp
306 is a multiple of 17 which is my patch size so it should work properly should it not? and being an actual size of 304 seems regardless of the 17 which is the reason of my confusion on how this isn't adding up properly. (would make my map editor quite difficult once I add differing sizes to it). I attempted your solution of having proper size for a 32/33 patch size with a 288x288 heightmap and this resulted in large gaps again. I am fine with manually finding the new size of the terrain node or making an automatic system to do it I just want to know the reason it is doing this as it could potentially be a bug.

further testing:
image size 305x305 patch size of 17, distance is 304 again, I went down to 304x304 image size and there was a large gap. 304 is a multiple of 16 so why would an image 1 pixel larger make a correct 304x304 square than an actual 304x304 image?
(kind of mind boggling)

Posted: Wed May 05, 2010 3:08 pm
by Insomniacp
bump.
No ideas? I guess I will make a trip to the source code this week some time.

Posted: Sat May 08, 2010 5:30 pm
by bonsalty
Your patch size cant be 17 its 16 in real. To be more precise n*16+1 is the exact size. So its 305, there will a gap of 1.

Re: Placing Terrain Scene Nodes

Posted: Sat May 08, 2010 6:07 pm
by Acki
Insomniacp wrote:I created two identical ITerrainSceneNodes using a 306x306 heightmap
the heightmap must be in dimensions of 2^n+1 !!!
and it should not be larger than 129x129 (IIRC) !!!

Posted: Tue May 11, 2010 3:00 am
by Insomniacp
ok, thanks, is there a reason that it shouldn't be larger than 129x129? I haven't had any issues with larger ones and still get good fps.

In the documentation there wasn't anything stating the size of the heightmap which lead to the confusion on if it should be 2^n or 2^n+1. The only mention of size was the patch sizes and I thought that simply refered to the enumeration of patch sizes being 2^n+1 and didn't know how to correlate it properly to the heightmap size.

Would it be possible to add a sentence stating the heightmap should be K*( patchsize-1 )+1, where K is a positive integer of your choice?

Posted: Tue May 11, 2010 7:03 am
by Frank Dodd
Yes IIRC the missing strip is due to the edges of your terrain object being one LOD unit shorter than the the size of the bitmap, another issue you will probably encounter is the normals at the edge of your terrains when you do line them up.

Worse than these is the difference in LOD on the patches at the end of your terrains where they join as you move the camera towards them, this will cause cracks to appear in your terrain and then disappear making it look very ugly.

There is a module CTerrainTileSceneNode.cpp in my irrlichtwrapper source that solves these two problems. It is the same as a regular terrain node only you have a function attachTile that allows you to stitch them together, it was designed for massive/infinite landscapes, it works well but there might still be a bug or two in it though as I really haven't used it in anger.

you can just pull that file and its .h out and add it to your project.

Posted: Tue May 11, 2010 1:48 pm
by Acki
Insomniacp wrote:ok, thanks, is there a reason that it shouldn't be larger than 129x129?
yes, but not bc of LOD... :lol:
everything already answered: http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=33886

Posted: Tue May 11, 2010 4:16 pm
by hybrid
Since Irrlicht 1.5 (or 1.6?) the limit to 129x129 is not anymore. If your computer supports 32bit indices (all hw drivers should, but dx8 seems to have some problems with it), you can have almost arbitrary sizes. However, more than 1025x1025 usually won't render anymore with any non-zero frame rate. You should use (2^n)+1 dimensions to get a proper tiling of the terrain under LOD.

Posted: Tue May 11, 2010 7:04 pm
by Insomniacp
okay, thank you.

I have noticed the cracks before but figured its not a big bother for now. I will take a look at your code and see if I can pull what I need out of it.