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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

[RELEASED] Piglet: glTF Importer

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

  1. Foxtalic

    Foxtalic

    Joined:
    Jan 12, 2021
    Posts:
    1
    I cant get Piglet to convert the Zip files when I drag them in. I'm using Unity v2018.4.20f1, is there a step i'm missing after importing to get it to work?
     
  2. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Hi @Foxtalic,

    That's strange! I'm not sure what the problem could be.

    Have you tried importing other .zip files? Does importing .gltf/.glb files work as expected?

    What O/S are you using? What version of Piglet?

    Closest version of Unity I've tested with is 2018.4.16f1. I'll try installing Unity 2018.4.20f1 and drag-and-drop a .zip file, to see if I can reproduce the problem.
     
  3. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    @Foxtalic,

    Dragging-and-dropping a .zip works as expected for me using Unity 2018.4.20f1 / Piglet 1.3.2 / Windows 10.

    I'd be happy to provide a refund if we can't solve your problem. (Just send me the e-mail address for your PayPal account.)
     
  4. dariuspowell

    dariuspowell

    Joined:
    Jun 11, 2015
    Posts:
    28
    Hi.
    I'm struggling to get Piglet to work in UNITY 2020.1.7f1. I've tried both a Zipped gtlf with external textures and a glb file.

    The zipped version gives me the following error:

    ArgumentNullException: Value cannot be null.
    Parameter name: source
    System.Linq.Enumerable.Take[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Int32 count) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
    Piglet.TextureUtil.IsKtx2Data (System.Collections.Generic.IEnumerable`1[T] data) (at Assets/Piglet/Scripts/Util/TextureUtil.cs:68)
    Piglet.TextureUtil+<LoadTexture>d__7.MoveNext () (at Assets/Piglet/Scripts/Util/TextureUtil.cs:261)
    Piglet.GltfImporter+<LoadImage>d__19.MoveNext () (at Assets/Piglet/Scripts/Importer/GltfImporter.cs:580)
    Piglet.GltfImporter+<LoadTexture>d__23.MoveNext () (at Assets/Piglet/Scripts/Importer/GltfImporter.cs:761)
    Piglet.InterleavedTaskSet`1[T].MoveNext () (at Assets/Piglet/Scripts/Util/InterleavedTaskSet.cs:89)
    Piglet.GltfImporter+<LoadTextures>d__20.MoveNext () (at Assets/Piglet/Scripts/Importer/GltfImporter.cs:667)
    Piglet.GltfImportTask.MoveNext () (at Assets/Piglet/Scripts/Importer/GltfImportTask.cs:267)
    Piglet.ProjectBrowserGltfImporter+<ImportCoroutine>d__5.MoveNext () (at Assets/Piglet/Editor/ProjectBrowser/ProjectBrowserGltfImporter.cs:225)
    UnityEngine.Debug:LogException(Exception)
    Piglet.<ImportCoroutine>d__5:MoveNext() (at Assets/Piglet/Editor/ProjectBrowser/ProjectBrowserGltfImporter.cs:230)
    Piglet.<>c:<StartImport>g__ImporterUpdate|4_0() (at Assets/Piglet/Editor/ProjectBrowser/ProjectBrowserGltfImporter.cs:149)
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions()


    Any suggestions where I'm going wrong? Importing an animated scene from Blender.

    thanks
    Darius
     
  5. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Hi @dariuspowell!

    Based on the stack trace, it looks like Piglet is not able to find a PNG/JPG file inside the .zip (for some reason), and so it ends up passing `null` to the downstream texture-loading methods. Your message made me realize that I should have a better error message when Piglet can't locate/extract a file from a .zip (I've made a note to fix that in a future release).

    Can you share the problem .zip/.glb with me, by sending it to awesomesaucelabs at gmail? (I will keep these files private, of course.) Then I can debug it and see exactly why it is failing.

    Have you tried to load other models with Piglet?
     
  6. SFX_One

    SFX_One

    Joined:
    Apr 7, 2019
    Posts:
    5
    Hello, I would like to buy your tool, but my workflow colorspace is Linear only... It seems like you said it doesn't work well with Linear mode, is it correct ?
    Also, would it be possible to target a specific shader for the materials when importing the files in Unity Editor ? For example, Standard shader doesn't have roughness (autodesk), or even other Custom shaders.

    Thanks for your answers
     
  7. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Hi @SFX_One!

    Thanks for your message.

    Yes, Piglet currently has an issue with linear color mode (as described in the Caveats section of the Piglet manual). A few people have been asking me to fix that lately, and it is a high priority issue for me. I expect that the fix will take a few weeks of work, though. (I will send you a message when it is ready.)

    The ability to use custom shader setups has also been requested by a few people recently. Currently, the mapping from glTF materials -> shaders is hardcoded in Piglet. The relevant method is
    LoadMaterial
    in
    Assets/Piglet/Scripts/Importer/GltfImporter.cs
    . Although the code is easy to understand and modify (IMO), eventually I would like to have shader mappings be configurable via a JSON file. That improvement will come later, probably 1-2 months from now.
     
  8. SFX_One

    SFX_One

    Joined:
    Apr 7, 2019
    Posts:
    5
    Thanks for your answer, I will definitely buy it when the linear mode will be ready, and using custom shader is definitely a huge bonus too.
     
  9. Pode

    Pode

    Joined:
    Nov 13, 2013
    Posts:
    145
    @awesomesaucelabs I don't know if it's the route you choose, but to be 'linear' and back, you can elevate the texture sample to pow(X,1/2.2) or pow(X,2.2) in the shader. It's a bit costly in WebGL, though.

    One request on my side would be the compatibility with the 'LINE' primitive :), but it's not urgent.
     
  10. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Thanks, @Pode!

    Yep, that's basically what I need to do -- make the linear/gamma correction myself in the shaders. It's necessary to do my own correction in the shaders because UnityWebRequestTexture (which I use to load textures at runtime) doesn't have a "linear" option and assumes all textures are sRGB. If not for that one limitation, everything would be so easy.

    Request for 'LINE' noted, but it would probably be quite a while before I get to it. (If you wanted to hack it in yourself, I would be happy to provide guidance about the code, though.)
     
  11. Pode

    Pode

    Joined:
    Nov 13, 2013
    Posts:
    145
    Thanks for the proposition! It's not urgent, so take all the time you need.
     
  12. dennyroberts

    dennyroberts

    Joined:
    Feb 14, 2016
    Posts:
    7
    Hi there! Did a quick search on this thread and in the manual and couldn't find anything. Is there a way to make the material receive realtime shadows?
     
  13. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Hi @dennyroberts :)

    I haven't tested it, but I think you would just need to enable shadows in the provided shaders.

    Assuming you are using the built-in render pipeline (as opposed to URP), try removing
    noshadow
    in the following line of
    Assets/Piglet/Resources/Shaders/Standard/MetallicRoughnessOpaque.shader
    :

    Code (csharp):
    1. #pragma surface surf Standard noshadow nolightmap nofog nometa nolppv
    Instead of just removing
    noshadow
    , you could also try replacing
    noshadow
    with
    fullforwardshadows
    . See Writing Surface Shaders for the available
    #pragma
    keywords.

    For your reference, Catlike Coding has a great tutorial about using shadows in Unity: https://catlikecoding.com/unity/tutorials/rendering/part-7/

    The shaders provided with Piglet have most features disabled by default because I'm not very experienced with writing shaders, and I wanted the default shader setup to be as simple as possible. For example, enabling shadows can generate weird visual artifacts if the project settings for shadows are not configured correctly (as described in the Catlike Coding article), which could be confusing to beginners.
     
    Last edited: Jul 21, 2021
  14. dennyroberts

    dennyroberts

    Joined:
    Feb 14, 2016
    Posts:
    7
    Thanks for the quick response and those links! So just removing
    noshadow
    didn't change anything that I could notice; replacing with
    fullforwardshadows
    did something kind of weird (you could see shadows on some of the objects, but they weren't oriented as if they were on the face; it was like you could see through the face or something); then I tried replacing with
    addshadow
    and that had the desired effect. Kind of strange because that's not what I would expect it to do according to the docs you linked to... but I'll take it!

    Thanks again ✌️
     
  15. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    @dennyroberts,

    Glad you got it working and thanks for reporting back! (I'm not sure why just removing
    noshadow
    didn't work, or why you saw weird shadow orientation with
    fullforwardshadows
    .)
     
  16. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    Hi @awesomesaucelabs, hope you've had a great summer!

    Wanted to ping you back and see if the Kratos model bug we reported is on the task list.

    Also that our BrandXR player (using the Piglet importer) is going well, having Draco & KTX support has made our efforts to get everything working smoothly on mobile WebGL so much easier.

    Check out some examples...
    Pac Man
    Link
    Spyro
    Megaman X (Video Test)
     
    Last edited: Aug 6, 2021
  17. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Your viewer looks great, @DerrickBarra! How did you do the animated PacMan/MegaMan screens? (Is that all encoded in glTF?!)

    I wanted to try the A/R mode on my phone but sadly my old Samsung Galaxy J2 is not up to the task. I was amazed that the model even loaded at all inside my mobile web browser... kudos!

    Anyhow, that's great work and thanks for sharing it. I feel proud to be a part of that.

    Re: Kratos model bug, sorry I haven't fix that yet. I've been absorbed in some other Piglet-related work, but that bug has been nagging at the back of my brain since @ASGS_DumbFox reported it back in June. I will revisit the bug next week and have another stab at fixing it.

    FYI, it is a linear algebra issue, related to converting from glTF's right-handed coordinate space to Unity's left-handed coordinate space. More specifically, the GetUnityTRSProperties method in Assets/Piglet/Dependencies/UnityGLTF/SchemaExtensions.cs is not working correctly when the glTF transform is supplied as a matrix rather than as separate transform, scale, and rotation properties. Even the matrix case seems to work correctly most of the time, but things go wrong when one of the scale x/y/z components is negative.
     
  18. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    So Pac-Man is just moving around the characters as billboarded textures on a loop within a GLTF. The Megaman X example at the end is a video player with our custom player controls layered on top of the texture.

    Part of what our service does is auto-optimize content that's given to it so they work well with mobile WebGL. And like I mentioned before, getting KTX2/Basis and Draco supported throughout our pipeline was crucial to stay below the tiny memory limit of mobile browsers (256mb in most cases). Our eventual goal is for multiple pieces of content in a scene with WebXR support.

    For the Kratos bug, I'm glad you have an inkling of where it's coming from. We get so many weird/bad models from Sketchfab, so we're never surprised when one of them explodes.
     
  19. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    @DerrickBarra (CC: @ASGS_DumbFox),

    That's interesting, thanks for explaining! Playing video onto a Unity texture sounds pretty challenging. Do you mind sharing which Unity asset/library you use for that? Or is it something you made in-house? I'm interested because I might be able to learn some tricks for fast/async texture loading in Piglet.

    I'll send you guys an update about that Khronos bug later this week. Even though I understand where the bug is coming from, it looks like it will require digging through some linear algebra theory to solve it. (I enjoy that sort of thing, though.)
     
  20. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    Oh, well the video is a Unity video player, just applied to a texture. We would be using AVProVideo, but there's currently a bug with iOS WebGL that prevents that plugin from working on that platform. The custom controls are something we whipped up internally.

    If you're looking for a faster way of loading textures, the biggest holdup is already solved via KTXUnity, which you've already integrated. However, for loading regular PNG/JPG textures, the best I've seen is via the UnityAsyncImageLoader. But it has some drawbacks.

    - Requires the complete FreeImage library for image processing (not great for WebGL)
    - Uses separate threads, so not WebGL compatible (would need to use WebAssembly instances)
    - Uses Unity Burst & Mathematics, so again not WebGL friendly

    If I ever find anything better, I'll let you know, but I've never found a better solution. That's why I was so happy to find KTXUnity and integrate that into our pipeline.
     
  21. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Thanks for the info, @DerrickBarra!

    I was not aware of Unity's VideoPlayer class.

    You are right, texture-loading performance is pretty much solved by using KtxUnity. I was just keeping an eye out for techniques to improve PNG/JPG loading.

    I was not aware of the UnityAsyncImageLoader package and it looks quite interesting! I may give that a try at some point (as an optional dependency). Thanks for noting the caveats (those are important).
     
  22. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    @DerrickBarra (CC @ASGS_DumbFox),

    I spent a bit of time revisiting the Kratos model bug this week. Although I haven't succeeded in fixing the bug yet, I've just discovered that @atteneder had the same problem and made a blog post about his solution: Matrix Decomposition in Unity. (@atteneder to the rescue again!)

    Next week I'll work on integrating that solution into Piglet. The code is fairly short/simple but I don't completely understand the math yet. Also, in order to make it WebGL-compatible, I will probably need to remove the dependency on
    Unity.Mathematics
    , which may take some work.

    Fixing this bug is a side-task for me in comparison to other Piglet work, so please bear with me if it takes a while.

    For future reference, here are some background details about the bug:

    - The bug is caused by the
    GetTRSProperties
    method in
    Assets/Piglet/Dependencies/UnityGLTF/SchemaExtensions.cs
    . The purpose of that method is to decompose the 4x4 transformation matrix (coming from the glTF file) into separate translation, scale, and rotation vectors.

    - I inherited the
    GetTRSProperties
    method from the Sketchfab glTF importer, and it appears the Sketchfab devs got the code from this Unity Answers post.

    - The solution from the Unity Answers post is simple and works well for nearly all cases, but gives incorrect results when the scaling part of the matrix has an odd number of negative components (e.g. scale.x is negative but scale.y and scale.z are positive). This caveat is mentioned in the discussion of the Unity Answers post above.

    - From-scratch solutions that correctly handle all cases of the matrix decomposition problem are complex. The ones I've seen so far use Polar Decomposition or Singular Value Decomposition, which is kind of like implementing a linear algebra solver. The most helpful resource I've found so far is this blog post: 3-Blog: Decomposing Affine Transforms
     
    Last edited: Aug 13, 2021
    DerrickBarra likes this.
  23. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    @DerrickBarra / @ASGS_DumbFox,

    I should mention that the Kratos model is the only example of this bug that I've seen so far, which is why I'm treating it as a B-priority task. (Time consuming to fix and limited benefits.)
     
    DerrickBarra likes this.
  24. john_goren

    john_goren

    Joined:
    Mar 19, 2021
    Posts:
    15
    If I want Piglet to load a model from Android assets, do you happen to know what the best URI scheme is for this? The manual mentions content URIs. Wondering whether the best way to go would be a content:://, file://android_asset, etc...
     
  25. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Hi @john_goren,

    Sorry, I don't have much experience with the trade-offs between content URIs and file URIs on Android.

    When testing Piglet on Android, I've only tested with content URIs, since file browser apps use content URIs when opening a file with an external program (opening a .glb/.zip file with PigletViewer in my case). But in principle I think file:// URIs should work fine too.

    Although I personally find content URIs to be weird and awkward, they seem to be recommended method for opening files on Android.

    One minor disadvantage of content URIs is that you generally can't load .gltf files (only .glb and .zip), because it's not possible to resolve relative paths to .bin/.png/.jpg files inside the .gltf file. But that's not a big deal since you have the option to use .glb or .zip instead.
     
  26. john_goren

    john_goren

    Joined:
    Mar 19, 2021
    Posts:
    15
    Thanks for the quick reply. So it looks like I need to review Content URIs 101 :) and potentially Content Providers -- since I guess special arrangements may have to be made to send assets across the Android / Unity wall.

    But it's good to know that content URIs will work -- thanks much.
     
  27. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    @john_goren,

    Good luck, and I'd be interested to hear how it works out for you!

    FYI,
    UnityWebRequest
    does not natively support reading from content URIs, so I had to implement my own reader using Unity's C#/Java interop. But it wasn't too bad. See the following files for an example:

    - Assets/Piglet/Scripts/Android/ContentUriUtil.cs
    - Assets/Piglet/Plugins/Android/ContentUriStream.java
     
    john_goren likes this.
  28. john_goren

    john_goren

    Joined:
    Mar 19, 2021
    Posts:
    15
    Success! I tried several methods before using a FileProvider as follows. This might be helpful as a step-by-step guide for newbies like myself.

    1) On the Android app, our Activity copies the 3D asset into an internal files directory.
    2) We declare a FileProvider in the manifest, and declare a path to the file under "${appName}.provider/models"
    3) This now allows us to build a Content URI, a la "content://${appName}.provider/models/${modelFilename}." The great thing about this is that we can test the Content URI on the Android side to make sure it works before sending it across to Unity.
    4) Unity receives the Content URI from an Android Intent.
    5) Piglet uses the Content URI to load the 3D model. (To make sure it is working, I set a breakpoint in Android's FileProvider. You can watch as Unity successfully grabs a File that exists in the Android internal files directory.)

    Other things I tried without success:

    - I tried to serve the 3D model directly from Android Assets, using a custom ContentProvider. But from experimenting with the path XML file, it seems like you aren't allowed to give a ContentProvider access to files other than file storage directories (internal, external).

    - I tried someone's code for calling the Android Asset manager directly from Unity C# and trying to extract bytes. This led me into a murky area of the JNI that was hard to debug, and led to some "obsolete method" errors.

    One approach I thought of but haven't tried is: It seems like you could serve bytes directly to Unity from an Android ContentProvider.

    Edit: The one thing I am thinking about now is whether I can somehow cache the bytes/file so that Unity doesn't keep having to reload the same object...(I have a weird situation where the Vuforia AR library doesn't seem to be respecting DontDestroyOnLoad)
     
    Last edited: Aug 21, 2021
  29. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    @john_goren,

    Glad to hear you got it working, and thanks for sharing your notes!

    I hate all this Android ContentProvider crap, but as long as it works, I guess. *shrug*

    It sounds like all you want to do is bundle a .glb file with your app and load it at runtime. Is that correct? Have you tried putting the .glb in the
    Assets/StreamingAssets
    folder of your Unity project? (See: https://docs.unity3d.com/Manual/StreamingAssets.html)

    I know StreamingAssets works fine on Android because I use it to load the default model ("Sir Piggleston" mascot model) in the demo PigletViewer app.
     
  30. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    @john_goren,

    Sorry I didn't mention the StreamingAssets option earlier, btw. It only occurred to me after I read your most recent post.
     
  31. john_goren

    john_goren

    Joined:
    Mar 19, 2021
    Posts:
    15
    Thanks! Yeah, the ContentProvider feels like an archaic 1990s way of doing anything, and it took forever to figure out. The Android documentation was also unnecessarily abstract where it should have been suggesting simple recipes.

    For size reasons, I am not allowed to ship the Unity project with all 50 of the .glb models we are using (my preference would have been to do just this.) Otherwise I would build the game with all the 3D models ready to use under Unity Assets. (Unless you are suggesting that we could somehow save files there at runtime...) Thus the importing across the great barrier of the Content URI...

    Although maybe Application.persistentDataPath would allow this kind of saving at runtime?
     
  32. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    @john_goren,

    Fair enough. Yes, the content URI approach makes sense if you need to minimize your app size. FYI, it is also possible to reduce the sizes of your .glb files with Draco compression and/or KTX2 texture compression. When used in combination, I saw 80%-90% reduction in file sizes on my test models, although it might require hand-tweaking of compression parameters to get acceptable texture quality. (KTX2 can make your textures look blocky/low-res.)

    Also, gltfpack is a great tool for mesh simplification, which is another way to reduce .glb file sizes.

    Unfortunately, I don't think it's possible. From what I have read, during a Unity build the contents of your Assets folder get baked into a proprietary "game-ready" format, and after that it is read-only. I think they added the StreamingAssets feature specifically to work around that, in cases where app developers need to read in regular files at runtime.

    Yes, I think that should work. I can't remember if I've tested
    Application.persistentDataPath
    specifically, but I read/write
    Application.temporaryCachePath
    in my PigletViewer app, and that functionality works fine on Android. (WebGL is another story...)
     
    Last edited: Aug 22, 2021
    john_goren likes this.
  33. nickxr4

    nickxr4

    Joined:
    Apr 29, 2019
    Posts:
    2
    Wow! It seems this is what I have been looking for for so long.
    I would like to use it in my HoloLens app.
    Does your plugin support UWP?
     
  34. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Hi @nickpronin98!

    Piglet does not officially support UWP yet because I haven't properly tested it. However, I recall another user saying it worked fine for them (also for a Hololens app).

    Send me an e-mail at "awesomesaucelabs" at gmail and I'll send you a free copy so you can try it yourself! (I need to send the .unitypackage via email because this forum has no way to privately send files.)
     
  35. omechano

    omechano

    Joined:
    Sep 12, 2014
    Posts:
    24
    Does this asset have IOS support ?
     
  36. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Hi @omechano!

    Piglet does not yet officially support for iOS, because I haven't tested on that platform yet. (I own an iPhone 10 and I recently bought an M1 Mac Mini, so I hope to add official support for iOS soon.) However, several users have already reported that Piglet is working well for them on iOS.

    Please send an email to "awesomesaucelabs" at gmail and I will send you a free copy of Piglet 1.3.2, so you can try it out yourself on iOS without risk. (I have to send the .unitypackage to you over email because this forum does not provide any way to privately share files.)

    As a first test, I recommend doing an iOS build of the example scene under Assets/Piglet/Examples/RuntimeImport and then running it on your iPhone/iPad. If it shows a spinning model of the Piglet mascot ("Sir Piggleston"), then everything is working correctly.
     
    Last edited: Sep 10, 2021
  37. ASGS_DumbFox

    ASGS_DumbFox

    Joined:
    Sep 23, 2017
    Posts:
    22
    @omechano @awesomesaucelabs

    We are using Piglet across all our platforms (Android, WebGL, and iOS) and it works fine for all. Just wanted to throw that out there! :D
     
  38. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
  39. omechano

    omechano

    Joined:
    Sep 12, 2014
    Posts:
    24
    Thanks
     
  40. wxxhrt

    wxxhrt

    Joined:
    Mar 18, 2014
    Posts:
    163
    @awesomesaucelabs

    Hi, I just bought Piglet and it seems a great asset- thanks for all the work you've put into it!

    I'm running into an issue with glTF's of animated Point Clouds recorded using the iOS app Record3D which makes use of the iPhone's FaceID TrueDepth sensor, it exports zipped glTF's straight to Sketchfab I'm importing these zips into Unity just fine with Piglet, the imported glTF shows it has animations but there's nothing in the meshes folder - is this the expected behaviour?

    Thanks
     
  41. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Hi @wxxhrt!

    So far, Piglet only supports triangle meshes (mesh.primitive.type == TRIANGLES), and so far there is no support for point clouds (mesh.primitive.mode == POINTS) or lines (mesh.primitive.mode == LINES). That's probably the reason that your model is not showing up properly.

    I'm not sure how hard it would be to add support for point clouds, but next week I will be busy finishing the Piglet 1.3.3 release, and after that I've promised to work on linear rendering support, so it might be a while before I get around to working on it.

    In the meantime, no problem if you need a refund! Just send me an email to awesomesaucelabs (at gmail) and let me know the email address for your PayPal account. Also, I'll send you a DM when point clouds are working properly, whenever that happens.
     
  42. shikhrr

    shikhrr

    Joined:
    Nov 19, 2013
    Posts:
    68
    Just bought the plugin. It works as intended. How do I increase the emission intensity. The shader is URPMetallicRoughnessOpaque. I am using Unity 2021.2.0f1 (URP 12.1.0) on Windows 10. The emissive factor only allows changing color. I need something like Unity Lit shader which has a intensity slider for emission. Could it be because of linear color space which is not supported yet?
     
  43. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Hi @shikhrr!

    Yes, I am pretty sure it is because of Piglet's incorrect handling of linear color mode. It makes all the texture colors look too dark and it makes normal maps look way too shiny. The root of the problem is that I use
    UnityWebRequestTexture
    to load the textures, and that class (incorrectly) assumes that all textures are sRGB-encoded. (In other words,
    UnityWebRequestTexture
    lacks a
    linear
    parameter.) The fix is to undo
    UnityWebRequestTexture
    's color conversions inside of the Piglet shaders, by adding a Colorspace Conversion Node for each linear texture (e.g. normal maps).

    Currently, the only workaround I know is not using linear color mode :-/ In other words, set color space to
    Gamma
    under
     Edit -> Project Settings... -> Player -> PC, Mac & Linux Standalone -> Other Settings -> Color Space 
    . Also, for Editor glTF imports it is necessary to re-import the models in Gamma mode, since the textures get permanently baked as too dark/shiny when they are created in linear color mode.

    I know that this a big limitation and is hugely annoying, since using linear color mode is the right way to do things if your platform allows it. A few people have been pleading with me to get this fixed for a while now, and I do hear you! I'm going to be working on this issue after I publish the Piglet 1.3.3 release, which will be done very soon (likely next week).

    In the meantime, if you want a refund, that is totally reasonable! Just send an e-mail to "awesomesaucelabs" (at gmail), and let me know the e-mail address for your PayPal account.
     
    shikhrr likes this.
  44. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Piglet 1.3.3 released!

    Hi everyone :)

    I'm happy to announce the Piglet 1.3.3 release, which has been in the works for about 5 months now!

    Although this is a minor release, it has a few significant improvements:

    1. Major performance improvements for both runtime and Editor imports. For example, see the graph below comparing runtime imports using Piglet 1.3.2 and Piglet 1.3.3. Importing large glTF files in the Editor is also much faster now.

    2. Piglet now automatically imports .gltf/.glb/.zip files that have been saved under
    Assets
    from an external program (e.g. Blender!). Please note that you need to switch the application focus back to Unity (e.g. Alt-Tab) before the glTF (re)import gets triggered.

    3. Editor glTF imports now import textures correctly in linear rendering mode. (Previously, the imported texture colors were too dark/shiny.) I still need to implement the equivalent fixes for runtime glTF imports in linear mode, but I'm working on it!

    There are some other small bugfixes as well, but please see the Changelog in the manual if you are curious about those.

    Near-term Roadmap

    Issues that are the top of my priority list right now are:

    1. A permanent fix for Json.NET compile errors. I think this is probably the biggest pain point for new Piglet users. I've got a section in the manual about it now, but regardless it is really discouraging when users get compile errors immediately after installing the asset. Json.NET DLL conflicts have always been an issue, but recently it has gotten a lot worse because Unity 2020.3.10+ now installs their own copy of Json.NET by default in new projects.

    2. Proper support for linear rendering mode during runtime glTF imports (as mentioned above).

    3. Testing and official support for iOS. About a million people have asked me for this by now and it would surely improve my sales. I've got the necessary Mac Mini and iPhone hardware but I always seem to be firefighting other issues (e.g. 1 and 2 above).

    Shout-outs

    @Boemak: Because you requested the ability to save your glTF files directly under Assets and have them automatically imported by Piglet. It's been a long time since you requested it, but the capability is there now if you're still interested!

    Piglet Benchmarks (1.3.2 vs 1.3.3)

     
    shikhrr likes this.
  45. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    I forgot to mention:

    For those who are interested, Piglet is 50% off right now as part of the Black Friday sale. Sale ends on Dec 5th!
     
  46. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Piglet 1.3.5 released!

    Happy New Year, everyone :)

    I'm happy to announce the Piglet 1.3.5 release, which finally fixes glTF imports in linear rendering mode, for all usage scenarios: Editor imports and runtime imports, built-in rendering pipeline and URP.

    Previously, imports in linear mode would produce normal maps that were too shiny and texture colors that were too dark. (See below for an example screenshot.)

    This issue has been a dealbreaker for many people, and I've been steadily working towards a proper fix for many months, so I'm quite happy that it's fixed now!

    Near-term Roadmap

    Issues that are the top of my priority list right now are:

    1. A permanent fix for Json.NET compile errors. I think this is probably the biggest pain point for new Piglet users. I've got a section in the manual about it now, but regardless it is really discouraging when users get compile errors immediately after installing the asset. Json.NET DLL conflicts have always been an issue, but recently it has gotten a lot worse because Unity 2020.3.10+ now installs their own copy of Json.NET by default in new projects.

    2. Testing and official support for iOS. About a million people have asked me for this by now and it would surely improve my sales. I've got the necessary Mac Mini and iPhone hardware but I always seem to be busy with other issues. (Several users have already reported that Piglet works well on iOS, but I would like to familiarize myself with the iOS development processes before advertising official support.)

    Shout-outs

    @SFX_One @shikhrr: Because you asked about linear rendering support.

    Before-and-After Example of Linear Rendering Fix

     
    shikhrr likes this.
  47. DerrickBarra

    DerrickBarra

    Joined:
    Nov 19, 2013
    Posts:
    210
    @awesomesaucelabs Looks awesome! I believe our team is using Gamma color space, but we'll have to double-check.

    By the way, on our end, we're going to be spending some time this year to lower the size of our player's build size as small as possible (goal is under 10mb for Android/IOS builds, our WebGL is already at 8mb). This is to turn our player into a Google Instant App and Apple Appclip, so we'll have full benefits of a mobile app for ARFoundation support, launched silently when you click the iframe on a mobile device.

    Long story short, we're going to be heavily poking every package we use with a stick to see where we can shave some build size. I'll let you know if we find anything that can be optimized for build size on Piglet's end of things (most likely within the use of JSON.net I'm guessing).

    Anyways, cheers on the new year. Looking forward to your future updates.
     
  48. awesomesaucelabs

    awesomesaucelabs

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

    Nice to hear from you and Happy New Year to you too!

    Okay, I'll keep the build size issue in mind while I'm poking around with the JSON parsing stuff.

    In the long run, maybe I should switch to SimpleJson or JsonUtility instead of Json.NET, even though it would require a lot of refactoring. (And a lot of testing and profiling too, to make sure I didn't break anything or hurt the performance.)
     
    DerrickBarra likes this.
  49. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    I'm aware of the IL2CPP/stripping issues with Json.NET too, btw. (You mentioned those way back when.)
     
  50. awesomesaucelabs

    awesomesaucelabs

    Joined:
    Aug 6, 2019
    Posts:
    186
    Piglet 1.3.6 released!

    Hi everyone :)

    I'm happy to announce the release of Piglet 1.3.6!

    The main purpose of this release is to fix Json.NET-related errors once and for all. In previous versions, "duplicate assembly" errors would occur whenever Piglet was installed alongside another Unity asset that also included a copy of
    Newtonsoft.Json.dll
    , which was a common pain point for new users. Unfortunately, the problem got even worse in Unity 2020.3.10f1, when Unity started installing its own copy of
    Newtonsoft.Json.dll
    by default in new projects, via their "Newtonsoft Json" package.

    Starting with Piglet 1.3.6, I am now bundling a custom build of the Json.NET DLL (
    Assets/Piglet/Dependencies/Json.NET/Piglet.Newtonsoft.dll
    ) that does not conflict with Unity's "Newtonsoft Json" package, nor any other assets that use Json.NET. I accomplished this by forking the Newtonsoft.Json-for-Unity project and changing the namespace of all C# classes from
    Newtonsoft.Json
    ->
    Piglet.Newtonsoft.Json
    . (You access my fork of Newtonsoft.Json-for-Unity at
    https://github.com/AwesomesauceLabs/Newtonsoft.Json-for-Unity/tree/piglet)

    Another improvement in this release is that IL2CPP builds now work out-of-the-box for all target platforms and Unity versions. In previous versions, the stock version of
    Newtonsoft.Json.dll
    bundled with Piglet did not always work well with IL2CPP builds, for the reasons detailed in What even is AOT (from the Newtonsoft.Json-for-Unity wiki).

    In addition to the above, there are also some important bug fixes in Piglet 1.3.6 for multi-material/multi-primitive meshes, and for models that use the default material. Please see the Changelog for further details.

    Near-term Roadmap

    The next item on my TODO list is to add MacOS and iOS to Piglet's list of officially supported platforms. I have already been doing some testing on these platforms and so far everything has been working very well! It looks like I will not need to make any code changes to Piglet itself, although I plan to add some documentation and minor tweaks to the example PigletViewer app.

    Shout-outs

    @DerrickBarra:

    Are you still aiming to slim down your build sizes? Unfortunately, I don't think this release has any reduction in Piglet build sizes yet (nor should it be any worse), but I'm still interested in switching to JsonUtility in the long term. (I've decided against SimpleJson because it doesn't seem as battle-hardened nor performance-tuned as JsonUtility and Json.NET.)

    So far, the only downside I've found with JsonUtility is that it doesn't support custom user data very well (a.k.a. "Custom Properties", a.k.a. "glTF extras"), because it can't parse arbitrary JSON structures. But that is probably outweighed by the awesome simplicity and performance of the library.
     
    Last edited: Feb 17, 2022
    shikhrr and DerrickBarra like this.