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 Sk8rseth · Nov 20, 2013 at 02:03 AM · terrainheightmap

Terrain flipped, then texture doesnt line up?

im exporting a terrain from world machine as a 16bit raw. along with a texture. when import the heightmap into unity, its mirrored. from what ive read i cant find out why. so thats my first question; why is it flipped? its not when i use it in mudbox or blender. why unity?

second is, if i go into photoshop and flip the heightmap around so its correct with my texture, the texture in unity then no longer lines up properly with the terrain. how can i manually adjust the texture in one direction, so it lines up with the heightmap again?

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 supernat · Nov 20, 2013 at 05:21 AM 0
Share

I had a similar issue, pretty sure I just flipped the texture vertically, if you mean the color map.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by tanoshimi · Nov 20, 2013 at 09:33 AM

The "raw" format in which Unity imports heightmap data is just a stream of binary values - it's not really a recognised file format. As such, there are no particular conventions about whether the first value (0,0) is at the top-left corner or the bottom-right corner, or whether the values are listed in row-wise or column-wise order, for example.

Depending on the conventions of the application used to output the raw heightmap file, you may therefore find that you need to flip, mirror, or rotate the heightmap to get it to appear the same in Unity. I don't know World Machine but, when recently importing DEM data via GDAL, I found that I had to rotate the image 90' clockwise, which I did in a script as follows:

 using UnityEngine;
 using System.Collections;
  
 public class RotateTerrain : MonoBehaviour {
      
     void Start () {
          
         Terrain terrain = GetComponent<Terrain>();
          
         // Get a reference to the terrain
         TerrainData terrainData = terrain.terrainData;
          
         // Populate an array with current height data
         float[,] orgHeightData = terrainData.GetHeights(0,0,terrainData.heightmapWidth, terrainData.heightmapHeight);
  
         // Initialise a new array of same size to hold rotated data
           float[,] mirroredHeightData = new float[terrainData.heightmapWidth, terrainData.heightmapHeight];
          
         for (int y = 0; y < terrainData.heightmapHeight; y++)
         {
             for (int x = 0; x < terrainData.heightmapWidth; x++)
                 {
  
                 // Rotate each element clockwise
                 mirroredHeightData[y,x] = orgHeightData[terrainData.heightmapHeight - y - 1, x];
             }
         }
          
         // Finally assign the new heightmap to the terrainData:
         terrainData.SetHeights(0, 0, mirroredHeightData);
     }
 }


I wrote up more details on the whole process in a blog article here:

http://alastaira.wordpress.com/2013/11/12/importing-dem-terrain-heightmaps-for-unity-using-gdal/

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 johanols · Feb 02, 2014 at 10:22 PM 0
Share

Great script. I used it to flip my raw height maps produced with World $$anonymous$$achine. Worked like a charm. Thanks!

avatar image
0

Answer by TorQueMoD · Jan 28, 2016 at 10:31 AM

All you have to do is add a "Flipper" device in world machine immediately before the heightmap output and then double click on it and check off flip vertically. When you rebuild and re-import it will fix the problem.

Comment
Add comment · 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

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

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Randomized terrain? 0 Answers

Smoothing Terrain after setting its Heightmap in a script 0 Answers

How to use Height Maps 2 Answers

Edit Terrain Script 0 Answers

Stitching grid of terrains together 1 Answer


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