CesiumGS / obj2gltf

Convert OBJ assets to glTF
Apache License 2.0
1.69k stars 302 forks source link

Implement feature to export geometry only #32

Closed webprofusion-chrisc closed 7 years ago

webprofusion-chrisc commented 7 years ago

Currently when I use this tool to convert a .obj (geometry only export from Rhino3D) it introduces default materials and shaders. I'm assuming it does this so that the model will show up in a simple glTF viewer. I'm using glTF as a model format and then applying materials and shader (in three.js) programatically.

Could we/should we have an option to export a .gltf with only geometry/nodes/meshes (discarding shaders and materials)?

pjcozzi commented 7 years ago

Could be a reasonable option here as it is probably straightforward. It could also be a nice contribution to gltf-pipeline so that all exporters/converters could benefit.

lilleyse commented 7 years ago

Yeah this shouldn't be too hard to do, even if it means processing the whole glTF and then just deleting the unneeded sections. For the gltf-pipeline we will need to make sure not to oct-encode or quantize if a flag like this is set.

webprofusion-chrisc commented 7 years ago

You likely already know that materials etc are "required" in the glTF spec, I wonder then if the option needs a warning that the generated glTF will not be standards compliant? Maybe, maybe not.

pjcozzi commented 7 years ago

@webprofusion-chrisc the material could be stripped down to the minimal required, https://github.com/KhronosGroup/glTF/tree/master/specification#appendix-a. Would that work for your use case?

webprofusion-chrisc commented 7 years ago

@pjcozzi hmm, that sounds a lot like what already happens when converting a geometry only .obj? A minimal material is a good start but I'm guessing we would save about 5Kb on .gltf with no defined materials/shaders. As an aside, as I mentioned earlier I'm using three.js GLTFLoader. The inspiration for discarding the materials is that overriding those materials currently doesn't work for me, because there's an issue somewhere with supplying your own texture, I haven't figured that out yet.

pjcozzi commented 7 years ago

I can't speak to the three.js implementation, but the spec allows material.technique to be undefined meaning that the technique and shaders do not need to be included. Sorry, I was not suggesting adding the entire default technique; I mean that it is implicit when not defined.

lilleyse commented 7 years ago

Partially fixed by #49

With --bypassPipeline no techniques or shaders are generated. A material is still generated and this is required by the gltf 1.0 spec, but that will change in 2.0.