[fixed] Terrain heightmap bug in 1.5

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

[fixed] Terrain heightmap bug in 1.5

Post by Eigen »

I ran into an issue with terrain heightmaps. I'm using the official 1.5 release. I have made no changes or even recompiled it. One edge of the terrain is always distorted. It doesn't matter what size the heightmap is. I tried 129, 128 and even the default heightmap that comes with Irrlicht (You can see an error in one of the corners). You can easily reproduce this error by making the heightmap a single solid color.

256x256
Image

129x129
Image

Hope this helps.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

I can't replicate this in the latest 1.5 branch source. Perhaps hybrid has already fixed it?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Wasn't there a bug a while back that made the side of the map average between the height given on the previous indice and 0? I think it had something to do with maps that were too big or something similar. Might want to check there. If not, maybe finding that fix will give you a lead, as the deformation seems strangely similar to the one seen then.
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

I tried the latest 1.5 branch version (1980) but still the same error occurs.

With terrain smoothing set to 0 it looks like this. It seems that one row of vertices isn't read or set.

Image
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Yeah, ok, this looks exactly like the old bug. Search in the bug section, you should find a topic about a near identical bug with similar pics.
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

Yes, I'll do the search in a second, but why would this happen? I mean, it's all standard .. the 1.5 release, running the example without any changes. I tried the official 1.4.2 release with the same plain heightmap and it works fine. So it must be something between these releases .. it can't be just me, can it?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The bug is almost invisible in the standard heightmap. And no one complained in the mean time.
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

I found a fix to the problem.
In CTerrainSceneNode::loadHeightMap I had to replace

Code: Select all

vertex.Pos.Y = (f32) heightMap->getPixel(TerrainData.Size-x,z).getLuminance();
with

Code: Select all

vertex.Pos.Y = (f32) heightMap->getPixel((TerrainData.Size-1)-x,z).getLuminance();
Now all heightmaps work as they are supposed to. I makes sense because when using 129x129 heightmap eg., it would try to read a pixel 129 when x is 0 and since it doesn't exist, it reads it as 0.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Super, thanks very much for looking into this. I'll give that a try. Tracking.

Damn, hybrid beat me to it! Curse my 12-year-old-single-malt addled reflexes.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply