Open Arlorean opened 6 years ago
There's some discussion of thumbnails in this thread, although I think having this separate issue for the question is better.
My own preference would be what @CentaurMare describes, where the glTF file itself does not contain the thumbnail.
In Windows, the explorer shell looks up the registry for the file type and if present calls the mapped DLL via the IThumbnailProvider interface - it would be this DLL (which someone needs to write) that creates the thumbnail so that the Windows Explorer can update its thumbnail cache. This means tweaking a value (such as a colour) directly in the glTF file will cause its thumbnail to be regenerated, which is what we want.
Similarly, MacOS can generate thumbnails and full 3D previews without changes to the file spec; it does this for OBJ already.
In any case, .glb
is not a zip format, but can (and often does) contain image files regardless. Adding a thumbnail via extension or .extras
property would be easy to do within the existing specification. My vote would be to leave it ad-hoc, though, rather than try to make thumbnails part of the specification and increase the size of files that are intended to be runtime-focused. Previews and thumbnails can come via plugins to the OS and eventually native OS support.
Thanks for the link to the other discussion and for the quick reply.
I agree, I'd rather not see the thumbnail in the .gltf file itself, but I would be keen to see it as an optional external reference, like textures.
The .glb looks so close to the .zip format that I wondered if we could just use .zip format to make it easier to use existing tool-chains to create, view and extract/replace content files. This is similar to the way Microsoft have setup Office file formats .pptx, .docx, etc. as .zip files (with thumbnails), and also their .3mf file format. Zip file entries can be stored uncompressed so they can be processed just as quickly as they can from a .glb as well. For the same reason you chose the JSON standard for the manifest format, I would have chosen ZIP for the package format, standards and tooling reuse.
Explorer shell extensions can be used to create thumbnails on the fly (I've done it myself for Voxel Files) but it can take some time to create these thumbnails and lower end machines may struggle with larger assets. Extracting a small thumbnail from a .zip is very fast and doesn't require any extra libraries that aren't already on most machines.
My vote would be to leave it ad-hoc, though, rather than try to make thumbnails part of the specification and increase the size of files that are intended to be runtime-focused
This is the best argument for not doing it I agree.
However, the downloads from Sketchfab are often >10Mb per asset and a small thumbnail would only add a few Kb to that file. Plus, it can still be optional if the file is only ever used at runtime. Deleting the thumbnail can be done using 7-zip or a similar tool.
IMHO even a 1-2KB thumbnail is very useful. For example I couldn't get the OSX Quick View plugin working (maybe because I'm still using 10.9?). And it's much simpler to write a plugin to extract a simple thumbnail then to extract, parse and render the mesh.
So I'm in favor of having a thumbnail in the glb file. The simplest solution would actually be by adding a new (3rd) chunk to the glb. In that case the thumbnail could be extract with ~20 lines of code, without using any json parsing.
The simplest solution would actually be by adding a new (3rd) chunk to the glb. In that case the thumbnail could be extract with ~20 lines of code, without using any json parsing.
That seems like the most practical solution to me too, although I'm still keen on the .zip idea as you can probably tell. :)
The .zip idea is nice for re-use of existing tooling, but, some engines ingesting GLB don't want the legacy of zip. There are a number of efforts underway now to add compression, but these are GPU compression (Draco mesh, Basis textures) not CPU compression (zip). The difference is, the asset could remain compressed on the GPU (or be transpiled to local-compatible GPU compression) while it is in runtime use, which zip can't do. Zip only helps the network, not the GPU.
Just for the record: mesh data stays uncompressed on the GPU (i.e. Draco is CPU-compression). Nevertheless, domain-specific compression routines are usually more efficient than general-purpose approaches, so we expect glTF to have standardized texture and geometry codecs at some point. Applying ZIP on top of that likely won't provide much value.
(And, at least in the domain of WebVR, browser transmission is of course nearly invariably gzipped anyway, so another layer of unsolicited compression is actually unwelcome.)
For OS support (e.g. seeing a thumbnail on your desktop), I think thumbnails must be handled by the OS long-term, and we shouldn't try to shortcut that by adding things to the file. We really want the OS to show a 3D preview as MacOS does for OBJ and COLLADA, not a thumbnail.
For other use cases like APIs, I would refer to the new Poly API. It defines metadata like thumbnails through a higher-level abstraction as described here: https://developers.google.com/poly/reference/api/rest/v1/assets#Asset. I would encourage other APIs and web-based projects to do the same.
The question of ZIP compression is separate, and wouldn't be needed for thumbnails anyway. As others have explained, I think current .glb
and upcoming compression techniques like Draco will be most efficient for runtime needs.
EDIT: Also note there are tools in progress now for easily zipping and un-zipping .glb
assets, if convenience is a concern there.
Also note there are tools in progress now for easily zipping and un-zipping .glb assets
The one that was originally contributed to the VSCode extension has since been broken out into an npm package:
It's interesting to note that the new Apple/Pixar format USDZ is a .zip package without compression. I still think that's a great way to store gltf content. I haven't seen a reference to a USDZ thumbnail yet but if anyone does I'd love to know about it and I'll bet it's a PNG/JPG in the ZIP.
I'm happy for this issue to be closed if there's no sign of consensus on adding thumbnail support BTW.
Looking at a .3mf (.zip) file, the thumbnail is embedded within the file. This allows the thumbnail provider to simply read the file and quickly extract the image. This can't be done with a glTF file, as it could take some time for a large model to load and render, and we can't guarantee that an exporter will create a thumbnail. I'm considering building a Windows thumbnail provider for .gltf and .glb files which will read the thumbnail, not from the file itself, but from an NTFS Additional Data Stream, e.g. myModel.glb:thumbnail Then have an indexing type of service that scans for and generates thumbnails from the glTF files on the system and writes them into the thumbnail stream. Advantages: The thumbnail isn't part of the file, it is not sent across the network, saving bandwidth. The thumbnail is moved with the file if the file is relocated on disk. Disadvantages: The thumbnail is lost if copied to a FAT32 device such as a USB. A thumbnail would not be generated if the file was read-only.
The issue I'm facing at the moment is that my glTF viewer requires a window to render into (It is written in C# with OpenTK). I can then save the render as an image, but it still brings up the Window. Does anyone have a glTF viewer capable of rendering to an image file, or know how to suppress the window creation with OpenTK?
Or can someone chime in with a better plan for thumbnails?
CentaurMare wrote:
or know how to suppress the window creation with OpenTK?
There is no need displaying the window - if you keep it hidden it should work OK - see comments on this thread (though make sure you are using FBO for image dump to avoid undefined behavior): https://github.com/opentk/opentk/issues/459
From another side, I would say that using OpenGL might be not very good idea on Windows for making thumbnails. I'm not familiar with Windows thumbnail provider logic, but would expect it to be performed preferably in background, when user is inactive, and in this context OpenGL-based application might observe issues with no hardware-accelerated OpenGL driver being available.
Another issue is that glTF file might be really huge, and there are no tricks similar to many image formats to be loaded only partially (fitting in desired memory limits), so that this process should consider somehow how to make screenshots without slowing down foreground system processes / making system unstable.
I tried the hidden window approach, but the window was first created visible, then hidden. I could render in GDI+ using only material colours - so ignore textures. That would be much slower to create the render than using OpenGL but it would work as a background service, and if it was a background service with a FileSystemWatcher it could chug away in the background unobtrusively and create thumbnails as needed. I might give that a go and see how the thumbnails look, but I know already they wont look as good as the OpenGL approach. But at least it represents the model.
I've got the IThumbnailProvider handler working, it simply loads the thumbnail from the ":thumbnail" stream attached to the file. It uses the IInitializeWithFile interface to get the filename, appends ":thumbnail" and reads in the image data (PNG or JPG).
@gkv311
I would say that using OpenGL might be not very good idea on Windows for making thumbnails
So I went with your suggestion, and it works nicely!
My thumbnail generator is a C# application.
I'm rendering by z-sorting each triangle and drawing using Graphics.FillPolygon, using the material colour and calculating incoming light based on the normal. I imagined it would be horribly slow to render, but it turns out to be fairly quick.
I'm rendering to a 4096 x 4096 bitmap and then resampling to 1024 x 1024, then saving the bitmap as a PNG into the ":thumbnail" alternate data stream on the file.
The C++ Thumbnail Provider simply reads from that stream to present the thumbnail to Windows Explorer (which downsizes appropriately)
Some things I need to resolve:
Thumbnail generation My Thumbnail generator will need to run as a service. To resolve synchronization issues, the ideal would be to have the thumbnail provider signal the thumbnail generator service that it needs a thumbnail on a file, which is then generated and returned to the thumbnail provider. That way there is no need for an intermediate ":thumbnail" stream, and Windows can handle storage of the thumbnail in Thumbs.db
Graphics I will need to calculate the normals if they are not provided. For textured models, I have no clue how to render the texture. I could sample a pixel from the texture and use that as the material colour if all else fails. It also ideally needs Gouraud shading, but I don't know how to do this. I need to use a Perspective Transform. I won't bother with all the other graphics features that an OpenGL fragment shader can provide.
Success! (mostly)
I attempted to use PathGradientBrush to do Gouraud shading, but it seems there is a memory leak in Microsoft's implementation and it quickly ran out of memory. So the resulting image is somewhat faceted, but otherwise it represents the model.
I'm sampling the texture at each point in the model, and using an average colour for the face. It works if the model is high polygon.
I've added the emissive material factor, but metallic-roughness will need to be left out.
I'm no longer using the :thumbnail stream, instead the thumbnail provider (C++) requests the image from the thumbnail service (C#) via named pipes. So updating the glTF file will mean the thumbnail gets regenerated as expected.
Prerequisites: .NET Framework 4.7.2 (Probably 4.x will work) Requires 64-bit Windows, I'm assuming no one is using an ancient PC for graphics work.
I'm not supporting Draco Mesh Compression, but otherwise let me know if a model thumbnail won't view and I will take a look at why.
Fixes
Calculate Normals if not present (this was causing the thumbnail provider service to crash) Exception Handling Gouraud shading implementation Back-face culling Fixed issue with UV texture coordinates Gamma Correction (SRGB to linear and linear to SRGB)
Installation Instructions
Extract the zip file contents into the folder "C:\Program Files\glTF Thumbnail Provider" Run (as Administrator) the install.cmd
How it works
glTFThumbnailProviderService is registered as a Windows Service. glTFThumbnailProvider is registered as a thumbnail provider for Windows Explorer, and Explorer calls it when a thumbnail is required. The provider then passes the filename of the .gltf or .glb to the thumbnail provider service (via a named pipe), which generates and returns the thumbnail image.
Download glTFThumbnailProvider.zip
I'd love to hear feedback, so please let me know how it goes, and let me know if there is any issue displaying a thumbnail for a model (note: Draco Mesh compressed glTF thumbnails will not be generated).
What's going wrong???????????????????????
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT.glb\shellex{125056E5-A8A3-41F8-A5F8-B834ABDEEFD9}] @="{6F6A251D-E800-4870-B088-87FA9B42F685}"
[HKEY_CLASSES_ROOT.gltf\shellex{125056E5-A8A3-41F8-A5F8-B834ABDEEFD9}] @="{6F6A251D-E800-4870-B088-87FA9B42F685}"
[HKEY_CLASSES_ROOT\glTFThumbnailProvider] @="glTFThumbnailProvider"
[HKEY_CLASSES_ROOT\glTFThumbnailProvider\CLSID] @="{6F6A251D-E800-4870-B088-87FA9B42F685}"
[HKEY_CLASSES_ROOT\WOW6432Node\CLSID{6F6A251D-E800-4870-B088-87FA9B42F685}] @="glTFThumbnailProvider" "DisplayName"="glTF Thumbnail Provider" "AppID"="{AF6BF7B1-6567-4D3F-A0FA-D938C7D85A8A}" "AllowEdit"=dword:00000000 "DisableLowILProcessIsolation"=dword:00000001
[HKEY_CLASSES_ROOT\WOW6432Node\CLSID{6F6A251D-E800-4870-B088-87FA9B42F685}\Implemented Categories{E073B408-1A6A-4B0A-BF49-2A47FEE7939E}]
[HKEY_CLASSES_ROOT\WOW6432Node\CLSID{6F6A251D-E800-4870-B088-87FA9B42F685}\InprocServer32] @="mscoree.dll" "ThreadingModel"="Both" "Class"="glTFThumbnailProvider" "Assembly"="glTFThumbnailProvider, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null" "RuntimeVersion"="v4.0.30319" "CodeBase"="file:///c:/program files/glTF Thumbnail Provider/glTFThumbnailProvider.dll"
[HKEY_CLASSES_ROOT\WOW6432Node\CLSID{6F6A251D-E800-4870-B088-87FA9B42F685}\InprocServer32\1.5.0.0] "Class"="glTFThumbnailProvider" "Assembly"="glTFThumbnailProvider, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null" "RuntimeVersion"="v4.0.30319" "CodeBase"="file:///c:/program files/glTF Thumbnail Provider/glTFThumbnailProvider.dll"
[HKEY_CLASSES_ROOT\WOW6432Node\CLSID{6F6A251D-E800-4870-B088-87FA9B42F685}\ProgId] @="glTFThumbnailProvider"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers] "{6F6A251D-E800-4870-B088-87FA9B42F685}"="glTF Thumbnail Provider"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\glTFThumbnailProvider] @="glTFThumbnailProvider"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\glTFThumbnailProvider\CLSID] @="{6F6A251D-E800-4870-B088-87FA9B42F685}"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID{6F6A251D-E800-4870-B088-87FA9B42F685}] @="glTFThumbnailProvider" "AllowEdit"=dword:00000000 "AppID"="{AF6BF7B1-6567-4D3F-A0FA-D938C7D85A8A}" "DisableLowILProcessIsolation"=dword:00000001 "DisplayName"="glTF Thumbnail Provider"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID{6F6A251D-E800-4870-B088-87FA9B42F685}\Implemented Categories]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID{6F6A251D-E800-4870-B088-87FA9B42F685}\Implemented Categories{E073B408-1A6A-4B0A-BF49-2A47FEE7939E}]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID{6F6A251D-E800-4870-B088-87FA9B42F685}\InprocServer32] @="mscoree.dll" "Assembly"="glTFThumbnailProvider, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null" "Class"="glTFThumbnailProvider" "CodeBase"="file:///c:/program files/glTF Thumbnail Provider/glTFThumbnailProvider.dll" "RuntimeVersion"="v4.0.30319" "ThreadingModel"="Both"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID{6F6A251D-E800-4870-B088-87FA9B42F685}\InprocServer32\1.5.0.0] "Assembly"="glTFThumbnailProvider, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null" "Class"="glTFThumbnailProvider" "CodeBase"="file:///c:/program files/glTF Thumbnail Provider/glTFThumbnailProvider.dll" "RuntimeVersion"="v4.0.30319"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID{6F6A251D-E800-4870-B088-87FA9B42F685}\ProgId] @="glTFThumbnailProvider"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\4BEB160A044200649A098D1938ABC7CD] "62A625FC464230000000209E05916B82"="Cc:\program files\glTF Thumbnail Provider\glTFThumbnailProvider.dll"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\4BEB160A144200649A098D1938ABC7CD] "62A625FC464230000000209E05916B82"="c:\program files\glTF Thumbnail Provider\glTFThumbnailProvider.dll"
@ErwinMeulman
Hi Erwin,
Some things look very weird... "Cc:\program files\glTF Thumbnail Provider\glTFThumbnailProvider.dll" Should start with "C:\ not "Cc:\
and "file:///c:/program files/glTF Thumbnail Provider/glTFThumbnailProvider.dll" is not a windows path.
You are installing on Windows, right?
So, step one, make sure you are logged in as an administrator, as we are installing a windows service. Step two, ensure .net framework 4.x is installed
On a command prompt, type the following... cd %windir%\Microsoft.NET\FrameWork dir
you should see a directory called v4.0.30319
The service is actually targetted for .net framework 4.7.2, so if you don't have that installed, download it from microsoft.
Check the contents of "c:\program files\glTF Thumbnail Provider", it has to be unzipped there, not anywhere else. It should contain at least the following files.
Centauri.Model.Gltf.dll Centauri.Model.Gltf.Interface.dll Centauri.Model.Gltf.Load.dll Centauri.Model.Gltf.Load.Json.dll Centauri.Model.Gltf.Thumbnail.dll Centauri.Model.Gltf.Utilities.dll glTFThumbnailProvider.dll glTFThumbnailProviderService.exe install.cmd OpenTK.dll uninstall.cmd
Then, on the command prompt, navigate to cd "c:\program files\gltf thumbnail provider" install
What is the output from running install?
I wan't to register the glTFThumbnailProvider.dll, so I can preview it in Outlook. But the register I copied is for a c# dll and the glTFThumbnailProvider is a c++, als I don't now the AppId. Is the register for glTFThumbnailProvider the same or do I need a other way?
This is that I wan't
@ErwinMeulman
Hi Erwin,
The thumbnail provider only provides thumbnails (icons) for Windows Explorer, it can't display an interactive model that you can rotate etc from within outlook. I do have a separate application to load and display a .glTF model, but it is standalone and not embedded within another application such as outlook.
I might investigate what is required for outlook, but no promises :)
Great job with the thumbnail viewer @CentaurMare. Very impressive. It's a shame there isn't a reference renderer that could be used as a separate process that we could call out to to render these thumbnails. Maybe there is?
I just noticed that Kenney.nl has released GLTF versions of his free assets. They provide some very simple models that highlight issues with missing (or likely reversed) faces that aren't being rendered currently in the thumbnails.
Try out Kenney's Weapon Pack to see the issues. Here are the assets on SketchFab and here they are in Windows File Explorer as thumbnails:
It's a shame there isn't a reference renderer that could be used as a separate process that we could call out to to render these thumbnails. Maybe there is?
There is one in development, although to be clear it is really meant as a "reference", and for efficiently generating hundreds of thumbnails you may have better luck with a made-for-production renderer. ThreeJS and Filament can be used via CLI (and probably BabylonJS?). There are other options, too, but I haven't used many of them myself.
@Arlorean,
I am unable to download the weapons pack as individual glb files, did you import the wavefront .obj files into an application and then export to .glb? If you are able to upload an individual .glb, I will be able to determine if my thumbnail generator is at fault - you may have installed the earlier version? A triangle will not be drawn if it is facing away from the viewer and its material is not double-sided. This is intended as some models use this to great effect, such as for drawing black outlines around a model.
It's a shame there isn't a reference renderer that could be used as a separate process that we could call out to to render these thumbnails. Maybe there is?
Funny thing is, that is exactly how my thumbnail generator works - it passes the name of the .gltf or .glb file via a named-pipe message to the thumbnail generator running as a windows service, which loads and generates the image, and then sends the resulting .png image data back to the thumbnail provider. (The thumbnail provider is a C++ application, and the renderer is a C# application)
I also have a glTF viewer which renders beautifully using OpenGL shaders (it even does the animations), and I had originally intended to use that as the renderer because it can render with PBR materials etc - but the issue I was running into is that the OpenTK library doesn't allow me to render in the background, it was designed for renderering into a window.
Anyway, I'm really pleased to hear that someone finds the thumbnail generator useful! I didn't know if anyone was using it at all. So thanks for the feedback!
I didn't know if anyone was using it at all. So thanks for the feedback!
It is definitely useful. Thanks for doing it. I did try it when you first announced it but didn't get around to replying to you. Sorry about that. Do you have a link to the latest version I can try out?
Github doesn't let me upload a .glb file individually so I've zipped them up and attached them here. Kenney's assets are all low poly, generally without textures, so they should be a simple test case: GLTF format.zip
Here's the rockerlauncher.glb file in Windows 10 3D Viewer:
Here's the generated thumbnail:
[cid:3e3b95bd-46d7-4201-aad7-17ea0067c063]
I've reattached the latest version, stop the glTF Thumbnail Provider service first from the control panel, unzip into c:\program files\glTF Thumbnail Provider and then restart the service. The visual artifacts that are visible on the ammo are caused by the z-sort of the facets before drawing, this won't be an easy fix without a z-buffer, so I might need to have a go at writing my own triangle-drawing routine with z-buffer - visually it would look better but then it would also be slower. Unless I can get OpenTK running without a window.
From: Adam Davidson notifications@github.com Sent: Saturday, 23 February 2019 11:44 PM To: KhronosGroup/glTF Cc: Natty; Mention Subject: Re: [KhronosGroup/glTF] Optional thumbnail image inside .glb file (#1167)
I didn't know if anyone was using it at all. So thanks for the feedback!
It is definitely useful. Thanks for doing it. I did try it when you first announced it but didn't get around to replying to you. Sorry about that. Do you have a link to the latest version I can try out?
Github doesn't let me upload a .glb file individually so I've zipped them up and attached them here. Kenney's assets are all low poly, generally without textures, so they should be a simple test case: GLTF format.ziphttps://github.com/KhronosGroup/glTF/files/2896795/GLTF.format.zip
Here's the rockerlauncher.glb file in Windows 10 3D Viewer: [image]https://user-images.githubusercontent.com/1547800/53286532-2053cc80-3768-11e9-9f31-46fc07263383.png
Here's the generated thumbnail: [image]https://user-images.githubusercontent.com/1547800/53286536-395c7d80-3768-11e9-9e92-b3275a846498.png
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/KhronosGroup/glTF/issues/1167#issuecomment-466645456, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Ac0djiwlaHTpRcgseJ-b66do9Rt5Eak1ks5vQTeYgaJpZM4QvRdj.
Try this one... (Stop the service, copy over the existing files, restart the service), or if first time installation, extract into "C:\program files\glTF Thumbnail Provider" and run the install command.
I've managed to implement a windowless OpenTK session (using very basic OpenGL triangles at the moment), but at least it gives me a z-buffer. It is considerably faster, and removes a lot of artifacts caused by the Windows GDI implementation.
Let me know how it goes!
From: Natty W Sent: Tuesday, 26 February 2019 6:11 AM To: KhronosGroup/glTF; KhronosGroup/glTF Cc: Mention Subject: Re: [KhronosGroup/glTF] Optional thumbnail image inside .glb file (#1167)
[cid:3e3b95bd-46d7-4201-aad7-17ea0067c063]
I've reattached the latest version, stop the glTF Thumbnail Provider service first from the control panel, unzip into c:\program files\glTF Thumbnail Provider and then restart the service. The visual artifacts that are visible on the ammo are caused by the z-sort of the facets before drawing, this won't be an easy fix without a z-buffer, so I might need to have a go at writing my own triangle-drawing routine with z-buffer - visually it would look better but then it would also be slower. Unless I can get OpenTK running without a window.
From: Adam Davidson notifications@github.com Sent: Saturday, 23 February 2019 11:44 PM To: KhronosGroup/glTF Cc: Natty; Mention Subject: Re: [KhronosGroup/glTF] Optional thumbnail image inside .glb file (#1167)
I didn't know if anyone was using it at all. So thanks for the feedback!
It is definitely useful. Thanks for doing it. I did try it when you first announced it but didn't get around to replying to you. Sorry about that. Do you have a link to the latest version I can try out?
Github doesn't let me upload a .glb file individually so I've zipped them up and attached them here. Kenney's assets are all low poly, generally without textures, so they should be a simple test case: GLTF format.ziphttps://github.com/KhronosGroup/glTF/files/2896795/GLTF.format.zip
Here's the rockerlauncher.glb file in Windows 10 3D Viewer: [image]https://user-images.githubusercontent.com/1547800/53286532-2053cc80-3768-11e9-9f31-46fc07263383.png
Here's the generated thumbnail: [image]https://user-images.githubusercontent.com/1547800/53286536-395c7d80-3768-11e9-9e92-b3275a846498.png
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/KhronosGroup/glTF/issues/1167#issuecomment-466645456, or mute the threadhttps://github.com/notifications/unsubscribe-auth/Ac0djiwlaHTpRcgseJ-b66do9Rt5Eak1ks5vQTeYgaJpZM4QvRdj.
@CentaurMare I've been trying to write a thumbnail service too, also by using SharpShell, but I fould a roadblock: It seems the Shell API to use is SharpThumbnailHandler and implement IInitializeWithStream.... but this API only allows opening the main file.
With self contained GLB files, this is fine, but with glTF files that also have .BIN and textures, there's no way to reference them... so how did you overcome this problem?
Should we close off this issue now? I'd still like the option for a thumbnail but I can see that adding a custom extension to the Windows File Explorer is a viable alternative. Thanks for being open to discuss this.
@Arlorean Unfortunately, using windows file explorer to add thumbnails is not a viable solution.
Windows provides an API for a service to generate thumbnails for a given file. Originally, the API allowed for both file paths and streams to be used to generate the thumbnails.
But in windows 10, the API that uses file paths has been locked for security reasons. The API still exists, but it fails if you try to use it.
This means that you're limited to use the API that gives you just a sanitized stream. The consequence is that you cannot resolve any file dependency, like loading the textures or the BIN blobs of a glTF file. At best you can generate thumbnails of stand alone GLB files.
@CentaurMare successfully achieved generating thumbnails thanks to extensive hacking skills, but I don't think it's the right approach for any safe thumbnail generation service.
So, unless Microsoft provides an alternative API that allows resolving file dependencies, right now it's extremely difficult to generate the thumbnails.
Furthermore: even if an extension to hold a thumbnail is implemented, the thumbnail content needs to be located in the root file... so in case of glTF text files, the thumbnail should be located within the json in embedded form, so the windows thumbnail service could retrieve it.
even if an extension to hold a thumbnail is implemented, the thumbnail content needs to be located in the root file
For testing/development purposes, you don't need a whole extension. Make a tiny JPG or PNG thumbnail-size image, encode it into a data-URI, and store that as a string in the JSON, under asset.extras.thumbnail
.
This would bloat the thumbnail size a bit due to base64 encoding, but ideally the thumbnail should be quite small, and this meets the requirement to store it in the root JSON.
Provide an option to have an embedded thumbnail file (.png or .jpg) in the .glb file. Windows Explorer can then show that thumbnail, making it easier to find assets on disk.
Ideally the .glb file would just be a .zip format file so you could store thumbnail.png inside the file, together with other information like the author, etc. They would just go along with the .glb (.zip format) file.
If we're too late to make .glb a .zip file, how about we create a new file extension, .glz that is a .zip format file containing the .gltf, any textures in their original file format inside the .zip, etc. It would be exactly the same as the current .zip file that we can download from SketchFab but with the .glz extension and optionally containing a thumbnail.png file.