Jump to content

Terrain with Unity3D and Export


Dad72
 Share

Recommended Posts

Hello,

I experiment the creation of terrain with unity3d to export it to Babylon. I create mountains, textures ... and when I export, the terrain or the scenes has no mountain (no positions, no normals, uvs) and has no textures, no materials, no multiMaterials. Why ?

58a2103fab6a9_2017-02-1320_59_28-Unity5.5.1f1Personal(64bit)-Delos.unity-Teste-PCMacLinuxStandalon.thumb.jpg.5a36b9f2460e6a4a1e4ed783c9fc38a2.jpg

I may be forgetting something, but I do not see what.

Delos.babylon

Link to comment
Share on other sites

In BabylonJS Toolkit ... The Terrain Generator Component... You would use the Surface Material option to assign material to terrain. (I can't get to the textures that the unity editor is using at design time... So i was forced to use a EXTERNAL property to set the textures... hence... the Surface Material Option on Terrain Generator Component)

 

I have been working with @MrVR on the new toolkit update (trying to get all documented)... But is has been using the the Babylon.TerrainMaterial to set things up in code and just set Surface Material in editor to null...

 

I plan on going back in and looking at the TerrainMaterial extension for babylon js... Maybe i can use that instead... I haven't had a chance to really look at the TerrainMaterial.... But i think that would be a great fit...

 

And UNTIL I stick it the toolkit.... You can ALWAYS just throw a mesh component script on the terrain object in your unity editor...

 

then in start function:


var terrainMesh:BABYLON.AbstractMesh = this.scene.getMeshByName("Terrain");
terrainMesh.material = new BABYLON.TerrainMaterial(....)

BLAH BLAH BLAH

 

Link to comment
Share on other sites

Hello,

I add the Terrain Generator. I have the ground with elevations (positions, normals uvs). 
but I do not understand what painted texture. I saw the material surface, it adds all alone on the ground?  It's been a long time I did not use U3D. in my memory, you drag the material on the subject, but that does nothing on the ground. 

is all painted texture is export this way or it is not supported? 
I want to paint a lot with U3D tools and export it such that it is painted is it possible? 
 
and would be it possible that the file export or minimifier , because the weight is huge. There are a lot of useless data also in the metadata and greatly increases the weight of the file. 53 MB field against 2 MB when it is creating with Babylon (just the land with elevations). this mean that there are 51 MB of useless data no compress. Surely that Unity to create an important subdivision of the terrain.

But just a terrain with some mountain file of 53 MB, it's really a lot and very long to load in Babylon.
 
 Thank you for this exporter

Link to comment
Share on other sites

19 hours ago, Dad72 said:

Hello,

I add the Terrain Generator. I have the ground with elevations (positions, normals uvs). 
but I do not understand what painted texture. I saw the material surface, it adds all alone on the ground?  It's been a long time I did not use U3D. in my memory, you drag the material on the subject, but that does nothing on the ground. 

is all painted texture is export this way or it is not supported? 
I want to paint a lot with U3D tools and export it such that it is painted is it possible? 
 
and would be it possible that the file export or minimifier , because the weight is huge. There are a lot of useless data also in the metadata and greatly increases the weight of the file. 53 MB field against 2 MB when it is creating with Babylon (just the land with elevations). this mean that there are 51 MB of useless data no compress. Surely that Unity to create an important subdivision of the terrain.

But just a terrain with some mountain file of 53 MB, it's really a lot and very long to load in Babylon.
 
 Thank you for this exporter

The metadata is VERY necessary for the Scene Manager API..

First off... The new version support Pre-Compressed Scene Files (MyScene.babylon.gz). The design uses a HttpBabylonModule at the server level (BabylonJS/Extensions/HttpBabylonModule and the new Toolkit has this built into the Preview WebServer) to serve the pre-compressed version of a babylon scene IF IT EXISTS AND THE BROWSER SUPPORTS GZIP (Accept-Encoding contains: gzip)... So that REALLY HELPS since the babylon scene file is TEXT based... Get GREAT compression ratio.

Second... The terrain is probably that big because my first version of the toolkit (which is what you have)... I actually BASE64 Encode the HeightMap PNG that is used to CreateGroundFromHeight into the .babylon scene file... Your Terrain must be BIG ... Also it turns out that the base64 encoded representation of the height map bytes probably increase that 25-30 percent with all the base64 text encoding overhead... That was probably not a good idea... although it seemed really kool when i was writing it... and all my height maps were really small... And on top of that... I think i always encode PNG now as apposed to jpeg... Because if you look at code... we really PACK reach Color Channel with a special encoded values so we DONT loose ANY precision on the actual HEIGHTMAPS...

byte[] packed = BitConverter.GetBytes(inverted);
if (packed != null && packed.Length >= 4)
{
    pixels.Add(new Color32(packed[0], packed[1], packed[2], packed[3]));
}

So this file is probably a major contributing factor to your size problem.

My new version is coming out soon... It should really help.

Also ... Ping @MrVR he is doing some kool looking stuff with the terrains using My Toolkit :)

 

