Kupoman / blendergltf

A glTF exporter for Blender
Apache License 2.0
319 stars 49 forks source link

Strange preview of glTF exported files in Win10 explorer #111

Closed fracteed closed 7 years ago

fracteed commented 7 years ago

The current version of Windows 10 can display glTF and obj files natively in Windows expolorer, which is one of the very few useful features that have been added recently. I have no problems previewing obj files from Blender as well as the official glTF files from Khronos.

For some reason the exported files from blendergltf look garbled. Maybe it is rendering the polys in the reverse order (clockwise vs anticlockwise?) since the vertices look correct. The following images show the same mesh exported from Blender as an obj (on the left) and glTF on the right. This file loads fine into Godot, and I have noticed this same issue from all files from blendergltf. Any ideas?

gltf_win10

Kupoman commented 7 years ago

I do not have a current version of Windows 10. Could you try exporting the model again with the Interleave Vertex Data option disabled?

fracteed commented 7 years ago

@Kupoman thanks, it worked after disabling that option. Is there any disadvantage to having that option disabled?

Also, had questions about the buffer data options in the exporter. I noticed that the name of the binary file stays the same as "buffer_combined.bin" so it seems that I need to put each gltf export into its own folder or the previous one gets overwritten. Strangely enough if I delete the .bin file Windows explorer can still preview the mesh, but Godot cannot import it. I would imagine that this binary file is required, so not sure how Windows is still accepting it?

Then I tried disabling combine buffer data and enabling embed buffer data which is what I would prefer since it is just one file. Godot had no problem importing it, but Windows explorer did not recognise it. Also tried disabling both buffer options, yet I still got a separate binary file, though it had a different name this time "buffer_Cube.bin"

Can you give me some idea of the requirements of these buffer options. Are the 2 options mutually exclusive and can the option be turned off, or is there always a requirement for a binary file, unlike an obj file that is purely a text file?

Kupoman commented 7 years ago

The mesh exporter was originally written with interleaved vertex data since this was, at least at one point in time, considered good practice. Since some glTF consumers can't handle the interleaved vertex data, the option was added to use a vertex layout similar to what the sample files use. You should be fine leaving this option disabled. Enabling it might give you a small performance improvement in vertex processing, but that usually is not even a bottleneck in most rendering systems.

The overwriting of the combined buffer file is being tracked by issue #64. The .bin file contains the glTF buffer data, and is required if the buffers are not embedded into the .gltf file. Windows is probably caching the data from the .bin file if you are able to still preview the file without it.

Embedding the buffer data into the gltf file and combining all buffers into a single buffer are two orthogonal options. The glTF format stores meshes and animation data into binary buffers, and it is sometimes useful to combine all of these buffers into one buffer. These buffers can be stored inside the .gltf file, or in a separate .bin file. This allows for four different ways of storing the binary data:

  1. Multiple buffers embedded into the .gltf file
  2. All buffers combined into one and embedded into the .gltf file
  3. Multiple buffers stored in their own .bin files
  4. All buffers combined into one .bin file

All four of those combinations should be valid, and any glTF consumer should be able to handle them if it is spec compliant.

fracteed commented 7 years ago

@Kupoman thanks for your detailed reply! This is very helpful.

Kupoman commented 7 years ago

Since this looks like a bug with the Windows viewer, I am closing this issue. Feel free to reopen it if you feel there is a blendergltf issue.