Native heightmap scale

Blitz3D Forums/Blitz3D Programming/Native heightmap scale

stayne(Posted 2015) [#1]
What is a standard scale for a 512 heightmap? 20/2000 seems a bit blocky. 40/2000 doesn't seem high enough. Brushing off the cobwebs here...thanks.


Guy Fawkes(Posted 2015) [#2]
30/2000?


RemiD(Posted 2015) [#3]
A heightmap gives you 3 infos for each pixel :
PixelX%
PixelY%
RGB% (grey value of the pixel)

For the width and the depth, if you want a scale of 1pixel = 1unit, a 512*512 heightmap will correspond to a 512units*512units terrain.
For the heights, if you want a scale of 1grey value = 1 unit, a 0 to 255 value will correspond, for each height, to a height between 0 and 255units.

Then it is your choice to decide how much you want to scale the terrain depending on the details you want to have...


stayne(Posted 2015) [#4]
Seems in that case the height scale value should be double the size of the terrain width: 20 width 40 height? Still doesn't seem near high enough even at 255 grey value.


GfK(Posted 2015) [#5]
There is no "standard". Scale the terrain so that stuff looks how you want it to look.


RemiD(Posted 2015) [#6]
If you want that 1pixel corresponds to 1unit (for width, for depth) and that 1 grey value corresponds to 1unit, you have to scale your terrain like this : 1,255,1

here is an illustration of what i mean :


But you don't need to use this scale, you can scale it as you want depending on what you want to achieve.


stayne(Posted 2015) [#7]
Gotcha. Was going with the idea that 512 * 20 = 10,240 units and 255 * 40 = 10,200 units. Confusing but hey I'm 44 so I have an excuse :).

Thanks.


stayne(Posted 2015) [#8]
I think I may have figured out what the issue is:

http://www.bundysoft.com/wiki/doku.php?id=tutorials:terrain:step_artefacts

According to that article it's best to export png files as 16 bit greyscale. I've been going the 32 bit route. Will post results later.


Matty(Posted 2015) [#9]
blitz terrains will simply use an 8 bit value regardless of what format the image is in.....

So the most precision you can have in a blitz terrain re:height is 256 different height values for a particular grid position....

Admittedly it also used LOD as far as I know which will alter things slightly.


stayne(Posted 2015) [#10]
So it's impossible to avoid the stepping?


Matty(Posted 2015) [#11]
I'd say you are simply using an image which is not very smooth...


RemiD(Posted 2015) [#12]
Try to blur your heightmap, it should decrease the "stepping"


Rick Nasher(Posted 2015) [#13]
I managed get an acceptable result using:

level=LoadTerrain( "blitzhmp512.png" ) ;512x512x256 heightmap
ScaleEntity level,8,200,8

;Loading and assigning textures
land_tex=LoadTexture( "blitzhmptext4096(2).png" ) ; original terrain
ScaleTexture land_tex,512,512

tex0=LoadTexture( "Media\insaner\detailLIGHT.png" ) ; crackedstone (base texture)
ScaleTexture tex0,2,2

tex2=LoadTexture( "Media\insaner\CrackedStone_diff.BMP" ) ; top layer
ScaleTexture tex2,32,32
TextureBlend tex2,3

tex3=LoadTexture( "Media\insaner\lmap.bmp" ) ; lightmap
ScaleTexture tex3,256,256

EntityTexture level,land_tex,0,0 ; original terrain
EntityTexture level,tex0,0,1 ; crackedstone (detail)
EntityTexture level,tex3,0,3 ; lightmap


TerrainDetail level,8000,True ; if set to 1000 then weird fx
TerrainShading level,True


Axel Wheeler(Posted 2015) [#14]
Sorry to bump, but I dealt with this at one time. The answer is that Blitz terrains only allow 256 heights, regardless of the values put in. The heights look like floats from 0-1 but if you set a height to a random float, then read it back you'll see it changed slightly to the nearest 1/256th (IIRC).

The usually recommended solution if you want smoother mountains is to use one of the alternates that have been posted in the archives or wherever. These use "regular" meshes which support any height value, and usually offer tiling and other optimizations as well, but are harder to implement. I've never used them, but search on Blitz3d terrains and you should find some.


RemiD(Posted 2015) [#15]
or you can have heights from 0 to 25.5units and have a precision of 0.1 for each height, if you scale your terrain 1,25.5,1...