[RELEASED]Terrain Importer

1749565--1268764--Icon.png

Purchase On The Asset Store | Current Verision: 2.5.0 | Discord Server

Support
Use Website Contact Form: https://deepspacelabs.net/html/other/contact.php
Or post here/use discord (link above)

Important

The latest version of Unity this product has been tested on is 2021.1, even though the Asset Store page says you can use it with 2018.4.26 or higher. I can only guarantee the package works with versions between 2018.4.26 and 2021.1. If you are using a version more recent than 2021.1, please email me before purchasing to confirm there are no issues!

2.4.0+ Update Note

The Gdal implementation used to expand GeoTIFF support requires .Net 4. As such, users of Unity editor version 2017.1 and above must switch their scripting runtime version to .Net 4.x (it may be called .Net 4.6 on some versions of Unity), which can be done via Edit → Project Settings → Player. If you cannot do this, please email me with your invoice number and Unity version, and I will send you a version of the package that does not include the Gdal implementation.

Support Note

To speed up the support process, please email me your invoice number for your purchase of the Terrain Importer and which version of Unity you are using (the full version, e.g. 2019.2.12f1), in addition to a detailed description of the issue, any exceptions or errors thrown, and screenshots if you feel it would better display the issue. Thanks!

Known Issues

  • When the Export To method is set to “Existing Terrain” you may get a Null Reference Exception when the “Base Terrain Settings” tab is expanded (fixed in 2.4.0)
  • Not all DEM/Geotiff files are supported, though update 2.4.0 has greatly expanded the range of supported files. However, it’s best if you email me your .tif file before purchasing the package so I can test it!
  • If you have a script outside of the TerrainImporter package that utilizes System.Threading, you’ll see an error. To rectify this I have removed the System.Threading.dll file in all versions above 2.3, though you may need to manually remove the .dll file yourself it it has already been downloaded (and you are using .Net 4.x scripting runtime version).
  • An exception is thrown when viewing the inspector for importing splatmaps. (Fixed in 2.3.1)
  • An exception is thrown when trying to import a full coverage texture (Fixed in 2.3.1)
  • You may see a Missing Script error when viewing your TerrainImporter asset on Unity 2017.1 or later versions, or you may not have the option to create a new TerrainImporter file. These versions require your projects Scripting Runtime Version (Project Settings → Player) to be set to .Net 4.x Equivalent (or .Net 4.6).

Video Previews
Single Terrain Import
Tile Set Terrain Import

This tool allows you to easily import heightmaps and splat maps into Unity and generate beautiful/spacious terrain. Though the files can come from anywhere, the tool has been tested and designed primarily with World Machine in mind. Features include:

  • Import Tile Sets of (theoretically) any size. By creating terrain prefabs out of your import files rather than generating the terrains in the scene (though both options are available, and can be used simultaneously), Unity’s 3.5 GB memory limitation can be circumvented.
  • Import one more more RGBA Splat Maps. The import settings for the splats are automatically configured prior to being applied to the generated Terrain (note, any image format that can be converted by Unity to a Texture2D should be supported).
  • Import Height Maps under a variety of supported extensions (.raw, .r16, .r32, .ter, .tif/.tiff). Additional height map extensions may be added in the future. Additionally, the tool allows for the use of custom components which can be created to add support for other formats yourself. Note that GeoTiff/DEM files are very complex and have many varieties, so proper importing cannot be guaranteed. Please email me a sample file before purchase so I can confirm it can be imported properly.
  • Scale your imported heightmap either up or down, or ditch scaling in favor of importing sub regions of your heightmap files instead. Using either of these two methods, you can make use of non power of 2 + 1 heightmaps and/or heightmaps larger than Unity can support!
  • Import Settings are stored as Scriptable Object Assets, which allows for quick and easy re-importation. You can also create a base file which stores common import settings (such as the location where you import files are loaded from on your machine), and then duplicate this file to generate new import settings that require less configuration.
  • Generate Prefabs for your terrains automatically.
  • Configure the Terrain Settings for all imported terrains. This is incredibly useful when importing tile sets (imagine having to change the Pixel Error/Detail Distance/Tree Distance/etc. for every terrain in the tile set post import!).
  • Additional script included which allows you to easily set the terrain neighbors of a group of terrain when entering Play Mode (very handy for tile sets).
  • Source code included.

Please note that this tool is primarily geared to those wishing to import/setup a large quantity of terrains, such as tile sets from World Machine. For such users, this tool will be invaluable, but for others needing to import a height map every now and again, it will be less beneficial (but still possibly worth the price tag).

Please let me know if you have any questions!

1 Like

The Terrain Importer package has been accepted and is now available on the Unity Asset Store!

There is a small error in the WorldMachineTileSettings.txt document.

Step 9 states:

This is not correct. The Terrain width/length should be left at your total world size (16km x 16km in the example), as the program will automatically calculate each individual tile’s dimensions.

maybe you should post a link to your asset in the store… :roll_eyes:

also, seriously… it’s a DLL? unless it’s like a trade secret or something I’d put the source code out there. Would have just bought it otherwise…

@p87 You’re right about the link; I’ve added it to the original post.

As for the files being in a DLL, I favor this practice because it makes it easier to change things; for instance, if I decide a class really isn’t needed at a later date (something that shouldn’t happen, but you never know), I can remove it without the user needing to know. If everything is included as individual script files and I decide to remove something, the user will have a useless file bloating their project hierarchy. In addition, I tend to have a lot of classes, each in their own file. The DLL reduces the amount of files and makes for a cleaner project hierarchy.

With that said, the DLL is definitely not meant to protect any “trade secrets.” I usually put the source in the package; I simply forgot in this instance.

I’ll update the package to include the source files in a zip. How does that sound?

Thanks for your feedback!

1 Like

Update 1.1, which includes the source code, is now available on the Asset Store!

1 Like

HI guys,

I am going to add support for importing heightmaps/alphamaps and building terrains at runtime, but before I start work on that I want to get feedback on how I’m envisioning it will work.

Basically, there will be a new scriptable object asset (let’s call it “Developer Settings”) you can create which will serve as the base settings for the runtime import. This asset will contain the same settings that the existing editor import asset contains, but each setting will have an option letting you define whether the setting should be preset or defined by the user at runtime. So something like “User Defined.” If checked, the setting is hidden in the inspector (since it will be set by the user at runtime), if unchecked the setting is shown and you set it to whatever you want.

At runtime there will be another class that also has all the settings (let’s call it “User Settings”), whose data is populated with user defined values (via a GUI). Once the actual import process is initiated, the predefined settings from the Developer Settings are used, with any “blanks” filled in by the runtime User Settings defined by the user. This design will allow you to define the level of control the user has. For example, you may only want heightmaps with a resolution of 1029 to be used, which you’d set in the developer settings.

Obviously a GUI will need to be created in order for the user to specify the User Settings; I can provide a basic default version using uGUI, but I’m not sure if I should bother since most people will probably want to create their own to fit with the GUI of their game/application. I am also thinking of bumping the prerequisite to 4.6 to make use of uGUI; does anyone have an issue with this?

One final thing. I can’t make any promises when it comes to performance, as I have no experience with importing terrain at runtime. When it comes to applying the heightmaps/alphamaps, I’m going to try to spread the work out, but I’m not sure how much of an effect it will have. More than likely, the import process will require game play to be paused.

Just wanted to let everyone know that v1.2 of this kit should be compatible with Unity 5. If you experience a bug, please let me know!

Version 1.2 has been submitted to the Asset Store. I’ll let you know when it’s available.

Changelog:

  1. Fixed a splat map import issue with Unity 5.
  2. Fixed Tiled Import Issue on all platforms.
  3. Fixed an issue where the Endianness Field would not show up correctly in certain situations.
  4. Added new guide for importing terrain and troubleshooting.

Version 1.2 is now live on the Asset Store. I’ve also posted two new videos which are available at the top of the original post in this thread, as well as on the Asset Store.