Link to comment
Share on other sites

Hi @Dad72 Exporting the terrain with all included is not possible in the current unity toolkit version; this feature is upcoming in the next version I  think.

But there are some ways of getting the terrain to work 

  1. Use the terrain Exporter to get the actual OBJ mesh with out textures then use it on the scene and add textures manually after 
    1. exportterrain.JPG.8b721ac75441bb0d923b64ee146fcee8.JPG
  2. Second you also can us the scrip BabylonTerrainGenerator component, that will generate a terrain with mountains but no textures assigned you have to chose the textures for the terrain after

 

Or generate the terrain from a mixmap

 var terrain = BABYLON.Mesh.CreateGroundFromHeightMap("terrain", "heightMap.png", 100, 100, 100, 0, 10, this.scene, false);
            var terrainMaterial = new BABYLON.TerrainMaterial("terrainMaterial", this.scene);
            terrainMaterial.mixTexture = new BABYLON.Texture("mixMap.png", this.scene);
            terrainMaterial.diffuseTexture1 = new BABYLON.Texture("grass.png", this.scene);
            terrainMaterial.diffuseTexture2 = new BABYLON.Texture("rock.png", this.scene);
            terrainMaterial.diffuseTexture3 = new BABYLON.Texture("floor.png", this.scene);

            terrainMaterial.bumpTexture1 = new BABYLON.Texture("grassn.png", this.scene);
            terrainMaterial.bumpTexture2 = new BABYLON.Texture("rockn.png", this.scene);
            terrainMaterial.bumpTexture3 = new BABYLON.Texture("floor_bump.png", this.scene);

            this.mesh.material = terrainMaterial;
        }

 

 

 

Link to comment
Share on other sites

36 minutes ago, Dad72 said:

The use of terrain material uses only 3 textures diffuse, and I wish I could use at least double (6 to 8). Which is why I use Unity's painting tools.

I am currently working on a field editor that I will soon be sharing here.

Nice let me know when you have ready or if further help need it,

there is feature @MackeyK24  is currently working on suppose, is to export the entire terrain with all its textures  but I'm not sure about the status on that.

Link to comment
Share on other sites

My terrain editor will not be with Unity. I work on an editor entirely written in JS and Babylon. But it will open sources, contributions will always be welcome.

It will allow to create mountains, rivers, smoothing, ramps, holes, paint textures in unlimited numbers, save the ground, export in a zip with terrain and texture and reload a terrain save ...

Link to comment
Share on other sites

4 hours ago, MrVR said:

Nice let me know when you have ready or if further help need it,

there is feature @MackeyK24  is currently working on suppose, is to export the entire terrain with all its textures  but I'm not sure about the status on that.

 I am still stuck with the 3 texture limit... Trying to see about packing a FORTH texture into the ALPHA channel of the splatmap 

 

But it working so beautifully (Even with 3 texture limit)... will post a video showing the terrain features shortly :)

 

Link to comment
Share on other sites

2 hours ago, MackeyK24 said:

 I am still stuck with the 3 texture limit... Trying to see about packing a FORTH texture into the ALPHA channel of the splatmap 

 

But it working so beautifully (Even with 3 texture limit)... will post a video showing the terrain features shortly :)

 

nice cant wait to see it,

I have finished putting the materials, post-process and procedural texturing classes into the toolkit with samples and scripts,

I will write some docs for these usage soon.

 

Link to comment
Share on other sites

On 2/16/2017 at 9:23 AM, Dad72 said:

My terrain editor will not be with Unity. I work on an editor entirely written in JS and Babylon. But it will open sources, contributions will always be welcome.

It will allow to create mountains, rivers, smoothing, ramps, holes, paint textures in unlimited numbers, save the ground, export in a zip with terrain and texture and reload a terrain save ...

Yo @Dad72 ... After going over the BABYLON.TerrainMaterial and studying the Unity Internal Alphamap Ecoding... I just RE-BUILT my Terrain Generator...

1... No more separate collision mesh... can now procedurally generate optimized mesh natively... No need for CreateGroundFromHeight when i can just procedurally generate the actual mesh (using resolution info from terrain material inspector... HeightmapWidth, HeightmapLength, Heightmap Resolution)... Ex: 300 x 300 x 33 yields an excellent leave space low poly BUT NICE LOOKING terrains... *IS OPTIMIZATION

