ARGB 4 Channel Output for Unity?

Hi Guys,

Heres another version of the same underlying world. Its made using assets that are freely available in Unity, and there are two scenes. Scene 1 has no tree’s etc. Scene 2 has freely available trees and grass that have been placed using Terrain Edge.

Theres a video at http://www.youtube.com/watch?v=ePcnYXTW9XU

You can view it in your browser at: http://www.btek.com.au/static/wmdaytime/

And you can download the Unity project from http://www.btek.com.au/static/wmdaytime/WMTutorial.zip

I have attached the World Machine tmd that i used to generate the world to this post.

Cheers,
Adam.

Pretty neat - I wish I had something cool to show people but I’m still working on it. I bought the standard version but I expect I’m going to need tiling before too long.

Two things:

Is it me or is 8-bit BMP currently not exporting Alpha in WorldMachine? I can export a PNG and save it as a BMP in GIMP but the same device outputing a BMP seems to be dropping the Alpha channel.

Has anyone else noticed an issue with Unity’s Terrain Resolution Dialogue and 4097px maps? I’m not sure if this is a technical limitation or just a bug but the Unity engine is in disagreement with its own interface. It attempts to snap heightmap resolutions to the count (not the highest index, e.g., 2049 instead of 2048) but then complains resolutions above 4096x4096 are not supported. Unfortunately anything near 4097 appears to be resized to 4097 and that is the number that appears in the Terrain > Set Resolution window which means you can no longer make changes via this window as they are rejected.

…I submitted a bug report but it’s pretty annoying.

Hi there,

Bitmap 8bit alpha export works fine for me – Export a bmp with alpha from WM and it opens fine in photoshop with the alpha channel intact.

Weird, I’m using 2.3.1 Standard. I’m just using the blank Splatmap converter example. The preview shows the alpha but when I open Bitmap output it in GIMP or Photopshop there is no Alpha Channel. PNG works fine with no wiring changes. I’ve attached my copy of the .tmd if you wanted to glance at it. I feel like it worked on the build I had before but I have two machines on this version and both seem to do the same thing.

Huh. I re-installed a fresh copy of 2.3.1 Standard and opened that file, built it, and exported the bitmap.

Opening the bitmap in photoshop and going to the Channels list clearly shows the alpha channel.

Note that photoshop seems to make a decision whereby png gets imported as an alpha-masked layer, but bmp and tiff formats import as 4-channel images without alpha cutout (but they still have their alpha channel, just select it in the channels dialog)

Yeah I don’t care for the way Photoshop handles Alpha for the purposes of splat-maps. GIMP simply grays out the Alpha channel when I go to Colors>Levels>Channel. If I write to 8bit PNG from WM, open it in GIMP, and export to ARGB, that bmp will have the alpha intact. I’ll keep looking, for now I have a relatively painless work-around.

Well, in case anyone else runs into this, I found that Unity simply cannot import the Bitmap V5 header used by current versions of GIMP (The bug report has been open since 2011). Dropping PNGs into unity will also give you issues with Alpha. The path of least resistance appears to be .tiff - I can go straight from WM to Unity with the tiff output.

I’m still fighting import issues so I thought I would ask since other people have done it… after you import your splatmap (EDIT set larger than 512x512), can you still save and or edit the terrain splat map? Just changing a texture causes an exception for me once I’ve imported. The import works fine and the terrain looks good. Everything works fine (except for the base map) until I either attempt to change the splat map (or a texture) or save the scene.

EDIT:
After another few hours of experimentation I’ve found that 512x512 maps work great, even the basemap works. Moving up to 1024px causes the basemap to start breaking up (it is interspersed with blank lines) and a scene-save or editing the splat map will cause a crash ( except for editing red, that just gives an error: "*footer == 0xFD )

I had Unity crash and thought it was a new version that I had updated to.

It turned out that I was trying to replace spatmaps with different resolutions. Make sure that the exported bitmap is the same resolution as the Splatmap alpha attached to your scene.

Interestingly, with 512 in the majority of the settings on my terrain it looks great and feels roomy. Smaller numbers translate into higher frame rates.

Here are a couple of versions of a 512 x 512 terrain with a 513 height map resolution and 512 control and detail resolutions.

Nice looking scenes. You might be right, although the code I’m using attempts to resize the splatmap before applying the new one but I’ll play with it anyway.

The trouble with lower resolution maps is that the area I’m working on is in 5km chunks and I don’t have enough ground-cover to get away with a terribly low resolution splat map. 2.5ish m/px would probably work but at the moment anything over 512px does not work.

Do you have working code to import detail maps yet?

Thanks :slight_smile:

There a cheap tool called Toms Terrain Tools which comes with source, and I think I saw some code in there to apply details based on images. Here’s a link: http://projects.lemuria.org/projects/ttt/wiki

My current challenge is the AI. How can you have a world with 200 AI’s, plus thousands of items they can interact with, and still maintain a frame rate good enough to show the environment off to best effect.

Don’t suppose you know any good nearest neighbours implementations?

Yeah I’ve seen his set around, I gather it has some issues but now that WorldMachine is doing the heavy lifting I imagine I should just grab it. But I’m being stubborn.

As far as your AI issue – and I have no idea what your game mechanics are but – what if you build a small spawn system based on where the player is. Despawn AIs once they are out of the interest area (Interest area should be larger than visible area), chance to spawn a target number of AIs total or and/or target number of types for the given terrain type would be easy. Spawn them just on the edge of the visible area so they can wander into the scene - or unceremoniously despawn if the player goes the opposite direction.

Have each AI measure whether it’s in the interest area, use sqrMagnitude plus the maxDistance^2 (there’s no reason to run the square root for this), Or, if you will have hundreds in the scene, you could pretty easily register the AIs in your spawn manager and only check distance from the player (and any other stuff that doesn’t need to happen every frame) for one AI per frame. Register the Manager with the AI as well so it can trigger a despawn event and remove itself from the manager.

You’ll either have to cram behaviors into one class or use Interfaces if you go the managed route.

Thanks for your thoughts.

I was actually just writing an email to my partner in the game (a psycho therapist), and describing that exact ‘if you can’t see it, then it doesn’t need to happen’ strategy.

I am using the pool manager by http://www.path-o-logical.com/. So this would be pretty easy to do.

Be curious as to how it impacts performance - should be massive.

Indeed, I was running into the same issue. Athough the Texture itself is being resized by the script, it is up to the user to set terrainData.alphamapResolution. Oops.