Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by andresp · Nov 08, 2011 at 10:27 AM · terrainimportheightmap

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ibot · Dec 15, 2015 at 03:10 PM 0
Share

@andresp - it doesn't seem like this question was ever answered. i'm encountering the exact circumstances with terrain heightmaps exported from City Engine. in CE everything lines up nicely and Align to Terrain matches all of the buildings perfectly to the terrain. but when i import the RAW heightmap into Unity, it's all off - even when i place the buildings in the same exact location as they were in C$$anonymous$$ did anyone find a solution to this? THX for the clues ...

7 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by proceduralien · Nov 08, 2011 at 12:52 PM

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 : http://www.fileformat.info/convert/image/metadata.htm

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image andresp · Nov 08, 2011 at 03:02 PM 0
Share

hi, first of all thanks for your answer.

Although, this happens despite we'd already aligned the shapes to the terrain and then the terrain to the shapes.

I don't have the 2011 version yet (we are waiting for the license update :)), but your approach for the 2010.3 doesn't seem to work. Your procedure would only give me the lowest and highest altitude of my shapes, not the lowest and highest point of the terrain. I think I would have to add a shape to the lowest and another one to highest point of the terrain (if I happen to know what those points are) and only then perform your instructions to get the terrain height range.

However, in this case, I think the terrain height range shouldn't have been changed as the shapes which alter the terrain are all far from the height interval bounds.

avatar image
1

Answer by proceduralien · Nov 08, 2011 at 03:12 PM

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 ?

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image andresp · Nov 08, 2011 at 03:15 PM 0
Share

nice suggestion, I will try that right away and let you know.

avatar image andresp · Nov 08, 2011 at 03:16 PM 0
Share

However, I'm not sure if I'll be able to import the terrain mesh because of Unity's 65k vertices limitation. I'll try... :)

avatar image andresp · Nov 08, 2011 at 06:21 PM 0
Share

after some "fighting" with Blender (terrible UI xD) to cut only a piece of the big terrain, we were finally able to test the terrain mesh, and, as expected, it correctly matches the other models' positioning / height. This implies that the problem resides in the heightmap pipeline: CE export - Image$$anonymous$$agick conversion - Unity import. However, I'm out of ideas to "debug" this procedure. I've tried testing the same use case using a heightmap in Blender but I don't know how to do it there :s

avatar image andresp · Nov 09, 2011 at 12:03 PM 0
Share

I've tested the same situation by using Photoshop to convert the png heightmap to raw, and I still have the same issues. I've also noticed a strange peculiarity related with the image normalization process. I've edited the main question to reflect these new tests.

avatar image
0

Answer by proceduralien · Nov 09, 2011 at 12:31 PM

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image andresp · Nov 09, 2011 at 12:42 PM 0
Share

yes, RAW images are the only way to import a terrain into Unity

I'll try that conversion program.

Additionally I can tell you more about the import in Unity. It asks for the terrain's width (X) and length (Z). I need also to introduce the height delta (Y). These parameters I get from the ones I use inside City Engine. Additionally I also have to tell Unity the raw image dimensions, bit depth and byte order. After this import I move the terrain to its correct place as inside City Engine the terrain is centered in the origin, but inside Unity the terrain is placed with one of its corners in the origin. I translate it by -X/2 and -Z/2 to center it and then move it up to the $$anonymous$$imum height value. I think this is the correct process and should place the terrain in its exact position.

avatar image andresp · Nov 09, 2011 at 01:03 PM 0
Share

the raw image created by imageJ produces the same results as Photoshop and Image$$anonymous$$agick's images.

avatar image
0

Answer by proceduralien · Nov 09, 2011 at 01:24 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image andresp · Nov 10, 2011 at 01:42 PM 0
Share

hmm it must have been something like that. the person who is responsible for the city engine work (I'm more on the Unity side) just went on holidays yesterday so we had to open the project ourselves and perform the shapes and terrain alignment. The export just worked as expected, i.e., what we see in City Engine is what we get in Unity. The only problem is now related with the way City Engine aligns the terrain. In this case I think a picture is really worth a thousand words so I took a screenshot of the issue: http://i.imgur.com/2jNs8.jpg

As you can see the problem occurs even inside City Engine. Do you know why this happens? Is there any way to fix it?

P.S.: I understand that this is now a problem only related with City Engine, for which we have a Gold Subscription, but as the discussion started here, I'm answering it here (if you want I can fill a support ticket with this question).

P.S.2: Obviously, I'm considering you work at Procedural.

avatar image
0

Answer by proceduralien · Nov 10, 2011 at 02:42 PM

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?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image andresp · Nov 10, 2011 at 03:09 PM 0
Share

How can we update to the newest version? I can't find that option in the user area

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Issue with importing raw heightmaps (made in photoshop) 5 Answers

Photoshop heightmap chunks not lining up 0 Answers

Import RAW height map not working 0 Answers

Importing Heightmaps 1 Answer

Problem with heightmap and terrain height maxing out at 10000, proportions *Solved* 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges