TerrainGrid Gaps

So basically, I’ve been working with terraingrid. Here’s a summary of all the information
I have various heightmaps and splatmaps. They’re all 64x64, all match up perfectly except the X and Z need to be swapped (even when it’s not, the problem is still there)
The following is the terraingrid instantiation line:
terrain = new TerrainGrid(“terrain”, 65, 129, new Vector3f(128f, 8f, 128f), new ImageTileLoader(assetManager, new Namer() {

        public String getName(int x, int y) {
            return "maps/"+y+"_"+x+"/height-0.png";

As you can see, this scales the maps 128x128 (for some reason, not 8x vertically, but that’s no problem).
The LOD calculator is as follows:
TerrainLodControl control = new TerrainGridLodControl(terrain, this.getCamera());
control.setLodCalculator( new DistanceLodCalculator(33, 4f) ); // patch size, and a multiplier
The problem I’m facing is that the exact same 2 lines (what would be the bottom and the right) are appearing at 0 height on every map. I don’t know what this is supposed to do (perhaps blend with the other map?) however it’s been extremely irritating me, as I can’t seem to find a way around it.
It’s definitely nothing wrong with my images. The issue is evidently that the terrain size is 65x65 but these are 64x64. I have no clue as to why it needs to be 2^n+1, however I’m sure there’s a good reason.
Is there any explanation for this?

I don’t know anything about image based terrain loader since I generate my height fields by code, so with that disclaimer…

The 2^n+1 comes from making triangles of the height map. Imagine that you pick the upper left pixel of the image (0,0), then you generate a triangle by going from that to 1,0 and then to 1,1. Then another triangle from 0,0 to 0,1 to 1,1.
So basically you need 4 pixels of the height map to make two triangles, working from top-left, but what to do when you get to the 64th row or column?
You can do like this terrain does and “borrow” from the next grid to the right and down. The 65th column must be identical (in fact the same) as the 0th column of the cell to the right. Yes you are totally right, they overlap to blend with the “other map”

Hope that makes it clearer.

So my images need to be 65x65, and I need to make the bottom line identical to the top line, and the right line equal to the other maps left line?
It says in the documentations, for example, a 512x512 map size with 513 as the size.

You can always try :slight_smile: Maybe the image based terrain loader (should) do some magic and create the 65th column/row by looking at the “next” image, I am not familiar with that code so I can’t really say.

I made a small program to iterate all of my heightmaps, and append the appropriate line to them (the entire process took almost half an hour), however, I got there in the end, and all works fine now!
Edit: It would be highly useful if it was mentioned in the wiki. jME3 hasn’t been keeping the documentation up to date. I might offer to start contributing once I update my knowledge to jME3

All terrain patches, quads, and grid tiles are 2^n+1, so 65x65. Each pixel in the height map corresponds to a vertex in the patch; this is used in conjunction with the LOD algorithm.

<cite>@fabsterpal said:</cite>

Edit: It would be highly useful if it was mentioned in the wiki. jME3 hasn’t been keeping the documentation up to date. I might offer to start contributing once I update my knowledge to jME3

You will find that jME3 is one of the most well documented and up-to-date documented open source projects out there. At the end of the day though it’s all maintained by volunteers so if you can do your bit to help keep it up to date that would be welcome.

TerrainGrid can be a difficult monster to work with when dealing with pre-made tiles, .j30 OR images.
Save me typing it all again please read my post here http://hub.jmonkeyengine.org/forum/topic/terraingridtileloadertest-confusion/#post-232055

I went quite far with terrainGrid before abandoning it for my own invention (wip) so had some experience with using it with image based tiles AND .j3o tiles.

Seems to me it works best(easiest) for fractal/noise based terrains. Not to say pre-made tiles are impossible, just difficult.