City Engine - Unity: Terrain mismatch

Hi,

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.

terrain mismatch

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:

convert -flop -depth 16 -endian LSB terrain.png gray:rawTerrain.raw

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:

Raw Terrain

Normalized:

Normalized Terrain

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).

ImageMagick’s normalize documentation

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.

The command that seems to do what I want is “-contrast-stretch 0” ImageMagick’s contrast-stretch documentation

Hi there,

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. :slight_smile:

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 ?

we have noticed as well that Photoshop sometimes generates faulty image conversions.

  • is it essential in unity to use the raw format for heightmaps?
  • give the image conversion another try with a program called imageJ

thanks for explaining the heightmap import into Unity.

When you exported the terrain did you refresh the project?

After the export the folders do not get updated! So it could be that when you use the file in question that it actually isn’t the updated version.

Hi,

Just thinking, if you are under a GOLD subscription you are eligble to update to CityEngine 2011. In the new version a lot of the terrain stuff is now a lot easier: http://www.procedural.com:9099/help/topic/com.procedural.cityengine.help/html/manual/al/terrain/terrain.html

Is it an option for you to update and try exporting your model again?

You have to check with your local Esri Distributor, they should have contacted you to update your version: http://www.esri.com/about-esri/locations.html

Is there a better way to communicate? via email?

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.