Export terrain + skybox from Unity

Hi all. I’m trying to export a terrain + skybox using the Babylon exporter (v4.0.0). Came across this thread: Unity 3d exporter missing terrain - but didn’t want to get in the middle of all that so as not to ping everyone. Just wondering what the upshot is - couldn’t decode from the thread. Sounds like it may work??

I’ve got a very simple skybox with terrain, which shows up blank from the exporter. No skybox and no terrain.

This might be a good question for @MackeyK24.

Took a few hours, but was able to rebuild in Babylon with skybox, fog, and terrain. Think it looks pretty identical (Unity on left / Bablyon on right). Cool! (but bummer that the export didn’t work, of course… unless i’m doing it wrong??)

2 Likes

@MackeyK24 is definitely the right man here :slight_smile:

This one can be tough if you don’t know all the stuff involved with terrains and custom shaders

First … you gotta create the terrain mesh from a heightmap image… you will always loose a bit of precision encoding heights into an RGB/PNG

Now the tough part, the shader to handle all the layers… you gotta decide between using separate textures per layer… you can check out the TerrainMaterial for how to mix colors

If you wanna use texture atlas for your layers, that’s a whole new can of worms :bug:

I listed some of my Babylon Toolkit Pro Shader SDK code snippet I use to handle texture atlas… the magic is the bilinear sample texture atlas function I created… is much simpler and only use about a dozen arithmetic computations per sample read… is really fast… I believe I posted a few images you can do with the upcoming Babylon Toolkit Pro Shader SDK… If you using the totally free version… your gonna have to write all that yourself

Looks like the color space is off a little… In my shaders, you gotta POW each color channel the proper color correction… Ether 2.2 or 1 / 2.2

Also… Here is some of the shader code i use for sampling texture atlas:

1 Like

Thanks! I got read up on shaders and then get into your code there. Appreciate it.

Oh, the color difference is just the fog btw.