I’m importing a terrain from City Engine along with an entire set of FBX models (which compose an entire city). These two assets: heightmap and models are exported in two independent steps although all the necessary data is preserved to make it possible to merge them seamlessly in Unity. However, I’m having difficulties to achieve a correct match between them (houses are “inside” the terrain) as you can see in the image below. Do you have any idea about what can be causing this? City Engine exports the heightmap as a png file and then I convert it to raw using ImageMagick.
EDIT:
Trying to debug this process, I have already confirmed that the problem is caused by something related with the heightmap pipeline: CE terrain png export - conversion to raw - Unity terrian import, because if I export the terrain as a mesh in City Engine, its import to Unity matches the other models as expected.
I have also tried to do the conversion to raw in Photoshop, to ensure that ImageMagick’s command:
was not causing the problem, and I confirm that the problem persists with Photoshop conversion.
This also made me notice that the “-normalize” argument in convert was, for some reason, changing the values in the terrain image. I’ve created a script to check if the image coming from CE was already normalized and it effectively is, so the process of normalizing an already normalized image should not change anything… but it does:
Raw image:
Normalized:
EDIT 2: The reason for this is that -normalize modifier performs a different action than I was expecting (making sure that the color bounds are present in the image).
The intensity values are stretched to
cover the entire range of possible
values. While doing so, black-out at
most 2% of the pixels and white-out at
most 1% of the pixels.
It seems your issue is that you forgot to align the terrain to the Shapes. Those changes should then be reflected in the exported new terrain png file.
Since there were changes in the terrain, the min/max range may also have changed. Find the new range as follows :
CityEngine 2010.3 :
Select the lowest and highest (dynamic) shapes, convert them to static shapes. select the highest vertex of the highes shape and lowest vertex of the lowest shape and in the Inspector, you will find the y-values in the ‘vertices’ tab. Those two values represent your new min/max range.
CityEngine >= 2011.1 :
way 1 :
View the metadata of the exported terrain png file, where the new range is stored. Find the data e.g. with this link : Image Metadata Viewer
way 2 :
Just drag and drop the terrain into a scene as if you wanted to import a new terrain. Like this, the new range is also extracted and shown in the import window.
Yes, this is of course only the case if all of your terrain is filled with shapes, sorry for
missing detail.
We dot not know how Unity deals with heightMaps (bitmaps) and how they define terrains in Unity. Though if you’re using directly the exported 3D mesh of the terrain, are the polygons aligned correctly ?
Maybe it is because you are trying to align terrain not align the graph. If aligning the terrain. The changes of terrain won’t be reflect to the result in Unity.
By doing aligning the graph should solve your problem.