khronosgroup / gltf-blender-exporter Goto Github PK
View Code? Open in Web Editor NEWMoved to https://github.com/KhronosGroup/glTF-Blender-IO.
License: Apache License 2.0
Moved to https://github.com/KhronosGroup/glTF-Blender-IO.
License: Apache License 2.0
I found problem. When model have very few vertices, then exports indices as Uint8. How to force export as Uint16 or Uint32?
Bezier can be converted to Hermite curve:
https://github.com/KhronosGroup/glTF-Sample-Models/issues/96#issuecomment-315213054
Hello,
Could you please explain how should alpha settings work?
I tried to change Alpha
parameter and it led to changes rendered image in blender as I expected. However, material in exported glTF file always has 1.0 alpha in pbrMetallicRoughness
:
{
"name" : "gray-color",
"pbrMetallicRoughness" : {
"baseColorFactor" : [
0.25192031264305115,
0.25192031264305115,
0.25192031264305115,
1.0
],
"metallicFactor" : 0.04025423526763916,
"roughnessFactor" : 0.5932203531265259
}
}
Additional note: If I set alpha directly in baseColorFactor then alpha value is exported as expected. It looks confusing because baseColorFactor
alpha doesn't apply to rendered image in blender.
Hi,
I faced with incorrect normals export when mesh contains custom split normals data
:
glTF Viewer output:
The current export solution is based on the Edge Split Modifier
which splits edges according to mesh.auto_smooth_angle. But blender doesn't use smooth angle when custom split normals data
are available see blender tooltip for smooth angle input:
Maximum angle between face normals that will be considered as smooth (unused if custom split normals data are available)
So model in blender has a differences of glTF model.
I'm not sure how Edge Split Modifier
actually works if I disable Edge Angle
option but this solution works for me:
--- a/scripts/addons/io_scene_gltf2/gltf2_filter.py
+++ b/scripts/addons/io_scene_gltf2/gltf2_filter.py
@@ -98,6 +98,7 @@ def filter_apply(export_settings):
blender_modifier = current_blender_object.modifiers.new('Temporary_Auto_Smooth', 'EDGE_SPLIT')
blender_modifier.split_angle = current_blender_mesh.auto_smooth_angle
+ blender_modifier.use_edge_angle = current_blender_mesh.has_custom_normals == False
current_blender_mesh = current_blender_object.to_mesh(bpy.context.scene, True, 'PREVIEW')
temporary_meshes.append(current_blender_mesh)
Models to reproduce the issue: cylinders.zip
I opened https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/sourceModels/DamagedHelmet in Blender 2.78c then I tried to export model.
I turned on all export settings.
Actual result: There is no textures field in gltf
Expected result: There is textures field in gltf
When exporting with embedded textures of a model gave me a 55MB sized file.
When exporting and copying the textures gave a total of 7-8MB including the model itself witch alone was 500-600kbyte.
Sorry if this is not the right place for questions, but I don't see any other channel for this kind of thing.
I see that the exporter uses the KHR_materials_cmnBlinnPhong
extension for materials. However, this doesn't seem to be the same extension defined at https://github.com/KhronosGroup/glTF/tree/master/extensions/Khronos/KHR_materials_common (that name is not even found in the whole of the repository, including issues). Also, it doesn't seem to be the same extension ThreeJS implements (that one seems to be called KHR_materials_common
and it seems to match a bit what the official repository discuss in some issues)
So the question is, where is this extension defined? I'm trying to implement an exporter and viewer, but I'm finding it very difficult to support all extensions out there, as there seems to be little in the way of documentation.
Thanks in advance, and again sorry if this is not the right channel.
Hi,
the user documentation describes the nodes group you provide to model glTF 2.0 PBR materials and ensure proper export.
It also makes mention of a future compatibility with the 2.8 Eevee node, when available.
In this regard, what is the status of the existing Blender 2.79 Principled Node? It seems to provide a large set of PBR features, and, similarly to the nodes group you provide, to strive for compatibility with texture conventions of Substance Painter or game engines.
So would it be conceivable to use the Principled node to design materials exportable to glTF 2.0? (This may understandably involve forbidding the use of some of the options it provides, such as SSS.)
I reckon PBR support in Blender is evolving from ad-hoc node groups to more integrated, standardized solutions such as the Principled Node and the future Eevee one.
Today glTF2.0 export seems somewhere in the middle, with convention-based materials such as your or Sketchfab's one.
Do you feel those approaches will converge, in the 2.8 branch at least?
Regards,
Olivier.
I recently encountered a problem with the camera parameters not being exported correctly. You can try it out by setting the fov in degrees in blender and compare it to the exported radian values from the glTF file. Whereas blender has the notion of sensor sizes and resolution, glTF does not, so perhaps it would be more useful to export the actual projection matrix used by blender for the camera. Furthermore, aspectRatio should be the ratio of view area instead of ratio of horizontal and vertical angle.
Here's some code which I believe fixes the issue:
For the perspective case:
camview = blender_camera.view_frame(context.scene)
perspective['yfov'] = 2.0*math.atan2(0.5*(camview[0][1]-camview[2][1]),-0.5*(camview[0][2]+camview[2][2]))
perspective['aspectRatio'] = (camview[0][0]-camview[2][0])/(camview[0][1]-camview[2][1])
and for the orthographic case:
camview = blender_camera.view_frame(context.scene)
orthographic['xmag'] = 0.5*(camview[0][0]-camview[2][0])
orthographic['ymag'] = 0.5*(camview[0][1]-camview[2][1])
Note that glTF does not support non-symmetric cameras, that's why averaged values are being used in the code above.
Kind regards,
Nico
Please, add an option to omit zfar
for perspective cameras.
Spec issue with details: KhronosGroup/glTF#722
Hi, thanks for this awesome project.
I'm having trouble loading a model with skinned mesh and joint. The loader fails at GLTF2Loader.js:2166
for ( var i = 0, l = skinEntry.jointNames.length; i < l; i ++ ) {
where skinEntry.jointNames
is undefined.
I'm not sure if it's an issue of the loader or it is the fault of the exporter ( the model is import from maya to blender and exported using https://github.com/KhronosGroup/glTF-Blender-Exporter )
FYI, I use the demo script to display the model
<!doctype html>
<html>
<head>
<!-- polyfill for older browsers -->
<script src="https://cdnjs.com/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="https://avgp.github.io/gltf-viewer/gltf-viewer.html">
</head>
<body>
<gltf-viewer interactive src="/patrick.gltf"></gltf-viewer>
</body>
</html>
Here is a link to the model : https://github.com/shrekshao/minimal-gltf-loader/tree/patrick-model/glTFs/patrick
Related to #16 and using the same example file, I've found that depending on the frame you have selected on the editor when doing the export, your final file will look incorrect. If you select the frame 0, everything is fine. If you select the frame 60 (like I did in the example I'm attaching) your animation will look wrong (it's applying the skin to a mesh deformed from the frame you have selected, instead of the initial state)
This might even be a feature, although I'm hard pressed to find how this can work in practice ๐
BoxSkinnedBug.zip
I seem to be unable to export Shape Key Animations (Morph Targets)...
Here's blend file and the exported glb missing animation: flamingo.zip
Interestingly, if the model has multi materials, the exported glb has animation: flamingo_color.zip
https://gltf-viewer.donmccurdy.com/ seems to have issues displaying it.
Not sure if it's a exporter issue or a loader issue. The resulting glb seems a bit too big though (4.6mb).
Hello there,
First of all thanks so much for this effort, it is a life saver!
The issue: I have exported many of the examples in the repo and works like a charm, but when I open any other blender project I cannot add any of the GLTF specific nodes... It does not appear in the menu or the search, the rendering engine is selected as Cycles. Any idea why?
Compare with other exporters but e.g. OBJ does not export the data as well.
Looking at the feature chart and the code it seems that morph target animations are supported. But I can't manage to export Shape Keys (ie, morph targets in Blender) without animation. Just shape keys, without any keyframe set, and all weights at 0. I checked all options in the "Animation" group of the exporter. Maybe an "Export shapes keys" in the "Attributes" group would be needed?. Thanks!
Hello. I tried to export gltf with metallic and roughness separately (but combined by "Combine RGB"), but Blender does not export this texture. Blender have no own image processing library? Would be good ImageMagick, for example, inside of Blender.
I believe that currently the animations for objects which are parented to a curve with path animation (follow path) enabled are not being exported.
Kind regards,
Nico
I believe I found a bug relating to exporting the current action bound to an object.
In gltf2_generate.py the 'blender_action' variable at line 495 shadows the blender action variable defined at line 470
Would it be possible to export all (used) actions as separate animations?
I believe it's possible to collect all animations of an armature by collecting all references to actions from all nla_tracks by iterating over
bpy.data.objects['Armature'].animation_data.nla_tracks['...'].strips['...'].action
So perhaps export one animation which is a baked version of all nla_tracks followed by separate animations for all referenced actions so that the generated gltf file can be used by a game engine?
Kind regards,
Nico
Exporting a single standard circle Mesh to glTF creates an empy node without Mesh:
{
"asset" : {
"generator" : "Khronos Blender glTF 2.0 exporter",
"version" : "2.0"
},
"nodes" : [
{
"name" : "Circle"
}
],
"scene" : 0,
"scenes" : [
{
"name" : "Scene",
"nodes" : [
0
]
}
]
}
If exported using Collada, a "lines" mesh is created:
<library_geometries>
<geometry id="Circle-mesh" name="Circle">
...
<mesh>
<vertices id="Circle-mesh-vertices">
<input semantic="POSITION" source="#Circle-mesh-positions"/>
</vertices>
<lines count="32">
<input semantic="VERTEX" source="#Circle-mesh-vertices" offset="0"/>
<p>0 1 1 2 2 3 3 4 4 5 5...................../p>
</lines>
</mesh>
</geometry>
</library_geometries>
While working on my own graphics engine I wanted to implement gltf support. I didn't understood why my buffers were so wrong until I tried to use a viewer.
This is the original scene (.blend is downloadable)
https://sketchfab.com/models/c1b85e2e54394326bccd1a85d7f1fe75
This is how it looks when uploaded using Gltf2
https://skfb.ly/6suFA
The scene was done using blender 2.78 with the .glb mode (but I get the same result with .gltf embeded) using the attached settings.
Note: most of the scenes I tried to export have problems but this is the most "spectacular" one.
If you need more scenes I can upload you more.
Note: There is no animations, textures or even hierarchy. This is just meshes, math only materials and compositing.
Did I do something wrong or this exporter isn't production ready and I should use collada2gltf ?
PS: I also get python error if I try to export animations.
Hi,
Is it possible to export mesh with a few smoothing groups?
I've created simple scene in blender with sphere and made half of sphere with sharp edges (Edit Mode: Mesh โฃ Edges โฃ Mark Sharp). You can see more information in blender docs. See rendered example bellow:
Then I've exported glTF file with default settings and got next renderer image via glTF Extension for Visual Studio Code. Sharp edges are absent:
JFYI: I've also tied to export the scene as Collada:
It looks as expected.Another useful feature could be to export object's Custom Properties metadata. This could be stored in the node.extras glTF2 field.
(Sorry for keep asking stuff, I just don't see this in the readme features table, and maybe is something you didn't think of)
This Issue has been separated from KhronosGroup/glTF-Sample-Models#83 (comment)
I also tried Blender 2.78c and glTF 2.0 Explorter.
First I tried to display EmaSimpleSkin.dae on Blender.
Next, I tried to display the glTF 2.0 file exported from Blender in Three.js.
Three.js + glTF 2.0 model result:
I think that models including skinning animation have not been converted correctly.
Hi
I just export the 04_common_materials.blend
file into gltf but when i've tried to open it with threejs webgl_loader_gltf2.html
example i could not see any material at all, it just a gray model! (In webgl_loader_gltf2.html
i just edited the model url to load.)
So do you have any idea?
Thanks.
As a dev on the original blendergltf project, I'm looking forward to contributing to this! I hope the work happens in public so I can keep an eye on it, and help with issues/testing/dev. Is this under development yet?
These images have no filepath, so a unique name has to be created.
what's the status of KHR_technique_webgl extension support?
I need to export the Techniques, programs, and shaders with glTF 2.0 exporter.
When I try to export the provided test scenes (e.g. 03_all_animations.blend
), it fails and I get the following error:
Traceback (most recent call last):
File "/Applications/blender.app/Contents/Resources/2.78/scripts/addons/io_scene_gltf2/__init__.py", line 276, in execute
return gltf2_export.save(self, context, export_settings)
File "/Applications/blender.app/Contents/Resources/2.78/scripts/addons/io_scene_gltf2/gltf2_export.py", line 82, in save
generate_glTF(operator, context, export_settings, glTF)
File "/Applications/blender.app/Contents/Resources/2.78/scripts/addons/io_scene_gltf2/gltf2_generate.py", line 2330, in generate_glTF
generate_meshes(operator, context, export_settings, glTF)
File "/Applications/blender.app/Contents/Resources/2.78/scripts/addons/io_scene_gltf2/gltf2_generate.py", line 848, in generate_meshes
internal_primitives = extract_primitives(glTF, blender_mesh, filtered_vertex_groups[name], export_settings)
File "/Applications/blender.app/Contents/Resources/2.78/scripts/addons/io_scene_gltf2/gltf2_extract.py", line 361, in extract_primitives
blender_mesh.calc_tangents()
RuntimeError: Error: Tangent space computation needs an UVMap, "(null)" not found, aborting
location: <unknown location>:-1
The addon was added by copying the io_scene_gltf2
folder into the /Applications/blender.app/Contents/Resources/2.78/scripts/addons/
directory.
When I export the default Blender scene (cube, light, camera) to glb, with the default settings, the GLTF2Loader in Three.js finds an unexpected token in the JSON data (and thus fails to parse).
Of course the error could be on either side -- export or loader. Would you know of any tool I could use to validate the glb?
Hi, I'm cross-filing this from an issue opened on three.js by @densetsughem.
Original issue: mrdoob/three.js#11460 (comment)
There are two skinned models, and with default settings (for either model) export gives this error:
(not sure how to copy/paste the text from Blender, sorry...)
If I un-check skinning before exporting, the export succeeds. In the resulting .gltf
, a material is present (I selected the "Phong" common material under experimental) but the material is not referenced by any nodes.
I understand this is still a work-in-progress of course, but hopefully these examples are helpful. :)
With the attached file, I'm getting the following error:
I might have done something wrong in Blender, as I'm still a beginner, but I guess the plugin should not explode no matter what :D
While converting https://github.com/dataarts/3-dreams-of-black models to glTF I noticed that the exporter seems to be producing over sized files when using sub-materials.
alligator.zip gltf file is 2.8MB
alligator_subm.zip gltf file is 11.4MB
Just want to double-check that this is correct.
Will the KHR_materials_common extension be supported when using Blender Render ?
As soon as the exporter is enabled, the material node groups should be linked and enabled as well.
Evaluate, if this can somehow be realized, as at a later point of time, the node group is integrated in Blender.
I have a scene containing two cameras, pasted__camera1
and pasted__camera2
, and I deleted the default camera. After exporting, my glTF contains three cameras:
"cameras" : [
{
"name" : "Camera",
"perspective" : {
"aspectRatio" : 1.703595982340029,
"yfov" : 0.5033799409866333,
"zfar" : 100.0,
"znear" : 0.10000000149011612
},
"type" : "perspective"
},
{
"name" : "pasted__camera1",
"orthographic" : {
"xmag" : 0.30000001192092896,
"ymag" : 0.30000001192092896,
"zfar" : 100.0,
"znear" : 0.0010000000474974513
},
"type" : "orthographic"
},
{
"name" : "pasted__camera2",
"perspective" : {
"aspectRatio" : 1.0,
"yfov" : 0.6606064438819885,
"zfar" : 100.0,
"znear" : 0.0010000000474974513
},
"type" : "perspective"
}
]
The first is unexpected โ perhaps the active camera from the editor, even though it's not technically the scene?
When I exported an asset into the GLB format, it appeared significantly darker and redder. Exporting the same asset into the GLTF format did not have this issue. In both cases I had visualized the output in Unity using this importer: https://github.com/AltspaceVR/UnityGLTF
In Unity, I selected the texture that was being rendered to clarify that it was definitely the texture not the material that was the issue. The texture itself had the darker, orange tint. Here is an image of the expected correct output next to the mistaken output.
Looking through the code, it appears the problem is in the create_png_data function in the gltf2_create function. The pixel values are read directly from the image into the png data blob. I believe the problem with this is Blender internally stores image pixels in a different color space than PNG. I think PNG is sRGB and Blender is Linear. So I believe the pixels are in the wrong color space as they are added under the PNG header, and then they get misinterpreted by the Unity loader. Blender doc on color management for reference https://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
I tried a simple conversion from gamma to linear by changing line 289 to include a pow function to 0.45 as below
buf = bytearray([int(pow(channel, 0.45) * 255.0) for channel in blender_image.pixels])
And that seemed to make the output GLB work in the correct format.
For a model I've imported from FBX, the resulting GLTF file contains 6 skins (which seem to be an exact copy of one another) where only 2 of them are used. Also, it seems that the armature node has as its children 2 nodes pointing to the same mesh, which if I understand the process correctly, will render the mesh twice.
I've attached screenshots of the Blender tree and a representation of the GLTF using a tool I'm developing, which (hopefully) should be readable enough. I can share the Blender file if required (as I understand that screenshots might obviously not be enough to debug this) but I need to do so privately, as the model is not free nor owned by me.
EDIT (pressed send too quickly after attaching): As you can see, there are two nodes ending in .001
not present in the Blender tree below. Those two nodes are pointing to the same meshes to their non-001 counterparts (meshes[0]
and meshes[1]
, respectively) but only the non-001 ones contain a pointer to the skin.
I am trying to test out creating animated objects in Blender and exporting them to GLTF to use in WebVR scenes, but I am having two problems with the export. I created a simple spinning cube by adding an animation to the default cube and setting up a simple colored material. When I export this to GLTF and try to load it into a Three.js test web-page, the cube does not have its material applied and does not spin. If I add another object to the scene (say a plane), the cube will spin but is still not textured. When I examine the GLTF files, I see animation tags in both cases... but I do not see material tags in either case.
I do not know if I am setting things up wrong in Blender, the export, or if my JavaScript is wrong. I am attaching the GLTF and Blender files for both cases as well as the HTML file for the test harness.
Currently I have an issue where exporting using the GLTF Metal Roughness PBR together with Mapping nodes: - the Mapping node scaling and rotation will be ignored:
The reason why this is a problem: my project doesn't use textures which are all the same size and rotation which seems to be an underlying assumption in the export.
Not sure if this is by design, if so, are there any workflow workarounds?
I took the HOUSE model from Blend Source (https://www.blendswap.com/blends/view/15091) to try out the exporter. I opened it in the latest release of Blender (V2.78c) with the export code downloaded and installed yesterday (2017-07-20). I exported the model to a binary glTF format and loaded it in Don McCurdy's glTF viewer (https://gltf-viewer.donmccurdy.com/).
The results are not the same.
Geometry
Appearance:
The text-based glTF file does not display at all in the viewer. I also exported in X3D and used BitManagement's BS Contact viewer. That model & display shows the same geometry issues, but is closer to Blender in appearance.
I am not sure if the problem is the exporter or the glTF2 loader (or even something else), but this seemed the best place to start. I am not really Blender-knowledgeable so the problem may be in something I didn't do or am looking at it incorrectly.
I'm fumbling my way through Blender here, so hopefully this isn't a silly mistake, but it doesn't seem to be possible to do UE4-style packed occlusion/roughness/metallic textures. I've tried two approaches:
Here, I bring in two duplicate Image Textures and use one for Occlusion, the other for MetallicRoughness. The exporter throws an error in this case.
If I really duplicate the texture (make a copy of the image file, not just two nodes referencing the same image, then this works as expected, but with duplicate resources of course.
I separate channels and re-combine green/blue for roughness/metallic. The export is successful, but both occlusion and roughness/metallic are omitted from the glTF.
^I wired occlusion to the wrong pin here, but you get the idea.. ๐
Source files:
It took some digging to figure out that vertex colors are only exported if the color channel is named COLOR_0
, COLOR_1
, etc. This should be documented, but since there is currently no documentation, I don't know how to file the PR. Any comments on this?
the addon is greyed and cant be enabled
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.