Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blender export fails for multiple materials #6731

Closed
flow-c opened this issue Jun 23, 2015 · 12 comments
Closed

Blender export fails for multiple materials #6731

flow-c opened this issue Jun 23, 2015 · 12 comments

Comments

@flow-c
Copy link

flow-c commented Jun 23, 2015

FILES:

This folder contains two blender projects, their respective THREE.js JSON exports, a texture file and this document:

  • 1-material_ok.blend --> 1-material_ok.json
  • 2-materials_nok.blend --> 2-materials_nok.json
  • dice.jpg
  • README.txt

DESCRIPTION:

  • 1-material_ok.blend defines a cube with a single material and a simple UV texture map.
    ==> As expected, the exported .json file contains six quad faces in the format [43, v0,v1,v2,v3, m, u0,u1,u2,u3, n0,n1,n2,n3], hence 14 entries per face.
  • 2-materials_nok.blend defines an additional material and UV texture map for one of the cube's faces.
    ==> Now, there are 18 entries per face in the exported .json file, and according to the metadata property it contains 17 faces. If imported with the THREE.JSONLoader, 2-materials_nok.json doesn't cause an error but it is displayed with the first material only.

USED VERSIONS:

  • Blender v2.74
  • JSON exporter v1.4.0 (r71)
@dimecho
Copy link

dimecho commented Jun 25, 2015

I ran into this problem too, you have to split your meshes - one material per mesh.

@repsac
Copy link
Contributor

repsac commented Jun 25, 2015

In three the second UV layer is reserved for light maps

@WestLangley
Copy link
Collaborator

In three the second UV layer is reserved for light maps

...and aoMaps.

@flow-c
Copy link
Author

flow-c commented Jun 25, 2015

Thanks, I wasn't aware of that convention.

It seems that only one mesh can be exported at a time, so I'll have to load the different parts of my model into THREE.js separately and somehow group them back together there. Or is there a better way?

@repsac
Copy link
Contributor

repsac commented Jun 25, 2015

It seems that only one mesh can be exported at a time,

For geometry exports this is true. Have you tried the Scene option (and use ObjectLoader instead)?

@dimecho
Copy link

dimecho commented Jun 25, 2015

With ObjectLoader you can have many meshes in one file, but only one material per mesh. This is true for three.js v71 and v72. Since they started improving it with BufferedGeometry they broke multi-material per mesh. I believe v69 this was working with old blender exporter using JsonLoader.

@flow-c
Copy link
Author

flow-c commented Jun 26, 2015

Thanks, @Poofik and @repsac! THREE.ObjectLoader did the trick!

@repsac
Copy link
Contributor

repsac commented Jun 26, 2015

Also; if you are only utilizing one material per mesh/object, and doing scene exports, to possibly use these material settings

  • Shading:
    Face Materials = False

SCENE:
Materials = True

The reason is that if both are checked then you will get a material entry for the object and a material entry for the geometry. There may be cases, especially with AO or light maps, in which have face materials makes sense. But, at least in my experience, if there is a single material affecting all faces then just having object based material assignments have worked just fine.

Now there may be some work flow or corner case where object material assignments don't work, as I can only speak for the use cases that I have been exposed to. But that is probably a discussion to be had on Stack Overflow

@repsac repsac closed this as completed Jun 26, 2015
@erno
Copy link

erno commented Nov 12, 2015

Does this work now for Blender objects with multiple materials, or was this closed more in the vein of "won't fix"?

@manthrax
Copy link
Contributor

Multiple materials on a single mesh doesn't seem to be supported for any case that I can create in Blender.

Is there a plan for addressing this, or must we work around this by doing single material per mesh?

https://www.reddit.com/r/threejs/comments/5kejle/importing_a_model_from_blender_materials_not/

@dimecho
Copy link

dimecho commented Dec 26, 2016

Yes someone fixed it for Blender exporter, but it was not merged into main repo.

#8087

@wilson0x4d
Copy link

this is also why you shouldn't mark development work "done" until it's merged and tested in a release, best to leave it open, tag it so we know where the "fix" is at instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants