ARGB 4 Channel Output for Unity?

Any hope of getting 4 channel output fit for use in the Unity terrain engine? It looks like a lot of people have put time into processing RGB WM output into RGBA (Clamping such that all channels add up to 1) but with limited success.

Hi there,

I’d be happy to try to implement something. I have not used Unity myself, so I would need a precise specification of what exactly you need out of your 4 channel maps.

Improving workflow (and thus making World Machine more useful) for all of the various apps people connect to is a high priority improvement item for me, so if you (or anyone else reading this) has other relatively easy to implement ideas do please shout!

Note: The format does appear to be ARGB32. I just spent an hour hurting my brain because of a misplaced variable.

The images are a little mind bending to look at because Alpha is simply being used as another color (which makes a mess when it’s used as alpha again in a normal image viewer). I believe the four channels must always sum to 1.

I’ve attached a sample. If you load the image into say Gimp and go Colors>Levels, select the Alpha channel, and and turn its output level all the way up, you will see most of what’s really happening. (Red is text1, Green text2, blue text3, alpha text4)

I could give you a project with my not-so-great interface to import and export textures. Unity is of course free. I can’t believe no one else has ever just asked to get this support? There’s a lot of people trying to use the tool.

Just so you are aware, The terrain system supports more than 4 splat textures, upon adding a 5th texture, another map-texture is created and you can lay down another 4 splats. interfering areas of the new map have All-zero (0,0,0,0) pixels. That is, the 2nd map will have all 0 pixles except what’s drawn on it, the 1st map will have its pixels modified accordingly to account for additions to the second - the sum of a particular pixel on both maps (now on all 8 channels) must still be exactly 1. I’m not sure if there is a hard coded limit on splat count or just a practical one. I’ve never tried more than 12 splats (3 maps).

Thanks for the additional info!

So in essence the main restriction that makes things hard right now is the fact that the unity splatmaps must be normalized at each texel location so the channels grouped together sum to one, correct?

If so, an additional “Normalize Device” would do the trick – that would take any number of inputs, and output them adjusted such that that restriction is true. Then you would just take your texture masks (created like here: http://forum.world-machine.com/index.php?topic=2073.0) and route them through this device en-route to the RGBA bitmap output.

I didn’t notice a way to set color output to Alpha… but it’s really the first time I’ve used WM. I’ll check out the sample on the other Thread, thanks.

Yep, the bitmap output takes an additional alpha input for RGBA formats.

I just wanted to further followup, as I believe that support for splat maps in all their forms (including Unity’s sum-to-1 restriction) is very important.

I had a bit of a hackathon a few days ago to create the device I outlined earlier in this thread. I have been experimenting and testing and I believe it is ready for public consumption, so it is quite likely I will slip it into 2.3 RC3 and then the final release as well.

The only remaining issue is what to call it :stuck_out_tongue:

In essence, this new device takes any number of masks and outputs them modified to obey the sum-to-one constraint. However, the interesting bit is how you modify them when they sum to >1.0. This device includes a variety of prioritization modes that produces some extremely interesting effects. For example, you can prioritize the layer with the largest value, or the layer that would contribute the most visual variety to the scene, or go with a simple averaging among all layers. In addition, you can force exclusion to various extents (full exclusion meaning that each point has a value of 1.0 in one layer and 0.0 in all the rest), which suppresses unwanted blending (does it really make sense to have a large swath of land that is a blurry combo of rock and grass?), and also means that you could then reduce the set of outputs into a single map and use it as a material index map/texture atlas if that is how your engine works instead.

Even though it was intended for mask purposes, it also actually is very interesting when applied to terrain values as well!

In any case, I will include it in RC3 out later today, which is also a notable release as it fixes the last of the serious bugs that have been discovered and also adds the last of the slotted features for 2.3.

edit: I am going to exclude this device from RC3… there are a couple last things being experimented with in it that I’d like to play with before releasing this device. I will make it available shortly though as an experimental ability.

Cheers!

Pretty neat, if I weren’t behind on my mortgage payment I’d buy today… I’m getting to a point where I’m going to want to add some terrain soon.

Are you handling the production of subsequent (>4 texture) maps as well? Probably would be worth putting the results on the Unity forum show-case if you haven’t already. I’m pretty sure you’ll get some sales out of it.

Hi,

Yes, the proper summing behavior is maintained across all channels – just set the number of mask channels you want in the splat converter device.

As an aside, the Splat Conv is included in the basic edition which is now updated to 2.3, so even without purchasing you can get started using this new device.

I would definitely like to engage the Unity community more, I will try to check in there – if you get a chance feel free to help spread the word for me as well :slight_smile:

Does anyone have any samples or know of any good end to end tutorial’s for Unity?

I have imported WM height maps with no problems, but now i want to make them look gorgeous. Being a noob to WM (i just purchased the other day) some of those graphs start to get horribly complex and its a bit overwhelming.

Ideally I would like to use WM to generate the terrains, and then use my own textures rather than a colourmap and apply them procedurally based on the erosion and other features created by WM.

Cheers,
Adam.

Hi Adam,

Welcome!

The graph networks can definitely sometimes get very complex – there are a few tools available to help with this right away. The first one that I try to use is Groups – grouping together logically-connected devices makes it much easier for your brain to remember and discover what’s going on. You can create groups by either selecting devices, right clicking one of them, and selecting “Group devices”, or by going to the Tools tab of the toolbar and using the Grouping Tool to draw a group. (Ctrl-G is a shortcut for the latter).

The other way is to use Macros to completely hide parts of your graphs. This is the logical extension of grouping – you’re saying “I don’t want to even see these devices, I only care about what goes in and comes out”. Creating flexible macros is beyond the scope of this reply, but one thing you can experiment with is selecting parts of your terrain network that you’re happy with and aren’t changing often, right click and select “Convert devices to macro”. Then assign a name to it (rclick-set name or ctrl dblclick), and you just made alot of the complexity and visual busyness go away. You can always “get at” whats inside the macro again if you need to.

Finally, with regards to Unity:

Funny I’m actually just finishing writing a workflow tutorial for Unity! Tthe toughest part is actually inside Unity itself as there is no standard way to replace splatmaps and many people are doing their own terrain texture shading, etc. I ended up slightly modifying a script that someone else wrote for copying the splatmap into the terrain object in Unity – I will try to get this workflow posted soon in the learning section.

In terms of World Machine : open up the new example file: File->Open Examples->“New Examples for WM 2.3”->“Techniques”->“Splatmap Converter.tmd”.

It’s an example world showing how to create a splatmap for Unity. It’s pretty well organized and documented so you can trace through the groups and see how things work. Note that the entire “Visualization Group” is basically just a splatmap shader (that would run inside Unity) replicated in World Machine graph-speak, and using solid colors instead of textures. All you strictly need is the terrain and splatmap outputs and then a way to get the splatmap from an imported RGBA file transformed into Unity’s terrain system.

Thanks Stephen,

I will have a play. Congrats on your 2.3 release as well. Its awesome :slight_smile:

Very much looking forward to your tutorial on Unity as well! It seems to me that there is an opportunity to create an editor plugin for Unity and I am sure that the community would pay for it in order to get the goodness that WM has to give. I certainly would.

FYI, I chose Unity over the other engines because it has a free version to learn on with a lower learning curve, has a large and robust community, and is able to cost effectively deliver the same application to a broad range of platforms. I run my own technology company so this stuff is a fun release for me.

Cheers,
Adam.

Adam,

The workflow tutorial is now available here.

It covers all the essential steps of getting a splatmap into Unity and includes the splat replacer script I mentioned earlier. There are lots of other valid workflows but this should get folks started!

looks gorgeous

Thanks!!

Gidday,

I tried this using Unity 4.1.2 (Indie) and it crashes Unity as soon as you try to save it after applying the textures.

On reading the Unity forums there seem to lots of issues with crashes from 4.1 onwards, so am reverting my Unity back to 4.0.1.

Will provide an update on how it performs in the older version on Unity later.

Cheers,
Adam.

hmm. I will upgrade my version of Unity and check it out.

Gidday,

Finally! I reverted back to 4.0.1 and no crashes :slight_smile:

Heres a couple of screen shots. I used Terrain Edge (free) to place the detail in the scene.

Here is a video : https://www.youtube.com/watch?v=6LLH6Nn-EtA

And you can play the world at http://www.btek.com.au/static/sunset/

A word of warning - dont wander off the edge of the world :slight_smile:

Cheers,
Adam.

Cool stuff Adam. I like your world there. If its OK with you I might link to what you’ve produced as an example from the workflow page?

I can’t cause Unity to crash after the import script on 4.1.2f1. The script isn’t doing anything complex – its just copying the contents of one texture to another – but I admittedly have limited knowledge of Unity.

Hi Stephen,

Happy for you to link back to it.

One of the challenges learning all this stuff is that there is often ‘generic discussion’ and rarely any specifics.

The downside of the unity world I created is that I am using paid assets for the trees and flowers. I am still experimenting with the techniques so if you want I will build it out a little more into something more tutorial oriented that a learner can download using freely available assets. That way they can go end to end from tmd file to unity project file.

I am now researching lighting and other effects like fog/haze as this is essential to getting a good result.

Cheers,
Adam.