2... I now handle the native Unity Splatmap generation workflow to dynamic produce up to 12 splats using up to 4 splatmaps... This give you up to 12 textures (i could make more ... bu that seems enough to me... also i don't feel like adding another set of properties and functions and handle more that 12 right now :))

3... Enforces image encoding (if not a jpeg or png will auto convert to selected image format) really helps with tag and dds types textures

4... Support scene dependencies to BREAK scenes apart into separate scene files... Characters with make bones and animations could in there own unity scene... Fully prefaced out and scripted and can be loaded at runtime using this.manager.importMeshes("MyOtherScene.babyon"); ... am also working on a scene dependency loader to auto load all required meshes from the selected number for dependent scenes...

5... Auto pre-compress scenes to make a .gz version... even dependent scenes

Will make video showing progress in creating my new BABYLON.SplatmapMaterial (that is based of the work of BABYLON.TerrainMaterial) but it will support:

1... Supports up to 4 Splatmap textures (optional meaning will not error out of you don't have all three textures: red, green, blue diffuse textures defined)... May only use the primary splat for the entire terrain... only 1 texture in the read channel of the primary splatmap texture image. This give you up to 12 painting textures to use directly in unity.

2. Auto splatmap texture configuration... Will pull the proper splatmap for the 1 of 12 diffuse text no matter which of the 4 splatmap textures if may land on depending on the Unity Terrain Editor changes that are dynamically made... Basically you don't have to do ANYTHING... all this is built in now.

3... Support self illumination ... will eventually support a useDiffuseAsIllumination just like the standard material useEmissiveAsImllumnation for Full Light Baking Support (WORK IN PROGRESS)

4... Support lightmapTexture for pre-baked lightmap shadows support (WORK IN PROGRESS)

5... Support reflectionTexture for SKYBOX Environment reflections (WORK IN PROGRESS)

Anyways check back soon for a sample video show a proof-of-concept of my new Terrain Generation system :)

@MrVR You should check out also... I got the Scene i am using to PUSH the limits of what i can do with a scene (Unity Assets In A Babylon Game... Working So Smooth So Far... Not a magic converter... But i will show how to properly use unity assets and get great frame rate and rude content payloads)

 

Link to comment
Share on other sites

47 minutes ago, MackeyK24 said:

Yo @Dad72 ... After going over the BABYLON.TerrainMaterial and studying the Unity Internal Alphamap Ecoding... I just RE-BUILT my Terrain Generator...

1... No more separate collision mesh... can now procedurally generate optimized mesh natively... No need for CreateGroundFromHeight when i can just procedurally generate the actual mesh (using resolution info from terrain material inspector... HeightmapWidth, HeightmapLength, Heightmap Resolution)... Ex: 300 x 300 x 33 yields an excellent leave space low poly BUT NICE LOOKING terrains... *IS OPTIMIZATION

2... I now handle the native Unity Splatmap generation workflow to dynamic produce up to 12 splats using up to 4 splatmaps... This give you up to 12 textures (i could make more ... bu that seems enough to me... also i don't feel like adding another set of properties and functions and handle more that 12 right now :))

3... Enforces image encoding (if not a jpeg or png will auto convert to selected image format) really helps with tag and dds types textures

4... Support scene dependencies to BREAK scenes apart into separate scene files... Characters with make bones and animations could in there own unity scene... Fully prefaced out and scripted and can be loaded at runtime using this.manager.importMeshes("MyOtherScene.babyon"); ... am also working on a scene dependency loader to auto load all required meshes from the selected number for dependent scenes...

5... Auto pre-compress scenes to make a .gz version... even dependent scenes

Will make video showing progress in creating my new BABYLON.SplatmapMaterial (that is based of the work of BABYLON.TerrainMaterial) but it will support:

1... Supports up to 4 Splatmap textures (optional meaning will not error out of you don't have all three textures: red, green, blue diffuse textures defined)... May only use the primary splat for the entire terrain... only 1 texture in the read channel of the primary splatmap texture image. This give you up to 12 painting textures to use directly in unity.

2. Auto splatmap texture configuration... Will pull the proper splatmap for the 1 of 12 diffuse text no matter which of the 4 splatmap textures if may land on depending on the Unity Terrain Editor changes that are dynamically made... Basically you don't have to do ANYTHING... all this is built in now.

3... Support self illumination ... will eventually support a useDiffuseAsIllumination just like the standard material useEmissiveAsImllumnation for Full Light Baking Support (WORK IN PROGRESS)

4... Support lightmapTexture for pre-baked lightmap shadows support (WORK IN PROGRESS)

5... Support reflectionTexture for SKYBOX Environment reflections (WORK IN PROGRESS)

Anyways check back soon for a sample video show a proof-of-concept of my new Terrain Generation system :)

@MrVR You should check out also... I got the Scene i am using to PUSH the limits of what i can do with a scene (Unity Assets In A Babylon Game... Working So Smooth So Far... Not a magic converter... But i will show how to properly use unity assets and get great frame rate and rude content payloads)

 

Nice work man.. @MackeyK24 IM working with the trackingjs I will put a post about Augmented reality Im having issues already ja ja 

Link to comment
Share on other sites

Yo @Dad72 - check out this thread http://www.html5gamedevs.com/topic/28512-new-terrain-splatmap-material/ 

Hope it will help (when new toolkit get released) :)

Until then i will PR the ne BABYLON.Splatmap material and you use it JUST LIKE BABYLON.TerrainMaterial

Except: mixTexture is now splatmapTexture 1 thru 4

and up to 12 diffuse and bump texture (3 per splatmapTexture)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...