when I import raw in unity terrain, it is like the picture1
http://www.jianshu.com/p/1d0fe567c9c8
the format of picture is like picture2 I really don’t know why
please help me thanks!!
when I import raw in unity terrain, it is like the picture1
http://www.jianshu.com/p/1d0fe567c9c8
the format of picture is like picture2 I really don’t know why
please help me thanks!!
For smoother terrain you need to use 16bit grayscale images. See:
https://docs.unity3d.com/Manual/terrain-Height.html
first, thank you very much, but it didn’t work, because I have already been bit16
to confirm for you, I import raw into unity terrain, and it shows like picture3, the picture3’s url is http://www.jianshu.com/p/1d0fe567c9c8
because my computer is Mac pro, so the byte order I choose mac,
finally it is like picture1



If you first paint terrain in 8 bit grayscale mode (8 位) and then switch to 16 bit grayscale, the terrain will retain “ladder-like structure” when you import it into unity, even though it is 16 bit. That’s because when you convert color from 8 bit to 16 bit, conversion does not automatically create smooth gradient.
Basically… in 8bit mode you have value of 0…255 per channel. And in 16 bit mode you have value of 0…65535 per channel. When you convert from 8bit grayscale to 16 bit grayscale, values 0, 1, 2, (8 bit) turn into 0, 256, 512… (16 bit). Which creates ladder-like steps.
To avoid the problem you’ll need to paint the terrain in grayscale mode since the beginning.
If you’re trying to convert existing 8bit grayscale terrain into 16bit grayscale and can’t just paint it over again… you could try blurring it slightly with a low radius gaussian blur after you’ve converted it into 16big grayscale color. This will smooth the steps somewhat (but may destroy terrain details).
i’m afraid I can’t give advice specific to mac pro, because I use different OS.
thank you so much for helping me.
the file I upload is the original file data screenshot, including file size and format
As you can see, it is tif format and 33M, is it 8bit, so no matter how I operate, it is still ladder-like?

If you used any image editing program like photoshop or similar and used layers, you need to merge all layers(flatten in photoshop) before you export/save it as raw file. I experienced some issues with that before, that some data from the layers seems to still get saved somehow.
(you don’t need to save the tif with merged layers, you can revert the merging after saving it as raw)
If that’s not your problem, it would be helpful to tell more about how you created the map, which programs you used and how you saved it as raw file etc.
thank you very much
I want to ask that when unity import raw, is it read the int16 format, rather than float format?
if it read float format, should it won’t like this stairs?
and how to read float format?
thank you very much
I want to ask that when unity import raw, is it read the int16 format, rather than float format?
if it read float format, should it won’t like this stairs?
and how to read float format?
I’m uncertain, but 16bit grayscale usually refers to 16 bit int, because float takes 32bit to store.
To read terrain floats by yourself you may have to implement your own reader. Apparently terrain data can be modified using GetHeights/SetHeights methods on TerrainData object, as specified here:
https://docs.unity3d.com/ScriptReference/TerrainData.SetHeights.html
Old thread, but I had the same problem and wasted an entire day trying to figure it out, I came up with a good work around here: https://answers.unity.com/questions/1638131/minecrafty-terrain.html?childToView=1914609#answer-1914609
It happens because you’re using 8bit images. 8 bit means there are only 256 possible height levels. To have smoother terrain, you’ll need more bits.
Hey thanks for the reply, that would be a problem, yes, but I’m not using 8 bit images, I’m using 16bit grayscale images.
Setting the image to “RGB 16bit” and reading the “Grayscale” using unity’s terrain tools… causes stepping… in 2021.2.13f1… I presume this is some kind of bug.

Setting the image to “R 16 bit” and reading of the “R” value instead of the “Grayscale” using the custom script below… gives the correct result

public class TerrainGenerator : MonoBehaviour
{
public Texture2D heightMap;
public float depth;
public float width;
public float length;
private bool terrainGenerating;
public void Update()
{
if (ControllerInput.NKey() & terrainGenerating == false)
{
StartCoroutine(GenerateTerrain());
}
}
public IEnumerator GenerateTerrain()
{
terrainGenerating = true;
Terrain terrain = GetComponent<Terrain>();
TerrainData tData = terrain.terrainData;
terrain.Flush();
tData.heightmapResolution = heightMap.width;
tData.size = new Vector3(heightMap.width, depth, heightMap.height);
float[,] heights = new float[heightMap.width, heightMap.height];
for (int y = 0; y < heightMap.width; y++)
{
for (int x = 0; x < heightMap.width; x++)
{
heights[x, y] = heightMap.GetPixel(x, y).r;
}
}
tData.SetHeights(0, 0, heights);
tData.size = new Vector3(width, depth, length);
terrainGenerating = false;
yield return null;
}
}