Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

[RELEASED] Piglet: glTF Importer

Discussion in 'Assets and Asset Store' started by awesomesaucelabs, Jul 9, 2020.

  1. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    Hi everyone,

    I'm happy to announce the first release of the Piglet glTF Importer!



    Piglet can import glTF models into your Unity project, either in the Editor by drag-and-drop, or at runtime via a simple API. Piglet can help accelerate your game development by giving you access to free textures, materials, and 3D models from great sites like Sketchfab and Google Poly.

    Features
    • import glTF models in the Editor or at runtime
    • import glTF models from .gltf, .glb, or .zip files, using file paths or HTTP URLs
    • extract textures and materials from glTF models, for use with your own 3D models
    • tested with glTF models from Sketchfab, Google Poly, and Blender
    • supported platforms: Windows, Android, WebGL (Unity 2018.4 or newer)
    • full source code provided
    Links

    Asset Store Page
    Web Demo
    Manual
    Video: Editor Import Demo
    Video: Runtime Import Tutorial
    Sample Application: PigletViewer

    Web Demo

    Try Piglet before you buy it by visiting the Web Demo. Tested with Chrome and Firefox on Windows 10 64-bit.


    Viewing "SciFi Gun" by mrfetch@sketchfab.com (CC Attribution License) in the Piglet Web Demo.

    Editor Import Demo

    Importing a glTF model in the Editor via drag-and-drop:



    Runtime Import Tutorial

    A basic tutorial for importing glTF models at runtime:



    Sample Application: PigletViewer

    The source code for the Web Demo is published on GitHub with an MIT License, as an additional resource for Piglet users:

    https://github.com/AwesomesauceLabs/piglet-viewer
     
    AntonioModer likes this.
  2. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    In exchange for early feedback, I'm giving away 10 evaluation copies of the asset.

    Please send me a private message or e-mail awesomesaucelabs at gmail if you would like a voucher code. You can provide your feedback via private message, e-mail, or in an asset store review. If you leave an asset store review, please add a disclaimer stating that you received a free copy from the developer.

    Thanks!
     
    enriqueflores likes this.
  3. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    Hey @awesomesaucelabs , I just bought Piglet and wrote you a review. I hope you'll be able to get animation working soon, my team is looking at using it for .gltf model viewing on WebGL (we use GLTFUtility right now on PC and mobile devices).

    Great work on this asset so far! Thanks for writing clean and well-documented code.
     
  4. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @DerrickBarra,

    Thanks so much for the kind words and the positive review! I'm getting a lot of interest in the asset and it's my first experience of success as an indie developer, so it's pretty exciting for me.

    I've had a couple of requests to add animation support already, so I'll get cracking on that. I'm not very familiar with Unity's animation systems (yet!), but my best guess is that it will require 1-2 months of work.
     
  5. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    @awesomesaucelabs : Don't forget to take a look at how others have done it! GLTFUtility's dev ended up adding the feature but was limited to adding the legacy animation system (which makes sense).
     
  6. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
  7. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    @awesomesaucelabs : FYI I found a potential issue with Piglet's editor code. You're looking for Piglet to be under a specific path for your editor code to work, but if the plugin is moved you'll encounter issues in the editor. It's a simple fix for the user to do but you should consider either dynamically locating Piglet's path or warning the user in some way to update a reference file so that your logic doesn't break.
     
  8. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @DerrickBarra

    I see what you mean, and thanks for taking the time to let me know. (I've added it to my TODO list for the next release.)
     
  9. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @DerrickBarra

    FYI, there's a new Piglet release (1.0.1) on the store now, which fixes the hard-coded path bug you mentioned above.

    I'm making progress with the animation stuff but I expect it will take at least a few weeks still (maybe longer). Looking at the GLTFUtility code was indeed helpful (thank you). I see what you mean now about needing to use the legacy animation system, if you want to create animation clips at runtime.
     
  10. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    @awesome-sauce Awesome! I also found another "bug". If you have another plugin that uses JsonDotNet (in my case, GLTFUtility), then it can cause issues with Piglet being in the same project, which already has it's own compiled version of JsonDotNet.

    In my experience, deleting JsonDotNet from Piglet causes the GLTF plugin to get angry, and removing my separate JsonDotNet plugin from GLTFUtility causes that plugin to fail during model import on mobile devices. There's probably more testing I could do but for now, I'm just redownloading Piglet whenever I work on Unity WebGL builds and removing GLTFUtility, and then removing piglet for mobile builds and readding GLTFUtility.

    I also noticed Piglet doesn't use its own assembly definition file, you should consider using one for your plugin.
     
  11. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @DerrickBarra

    Not sure what's going on there, but that does sound like an unnecessary hassle.

    I never thought of using .asmdef(s) to prevent potential DLL conflicts, but it seems like a good idea. I'll look into it for the next release.
     
  12. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @DerrickBarra

    There's a new version of Piglet out today (1.0.2) that I hope will make your life a bit easier.

    It should now be possible to delete Piglet's copy of Newtonsoft.Json.dll without getting any errors.

    The problem was that GLTFSerialization.dll depended on a specific version of Newtonsoft.Json.dll (version 10:0:0:0). As I learned during debugging, all .NET DLLs must specify the exact versions of the assemblies they depend on, and there is no mechanism for specifying a range of acceptable versions. I solved the problem by replacing GLTFSerialization.dll with the corresponding C# source files, and now Piglet will compile with any recent version of Json.NET.

    For good form, I also added .asmdef files in Piglet 1.0.2 like you suggested, although it turned out not to help much with this particular issue.
     
    DerrickBarra likes this.
  13. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
  14. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    460
    Please add URP support if there isn't already! It's a must!
    EDIT
    Hm...from the video it doesn't seem necessary. You don't use custom shaders or anything.
     
  15. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    Hi @Marks4 :)

    I don't have any experience with SRP/URP/HDRP, but it's probably time that I learned about those!

    I do include some simple surface shaders with Piglet, which are essential for the proper functioning of the asset. They are located under Assets/Piglet/Resources/Shaders. Those shaders may need to be updated in some way for compatibility with URP, but I'm not sure at the moment.

    I'll look into what's required for URP. At the moment, I'm pretty focused on animation support, so if it requires a lot of work I may not get to it until later.
     
  16. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    Hi @awesomesaucelabs, heads up about a potential "bug" I found with GLTFUtility, and something you should check for with Piglet, since both plugins use JsonDotNet.

    So with WebGL builds, making sure we support our ILCPP stripping level of 'High' is important for maximum build size reduction and freeing up as much memory as possible for mobile devices (especially mobile WebGL!).

    I'm working on trying to do this with GTLFUtility using the [Preserve] attribute and link.xml files, but the GLTFUtility plugin loads models in with incorrect rotation when stripping is set to 'Medium' or 'High', and I believe it may be because of something being stripped from JsonDotNet (at this point I've set [Preserve] on every class and method of GLTFUtility, so the issue probably comes from the JsonDotNet dependency that I can't fix since that's a DLL.

    Anyways, figured I would let you know about this potential issue with Piglet. I'm going to try to resolve this with the developer of GLTFUtility, but since the issue might be with JsonDotNet, it might affect Piglet as well.
     
  17. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    Thanks for the heads up, @DerrickBarra

    I don't have any experience with ILCPP stripping, unfortunately. I wonder if it would it be possible to exclude Json.NET DLL from stripping, while still stripping the rest of the code (maybe via link.xml)?. That would be a good way to test your hypothesis about Json.NET.

    Your comment gives me pause, since I have been planning to add the MathNet.Numerics DLL (1.6 MB) to the next version of Piglet (for animation curve calculations).
     
  18. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    @awesomesaucelabs So for ILCPP stripping it's pretty simple, basically for every assembly definition file in your project, the ILCPP tech strips out any classes, methods, and variables that are unused in your project. So for projects like ours where everything is dynamically loaded, we have to put [Preserve] or use link.xml files a lot since technically we don't use much of anything at build time, since it's all loaded at runtime.

    I am curious to see how much of the MathNet.Numerics library could be stripped out. Unity's recommendation is to instead of using an entire DLL, developers instead make a new library that only has what they need in order to prevent an entire library from being used. Which seems like the right call to take with JsonDotNet and MathNet.Numerics (use what you need and throw the rest out).

    As for making a new library, as long as JsonDotNet and MathNet.Numerics are open source so you can see how they achieved what you need, you can make your own classes/functions that do the same (that's often times much easier than trying to carefully rip out sections of an existing library without causing bugs).

    So for JsonDotNet in GLTFUtility for example, the AOT library is about 400kb, which as far as libraries goes, is very big. So theoretically by only using the JSON logic you specifically need and making a smaller library/classes for that functionality, you could significantly decrease that size.
     
    Last edited: Aug 27, 2020
  19. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @DerrickBarra

    Thanks for the good advice!

    I agree, extracting a subset of the Json.NET/Math.NET classes/files seems like the best strategy -- it's a good middle ground between using the stock DLLs and writing my own implementations from scratch. For my particular application (linear equation solver), I expect that I'll be able to cut down the MathNet code quite a bit.

    Yeah, I'm aware that the Json.NET DLL is quite big. I've often thought about removing my dependency on Json.NET entirely, but stripping it down would be a good first step.
     
  20. MidnightCoffeeInc

    MidnightCoffeeInc

    Joined:
    Feb 28, 2017
    Posts:
    419
    Looking to purchase this for my project, looks super cool and easy to use! I love that it will take a .zip file. Definitely looking forward to Animation support, but URP/HDRP would be awesome too!
    If I purchase and edit some of the required shaders you mentioned earlier to hopefully work with URP, do you know of any other functions that might break?

    There are plenty of simple tutorials on YouTube on upgrading shaders, so that might be worth looking into :)
    https://www.youtube.com/results?search_query=upgrade+shaders+to+urp
     
  21. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @MidnightCoffeeInc

    Thanks for the feedback! I love it when people make feature requests because it helps me know if I'm working on the right thing :)

    I'm currently working on animation support and but I still have some work to do. I'm hoping to make a release with animation support either this month or next month (Sep/Oct).

    Sorry, I haven't gotten around looking at URP/HDRP yet, so I still don't know exactly what's required. You're the second person to ask about it, so I'll take it as a hint ;-) (And thanks for the link.)

    I'll send you a DM with a Piglet voucher code, so you can try it out with URP/HDRP, if you are so inclined :)
     
  22. MidnightCoffeeInc

    MidnightCoffeeInc

    Joined:
    Feb 28, 2017
    Posts:
    419
    Awesome, thanks so much! Looking forward to the next release, and I'll do my best to test it out with URP when I can!
     
  23. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @Marks4

    I just noticed your review.

    Thanks for the heads up about the problem with spaces in file paths. I will definitely fix that in the next release.

    I will look into URP support this week, and let you know what I find out.

    Good reviews are really important to me, so thanks for offering to update your review if I fix your issues.

    Talk to you soon!
     
  24. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    460
    Hey @awesomesaucelabs . Sure, I will gladly update my review. If you don't mind a suggestion regarding URP support, all you need to do really is to not use custom shaders. Because then I can convert the materials to URP with one click, simple as that. This asset does what your asset does, with no custom shaders. Hasn't been updated in years and has tons of errors, but somehow still works. I'd take a look at it and see how it manages to do it. Probably easier than having to write URP shaders. Because if you write URP shaders, somebody is gonna come along and ask for HDRP shaders, etc.
     
    Last edited: Sep 9, 2020
  25. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    Keep in mind that there is a benefit to using custom shaders, namely projects without predefined content (everything loaded from GLTF models dynamically, so there's no Unity standard shader variants included in the build). That's our use case. This is important for WebGL and project tiny builds to make sure we have the shaders added to our "Always Include" list.

    Also, my knowledge of URP is super limited, so I'm no expert on the subject, just wanted to make sure our use case for Piglet and other GLTF loaders isn't broken when converting to URP compatible materials and shaders.
     
  26. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @Marks4

    I had a look at UniGLTF. I see what you mean about being able to convert the glTF-imported materials to URP without problems. After investigating a bit though, it looks like it will be easier to add custom URP/HDRP shaders, rather than mimic what UniGLTF is doing. (Their shader setup is quite messy.) Also, adding URP/HDRP-specific shaders would remove any need to manually convert materials to URP following glTF imports.

    I've been working on URP compatibility in Piglet for the past couple of days and it's going pretty well so far. My best guess is that it will take about a week to complete that, but I'll keep you posted.

    @DerrickBarra

    Understood! I definitely want to support that use case, and since I've decided to go with custom URP/HDRP shaders it shouldn't be an issue.
     
  27. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @Marks4 and @MidnightCoffeeInc

    Just a quick update. It's going fine with the URP/HDRP shader work, but it looks like it's going to take a bit more time (maybe another week yet). Bear with me and I'll let you know when the new release is out.

    Happy Friday!
     
    Marks4 likes this.
  28. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @Marks4 and @MidnightCoffeeInc

    Just wanted to let you know: The new Piglet release is out (1.0.4), which now has support for URP! You need to be using at least Unity 2019.3, and then all you need to do is unpack the shader files in Assets/Piglet/Extras/URPShaders.unitypackage and you should be good to go.

    Making the URP shaders took quite a bit longer than I expected, mostly spent learning the quirks and limitations of the shader graph editor and tripping on various compatibility issues between different rendering pipelines and versions of Unity. But overall, I still think adding custom shaders was the right approach.

    @Marks4

    This release also fixes the annoying spaces-in-file-path bug. Please remember to update your review once you've had a chance to try it! (Or if you are no longer interested in the asset, you could also just remove your review.)
     
    Last edited: Sep 29, 2020
    Marks4 likes this.
  29. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    @awesomesaucelabs : So if you haven't seen this already, you should look into supporting KTX and Basis textures via the KTXUnity plugin. Our team will be experimenting with them soon, but from everything I've seen they improve texture loading performance by an enormous factor, making them a perfect substitute for the GPU ready textures in the Unity Asset Bundle system on WebGL and with the GLTF format.

    KTXUnity Plugin
    Demo Project



    We intend to check for the plugin using the KTX scripting define symbol we'll add to our project settings. Then whenever a texture we load is .ktx or .basis, we'll use the plugin to load the texture instead of the standard Unity load.

    Our plan is to load .glb files with textures formatted with either the .ktx or .basis format. I haven't spent much time looking into .glb yet, but hopefully, the fact that it merges all the files into one won't prevent you from adding KTX support (it shouldn't).
     
    awesomesaucelabs likes this.
  30. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @DerrickBarra

    Thanks for sharing this. Looks pretty awesome :)

    I've heard of Universal Basis format before but I didn't really know what it was about until today. (For my own future reference, the more general term is "supercompressed" textures. This article explains the motivations behind the Universal Basis format, and this paper goes into the nitty-gritty details of the algorithms.)

    I definitely want to improve performance of texture loading in Piglet at some point, and this may be the thing that solves it for me, so I appreciate the heads-up. Even more than overall speed, I want to make sure that runtime texture loading never interrupts the main Unity thread. As far as I understand, the main issue is that Unity uploads textures to the GPU in a synchronous manner, as discussed in this thread. So even though Piglet decompresses the PNG/JPG textures on a background thread using UnityWebRequestTexture, there can still be hiccups when uploading the textures to the GPU. Sheesh.

    As far as my work schedule goes, I'm planning to spend most of this month wrapping up animation support (going well by the way!), but after that I'll have a closer look at improving texture loading performance.
     
  31. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    @awesomesaucelabs : Your understanding of the .jpg/.png loading situation is on point. That's one of the primary motivators for Unity using their own AssetBundle system, as it packages the textures as GPU ready variants for you. The supercompressed textures that KTX brings us are as close as we can get right now to have these GPU ready textures without building variants for each GPU type out there.

    Our team is going to be using KTX for pretty much everything from here on out (not just models, but for general textures as well), our server will generate and store the KTX version and then Unity will use that instead of the original .jpg/.png.
     
  32. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @DerrickBarra

    Cool, thanks for confirming my understanding about texture loading stalls. People ask about that all the time on the forums but I've ever seen a response from the Unity folks that acknowledges the problem or explains the cause.

    Looking forward to learning more about KTX.
     
  33. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    @awesomesaucelabs : Just wanted to give you an update on our progress with our KTX research...

    So we've been working on implementing KTX/Basis support in Unity via @atteneder's awesome KtxUnity plugin. There's still a nasty Editor bug at the time of this writing but it works on Android & WebGL (haven't personally tested iOS or Mac yet).

    There was a decent amount of confusion on my part about how to use KTX and BASIS files, but it's actually quite simple.

    - A .basis file is a supercompressed texture. It's one step away from becoming any type of GPU texture (ETC1, DXT1/5, PVRTC, etc). So it's almost as efficient as loading a GPU ready texture, but you only have to worry about creating and downloading a single file type, so it's super worth it.

    - .basis files can be made using two encoding types, ETC1S and UASTC. ETC1S is the default and the lower quality of the two, but it has a very low bits per texel ratio (between 0.30 - 1.25 bpt), so it's very efficient for transmission file size. UASTC files are much bigger at 2-8 bpt but are nearly flawless quality-wise, so they are sometimes used for normal maps.

    - A .basis file is loaded into RAM and transcoded by the CPU into the GPU format your device supports and loads into VRAM. I'm still not sure if it gets cleared from RAM at this point. The final amount of VRAM used is dependent on whatever format the .basis texture got converted into when it became a texture (same ram usage as the GPU texture your platform prefers).

    - You can store any texture type inside of a .ktx or .ktx2 file. It's just a container format. For .ktx it was common to store a bunch of GPU ready textures, and you can still do that with .ktx2 but everyone just uses a .basis payload instead as it's what everyone should use moving forward. If you use the .basis file outside of a .ktx2, that also works, but most teams are just stuffing a .basis inside of a .ktx2.

    -------------------------

    Creating and using a .basis file is also not that hard...

    - Create .basis textures for your model using the basisu command line tool. Make sure to enable the flipY command so the textures are flipped correctly in Unity.

    - Load up this .basis texture using the KtxUnity plugin. It returns a Texture2D as well as the orientation of the texture in case you need to flip it in your code.

    ---------------------------

    So basically to add support to Piglet for KTX & Basis files, your code should optionally check if a scripting define symbol exists (we use 'KTX'), hopefully, you don't have to add KtxUnity as a dependency (you might not have a choice).

    If you have access to KtxUnity and the mime type or extension of the texture you want to load is either .ktx, .ktx2, or .basis, then use KtxUnity to load the texture, otherwise, it's a normal texture and you can load it like normal.

    If the orientation of the texture is the "default", you'll need to flip it in your code, that's pretty much the only "gotcha".

    KtxUnity only has binaries for Android, iOS, Mac, PC, and WebGL right now, so it's not 100% universal but it's very useful for a lot of platforms.

    I wouldn't recommend making piglet require KTXUnity, just in case this functionality becomes built into Unity or someone doesn't want to use it. So wrapping your KtxUnity plugin code around the "KTX" scripting define symbol is the way to go.
     
    Last edited: Oct 30, 2020
    awesomesaucelabs likes this.
  34. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @DerrickBarra

    Thanks so much taking the time to write these notes! There is a lot of useful information here, much of which I did not already know. I expect this will save me a lot of time when I finally get around to adding KTX support (soon!). And as you say, it probably won't be that much work. I agree about making KtxUnity an optional dependency, btw.

    On my side, I'm getting really close to finishing animation support, which I've been working doggedly on for the past three months. At this point, I just need to do some sanity checks, make some tutorial videos, and update the manual.

    I promise I'll look at KTX support in November!
     
  35. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    @awesomesaucelabs BTW we're testing out Draco compression on our models and seeing very impressive results (huge reduction in file size for poly data). We're currently mucking around with GLTFUtility to see if it can load up models using this GLTF extension, but we know the optimizer tool we're using supports it (and viewers that support Draco like <model-viewer> are confirmed to work with this extension).

    Note: <model-viewer> supports Draco but doesn't support KTX2/Basis, too bad! Would be nice to have a testing web app that supports all the optimizations at once.

    Our team put together some test files on our S3 server so everyone can see how these work on their viewers.

    • Horse [NO KTX] [NO DRACO LOSSY] 2175kb
    https://bxrtest.s3.amazonaws.com/Draco_And_KTX_Testing/horse_NoKTX2_NoDraco.glb

    • Horse [NO KTX] [ DRACO LOSSY] 1670kb
    https://bxrtest.s3.amazonaws.com/Draco_And_KTX_Testing/horse_NoKTX2_DracoLossy.glb

    • Horse [KTX] [NO DRACO LOSSY] 1243kb
    https://bxrtest.s3.amazonaws.com/Draco_And_KTX_Testing/horse_KTX2_NoDraco.glb

    • Horse [KTX] [DRACO LOSSY] 734kb
    https://bxrtest.s3.amazonaws.com/Draco_And_KTX_Testing/horse_KTX2_DracoLossy.glb
     
    Last edited: Nov 4, 2020
  36. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @DerrickBarra

    Thanks for the test models!

    I've heard about Draco compression, and the results look pretty impressive. (For example, the Cesium page about Draco shows glTF models being compressed by a factor of approx. 7X!)

    For my own future reference, here are some links about Draco mesh compression:

    * Draco overview (blog post by Cesium)
    * "EdgeBreaker, the Heart of Google Draco" (blog post by Vladimir Agafonkin)
    * original paper about EdgeBreaker algorithm
    * second EdgeBreaker paper with simplified algorithm

    A couple of people have asked me about Draco support in Piglet, but it's currently behind the following items on my TODO list:

    * animation support (I'm almost done, I swear!)
    * add iPhone to list of officially supported platforms
    * KTX support (supercompressed textures)
     
  37. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    859
    I have just bought your asset.
    The runtime import scene is working on the piglet model, but I can’t import anything in editor.
    I am using unity 2019.4.13.
    Neither drag&drop, nor Asset/Import New Asset nor file copying with file system.
    The Window/Piglet Options are setup correctly.
    My gltf model also opens correctly in Windows10 and in your webgl demo.
    Maybe I am missing something oe doing something wrong?
     
  38. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    Hi @tomekkie2,

    Sorry to hear you are having trouble with the asset.

    I'm currently installing Unity 2019.4.13f1 to see if I can reproduce the problem. I test Piglet across many Unity versions (2018, 2019, 2020). So far, the closest version I have tested with is 2019.4.5f1 (and it worked as intended).

    I saw from your other message (e-mail) that you tried installing Piglet in a fresh project, and that it didn't solve the issue.

    Neither Asset/Import New Asset nor copying with file system will trigger the glTF import. Only dragging-and-dropping a .gltf/.glb/.zip file onto the Unity Project Browser window will work. Dragging-and-dropping a directory containing a .gltf/.glb/.zip file will *not* trigger a glTF import.

    Some trouble-shooting questions:

    * What OS are you using? (Windows 10? Linux? MacOS?)
    * Have you already tried following the steps in the Editor Import Tutorial video?
    * Are you seeing any errors or warnings in the Unity Console?
    * If you enable "Print progress messages in Console" in Window/Piglet Options, do you see any messages after dragging-and-dropping a .gltf/.glb/.zip file onto the Unity Project Browser window?

    I'd be happy to provide a refund if we can't solve your problem. Just send me the e-mail address associated with your PayPal account or bank account (for e-transfer) in a private message.

    EDIT 1: Added some more troubleshooting questions (bullet points).
    EDIT 2: I just tried a drag-and-drop glTF import with Unity 2019.4.13f1 and it worked correctly. (Hmm...)
     
    Last edited: Nov 5, 2020
  39. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @tomekkie2

    By the way, I accidentally posted my previous reply before I had finished writing it, so you will see a truncated message in your e-mail notification. Please check the forum thread for the full message.
     
  40. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    859
    Windows 10.
    I have just expected to be able to drag&drop straightaway after installing the asset.
    But even a copied gltf file did not show up as asset in Unity inspector don't know why.
    Then I have removed Piglet asset and imported the GLTFUtility from github and the file got imported and showed up as asset.

    I have also tried other projects, in other Unity versions, including 2019.3.0 and 2020.1.3 - with the same results.

    Is there much difference between this GLTFUtility and Piglet asset?
     
    Last edited: Nov 5, 2020
  41. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    As you should!

    If you want to keep troubleshooting (up to you!), following the steps Editor Import Tutorial video is the next logical step (if you haven't done so already). I am guessing this is just a misunderstanding about how Piglet works, but unfortunately I'm not sure what it is.

    Editor imports are handled differently in GLTFUtility and Piglet. GLTFUtility uses ScriptedImporter and behaves similarly to a built-in Unity importer (e.g. texture importer, FBX importer), in the sense that it shows import settings in the Inspector and automatically updates the .asset file when the underlying .gltf/.glb changes on the filesystem. Piglet on the other hand does a one-time conversion to a Unity prefab whenever you drag-and-drop a .gltf/.glb/.zip file from Windows File Explorer to a folder in the Unity Project Browser window.

    I have not done a detailed comparison of features/performance between GLTFUtility and Piglet, but currently they have very similar capabilities.

    I would say that if GLTFUtility is working well for you, you should stick with that for now. I can send you a refund and you can always try Piglet again later if it provides a feature that is missing in GLTFUtility. They are both well-written glTF importers with lots of users.

    EDIT: Add paragraph about differences in Editor import behaviour between GLTFUtility and Piglet.
     
    Last edited: Nov 5, 2020
    JUNG7R likes this.
  42. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    859
    I have watched, all seems just very simple, but I just can't get it to work on my computer for some strange reasons.
    Then I have removed GLTFUtility from my sample project, the thumb image has disappeared from my sample gltf file, imported the piglet asset again and the thumb did not reappear again.
     
  43. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @tomekkie2

    Bummer. I think we are at a dead end :-(

    It could be some rare Windows configuration issue that I just haven't encountered until now.

    On the off-chance it helps, make sure you are not holding the Control key when you drag-and-drop the file into Unity. (Holding the the Control or Command keys while dragging the .gltf/.glb/.zip file will bypass the normal Piglet glTF import behaviour and just do a straight copy of the file.)

    Are you testing with a .gltf, .glb, or .zip file? If it's a .zip file, maybe it has something to do with the way the archive is structured. Have you tested with any other .gltf/.glb/.zip files? That might be worth a try, just to see if the problem is related to that particular file. (Would you be able to e-mail me your glTF file?)
     
  44. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @tomekkie2

    By the way, installing Piglet with the .gltf/.glb/.zip file already in your project will not do anything. All the action happens (or should happen!) when you first drag the file into the Unity project from Windows File Explorer. (It is a one-time conversion process to a Unity prefab.)
     
  45. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @tomekkie2

    Another thing: The .gltf/.glb/.zip must originally be located somewhere *outside* of your Unity Assets directory before you drag it into your Unity project. (Nothing but a normal file copy will happen if you drag a .gltf/.glb/.zip between two folders that are both located under your Assets folder.)
     
    Last edited: Nov 5, 2020
  46. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    859
    This a .gltf file. The problem is not related to that particular file, because it imports well to your webgl demo, I have also tried other files. All the checks you point in the above posts are met.
    Maybe this is something related to my system, but I don't have anything unusual here.
    Thank you for your patience and determination anyway.
    For the time being I am happy with GLTFutility.
    I will check it somewhere else when I have a chance.
    Generally I was hoping for getting more optimized meshes from gltf than from obj but it looks like I was wrong and misunderstood something.
    I am getting the same looking meshes, with the same triangles counts, from both formats, but with less import options from gltf.
     
  47. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    @tomekkie2

    I'm sorry we couldn't solve it :-/

    Yes, I agree. Using glTF wouldn't optimize your meshes. You would have to do mesh simplification/optimization in a 3D modeling program (e.g. Blender) or some other tool, before saving it out to glTF/OBJ.

    I will give some thought about making Piglet behave more like GLTFUtility for Editor imports. One other person commented on that before, although they were still able to use the asset successfully.
     
    tomekkie2 likes this.
  48. chpax_159

    chpax_159

    Joined:
    Oct 11, 2014
    Posts:
    4
    Hi, Does support Blendshapes?
     
  49. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    167
    Hi @chpax_159,

    Yes and no. Piglet correctly loads the blendshape data into SkinnedMeshRenderer(s), however it does not yet import/create the AnimationClips that animate the blendshapes (a.k.a. morph targets).

    There's a new Piglet release with full animation support coming out very soon (this month).
     
  50. Pode

    Pode

    Joined:
    Nov 13, 2013
    Posts:
    141
    @awesomesaucelabs Hi, does Piglet works with WebGL 1.0? No problem for me with WebGL2, but it seems not with 1.0.