Jump to content

Blender exporter needlessly dividing meshes


jdurrant
 Share

Recommended Posts

I have a Blender test scene with two objects. One is a complex "tube," and the other is a high-resolution test cube.

1.png.0c37855514adc61bbd1a49d422f01b69.png

Both have UVs. The test cube has 58,984 verts, and the tube has 62,808 verts. So both come in under the ~65,500 limit for exporting as a single mesh.

When I export using the Babylon.js ver 5.2.1 exporter, the test cube is exported as a single mesh, but the tube is divided into multiple meshes. The log file suggests there are far more tube verts that Blender reports:

Exporter version: 5.2.1, Blender version: 2.78 (sub 0)
========= Conversion from Blender to Babylon.js =========
	Scene settings used:
		selected layers only:  false
		flat shading entire scene:  false
		inline textures:  false
		texture directory:  /Users/jdurrant/Documents/Work/durrant_git/protein-vr/webapp/scenes/influenza/
	Python World class constructor completed
	processing begun of mesh:  Cube
		processing begun of Standard material:  Material
		num positions      :  63245
		num normals        :  63245
		num uvs            :  126490
		num uvs2           :  0
		num colors         :  0
		num indices        :  353892
	processing begun of mesh:  NA_patch_single_tube
		processing begun of Standard material:  Material.003
		num positions      :  65534
		num normals        :  65534
		num uvs            :  131068
		num uvs2           :  0
		num colors         :  0
		num indices        :  107769
	WARNING: The following mesh has exceeded the maximum # of vertex elements & will be broken into multiple Babylon meshes: NA_patch_single_tube
	processing begun of mesh:  NA_patch_single_tube1
		registered as also a user of material:  Material.003
		num positions      :  65535
		num normals        :  65535
		num uvs            :  131070
		num uvs2           :  0
		num colors         :  0
		num indices        :  107043
	processing begun of mesh:  NA_patch_single_tube2
		registered as also a user of material:  Material.003
		num positions      :  65533
		num normals        :  65533
		num uvs            :  131066
		num uvs2           :  0
		num colors         :  0
		num indices        :  125214
	processing begun of mesh:  NA_patch_single_tube3
		registered as also a user of material:  Material.003
		num positions      :  21593
		num normals        :  21593
		num uvs            :  43186
		num uvs2           :  0
		num colors         :  0
		num indices        :  29625
	processing begun of camera (FreeCamera):  cmra
========= Writing of scene file started =========
========= Writing of scene file completed =========
========= end of processing =========
elapsed time:  0 min, 16.3766 secs

When I view the scene in the browser, it ends up looking checkered (perhaps related):

2.thumb.png.7b060f0da42e654d73492cc7e995d513.png

 

Thanks so much for your help!

 

Link to comment
Share on other sites

Thanks for your help, guys. So re. the vertex count, I'm guessing it's because of the mesh's complexity. Different UV coordinates had to be assigned to the same vertices. What a mess!

1.thumb.png.2d9e518cd3ca8baf84d2ae9c3e050a5c.png

Do you agree that that's the culprit, then?

Re. the material, it is the standard material with an ambient texture. Here's the gist:

var mat = new BABYLON.StandardMaterial("some_name", scene);
mat.diffuseColor = new BABYLON.Color3(0, 0, 0);  // to make shadeless
mat.emissiveColor = new BABYLON.Color3({some_val}, {some_val}, {some_val});
mat.specularColor = new BABYLON.Color3({some_val}, {some_val}, {some_val});
mat.ambientTexture = new BABYLON.Texture("shadow.png", scene);
mesh.material = mat;

When I use the texture in Blender, it looks great:

2.thumb.png.3a0b5e048d4c5dfb1c32902d05905fc3.png

Thanks! Great community you've got here.

Link to comment
Share on other sites

Hi all. I was able to resolve this problem by unwrapping the mesh manually (marking seams, etc.). I also divided the mesh into four separate meshes, which may have contributed to the solution. I'm still not certain why it happened on the other version of the mesh, though. For what it's worth, with the new manual unwrapping the mesh did not have to be divided on export. I suspect that's where the problem lies.

With low-res shadow map:

1.thumb.png.f0fc9fbb1bf7f2fe9f9af17046d74cbb.png

Link to comment
Share on other sites

Looks like some kind of folded protein.  I think to truly isolate the problem to the mesh division, you would actually need to export the mesh without any material at all.  In any case, I am adding an option to turn off the mesh splitting feature.  That's right it is a feature to allow very large meshes to run on old WebGL implementations.

This just made it on the very end of the Source Code Exporter, Tower of Babel, 5.3 release being finalized today. Making the JSON exporter is largely a file diff exercise I do using Netbeans.  Here is the TOB UI with the switch.

vertexLimitUI.jpg.1b9800d5d88fd99b89f382e46d57e1de.jpg

FYI, if a mesh requiring more than 64k vertices contains multi-materials or shapekeys, it will be exported as a single mesh regardless.

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...