Version 1.3 is now live on the Asset Store. Here’s the change log:

  • Added new option to Dimensions/Resolution section of Base Terrain Settings that, when checked, will force the dimension/resolution settings to be treated as the settings for a single terrain when importing a tile set (rather than being treated as the settings for the entire group). This enables the importing of giant tile sets.

  • Added a “Pad Coordinate Digits” option to the Tiled Import Settings section. This should only be enabled if you have the “Pad Coordinate Digits” option enabled in World Machine when exporting your height/splat maps.

  • Added two options to the Terrain Output Settings, “Put Tiles In Standard Format” and “Bump Indexes By One.” These options allow you to output terrains whose names are compatible with my other package, the Terrain Slicing & Dynamic Loading Kit, regardless of the naming format of the import height/splat maps.

  • Fixed a bug where the Endianness option would not show up correctly when the Heightmap File Format is .r16 or .r32.

Also FYI, I still want to add run-time importing, but there doesn’t seem to be any interest. If you’re looking for this, please post on here so I know, otherwise it will stay on the back burner for good!

Hey Nice work Gilley!! If you didn’t post today I probably wouldn’t have known about this plugin.

I don’t want to offend but do yourself a favour and spend some time on presentation. First change the logo :slight_smile:

For the current project I won’t be needing this but later I will be needing to import many tiles so I think I’ll end up purchasing it.

Keep up the great work :slight_smile:

Regards
TechiTech

No offense taken, I know that logo needs to be replaced :slight_smile:

Hi Kyle, runtime import is interesting for me, do you plan an update soon?

I’ll look into what it will take, but at a guess I’m thinking it will take some work, in which case I’ll need to see more interest before proceeding. Unfortunately, I just don’t have the time to put the effort in without there really being a strong interest. Other projects are demanding my attention.

Thanks for showing an interest though!

Hi there,

I purchased Terrain Importer this morning and regardless of which tiled terrains I attempt to import from World Machine, I receive this error:

EndOfStreamException: Failed to read past end of stream.
System.IO.BinaryReader.ReadByte () (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/BinaryReader.cs:293)
TerrainImporter.Raw16HeightmapFileImporter.ImportHeightmapUsingFullFilePath (System.String fullFilePath, Int32 heightmapResolution, Endianness endianness)
TerrainImporter.HeightmapImporter.ImportHeightmap (System.String heightmapFileName, Int32 heightmapResolution, System.Action IncrementProgress)
TerrainImporter.TerrainImporter.ImportAndSetupTerrain (System.String heightmapImportName, System.String terrainExportName, System.String terrainDataExportName, System.String[ ] splatImportNames, Vector3 terrainPosition, Single maxProgressOfOperation)
TerrainImporter.TileSetImporter.Import ()
TerrainImporter.Importer.InitializeImport ()
UnityEditor.DockArea:OnGUI()

In World Machine, please make sure that the height maps are a power of two + 1 value (but keep the splatmap at a power of two value). If that’s not the issue, could you please send me your World Machine file and screenshots of your TerrainImporter asset inspector settings? Alternatively, you can export the asset as a Unity package and send that instead.

You can send those things to kgillen@deepspacelabs.net. We should be able to figure out what’s going on in no time. Thanks for your patience!

Regards,
Kyle Gillen

Hi Kyle,

Thanks for the reply. It completely slipped my mind that a tiled export in WM is only a power of 2 and I’d need to specify the +1 (ie. 2049). I’m going to give this a try and get back to you.

Thanks!

I am having a hard time with terrain importer, no matter the format I choose to import (.ter, .raw, .r16, .r32, .tif) it happens the same. I get the grilled view/bad import artifacts. You can see them in the animated gif below. After doing Single or Multi terrain import with your asset, I can manually select each terrain and use Unitys standard import option to import .r16 files and it gets fixed/properly imported. I was really happy to purchase your asset, just to save the time and avoid doing it manually, but.... Ill be really grateful for your support/assistance.
Also a feature request: If possible to use .png as an import option it`ll be great.
Thanks in advance for your help.