Search Unity

TriLib - Model Loading Package

Discussion in 'Assets and Asset Store' started by rickomax, Jun 21, 2017.

  1. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Yes, that's a good idea, thanks- I'll try importing a model with only Import Materials checked like in your example and hope all the materials are included.
     
  2. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!

    It seems to be related to this specific model then. Have you tried out with TriLib 2.1.2?
     
  3. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    I've added it to my work-list and will check it out soon.
     
  4. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    Could you try it again with TriLib 2.1.2?
    If you can't load it with this version, I would suggest you sending me the model by e-mail for testing: contato@ricardoreis.net
     
  5. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    TriLib has to do a lot of stuff on the main Thread because of Unity's lack of Thread-safe methods.
    That will always cause noticeable slowdowns.
    I would have to rewrite TriLib from scratch to use the job system and try mitigating this issue.
     
  6. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    TriLib uses the original model orientation when loading.
    There is no way to rotate it when loading yet, but I will write down this suggestion.
     
  7. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    I should really check your models to understand what is happening.
    Could you please send the models you can't load to contato@ricardoreis.net?
     
  8. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    You can safely remove the Newtonsoft.Json files from your TriLib folder if you have them on your project.
     
  9. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    I'm working on this item right now and it should be included in TriLib 2.1.3
     
  10. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    Could you try loading it with TriLib 2.1.2 (latest version)?
     
    maxOculavis likes this.
  11. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    TriLib 2.1.2 exposes the AssetLoaderContext.CancellationTokenSource field that you can use to cancel your model loading. Just keep in mind that you might track your cancellation request as TriLib might not be able to cancel your loading right in time
     
  12. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    What is your target platform?
    Could you send the model you're trying to load to contato@ricardoreis.net?
     
  13. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    There is no way to access this data yet, but it is something I'm going to allow, probably in the next update.
    It is on my to-do list:
    Public | Trello
     
  14. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    This issue has been fixed in the 2.1.2 update
     
    Lex4art likes this.
  15. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    When the IContextualizedError.Context field is null, which means your error has been generated from a code that can't access it (probably a code on your end, but I can't be sure without checking your code)
     
  16. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    The "mesh-splitting" feature will be added in the upcoming update:
    Public | Trello
     
  17. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    There is no ETA for this feature yet
     
  18. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    You would need a custom TextureMapper in order to do that.
    Please refer to the "SimpleCustomAssetLoader" sample, it shows how you can implement your own TextureMapper and ExternalDataMapper
     
  19. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    Does this issue still persist in the 2.1.2 update?
     
  20. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    Could you send the model you're trying to load to contato@ricardoreis.net so I could check it out?
     
  21. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    I will check out this model, adding it to my work-list
     
  22. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    I've added this feature to the 2.1.2 update.
    You can use the AssetLoaderContext.CancellationTokenSource to cancel your model loading. Keep in mind you have to track the cancellation yourself as TriLib might not be able to stop the loading at the same time you request it to
     
    garrido86 likes this.
  23. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    Actually, not.
    I might drop the Dispatcher usage on a future update, but that would require a lot of refactoring
     
    salvolannister likes this.
  24. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    Please check my answer to garrido86 above
     
  25. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    Your item is in my work-list and I'm working on it now
     
  26. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Material mappers are used to converting between native file format material properties and textures into properties and textures the scripted rendering pipeline can understand
     
    Lex4art likes this.
  27. flecheria

    flecheria

    Joined:
    Apr 25, 2019
    Posts:
    17

    Attached Files:

  28. flecheria

    flecheria

    Joined:
    Apr 25, 2019
    Posts:
    17
    OK. it seems that Unity 2019.3.18 doesn't update the package manager to version 2.1.2 but it seems blocked to 2.0.11.
    I moved to Unity 2020.3.17 and in this way at least I can update to Trilib 2.1.2
     
  29. flecheria

    flecheria

    Joined:
    Apr 25, 2019
    Posts:
    17
    Ok. It seems solved on 2020.3.17, but the support for Unity 2019.4 it seems have some problems
     
  30. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!

    I will test it on this Unity version as soon as possible.
    What are the problems you're getting?
     
  31. flecheria

    flecheria

    Joined:
    Apr 25, 2019
    Posts:
    17
    Thanks Ricardo
    the problem was specifically with iOS, see the image on my first message. It seems that StandardFileBrowser has some issue.
    In Unity 2020.3.17 I didn't have this error. It works as supposed to do for all platform.
     
  32. vaioj10jp

    vaioj10jp

    Joined:
    Aug 23, 2021
    Posts:
    6
    Hi! @rickomax

    I am reading an fbx file using TriLib 2.1.1, but there are some parts that are not transparent.
    Is it necessary to set it in a script or the like?
    thank you

    Code (CSharp):
    1.         string filepath = System.IO.Path.Combine(FileDirectoryPath(), a_FileName);
    2.  
    3.         AssetLoaderOptions assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
    4.  
    5.         assetLoaderOptions.AlphaMaterialMode = AlphaMaterialMode.Transparent;
    6.  
    7.         AssetLoader.LoadModelFromFile(filepath, OnLoad, OnMaterialsLoad, OnProgress, OnError, null, assetLoaderOptions);
    8.  
     

    Attached Files:

  33. pr90s

    pr90s

    Joined:
    Oct 26, 2018
    Posts:
    5
    Hi All,

    Has anyone tried to load multiple fbx files to unity using "LoadModelFromUri"? I need to load multiple fbx models from a server one after the other or all at once. Is there any correct way to do this without crashing Unity?
     
  34. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    973
    Since updating from 2.0.17 to. 2.1.1 and then 2.1.2 - I started to get this error in Edlitor
    Assertion failed on expression: 'mipLevel < m_MipCount'
    The app also crashes on Android, works only in Editor and WebGL.

    What can be a reason and how to fix?
     
    Last edited: Oct 8, 2021
  35. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    Try changing your AssetLoaderOptions.AlphaMaterialMode to a suitable value. This option controls how TriLib handles transparent materials.
     
  36. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    I will work on a sample on how to do that soon.
     
    pr90s likes this.
  37. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Hi!
    It is possible your textures do not have enough resolution to generate mipmaps.
    I remember I've fixed that, but anyway, could you send me your model for testing to contato@ricardoreis.net?
     
  38. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    I will check this out as soon as possible.
     
  39. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    973
  40. vaioj10jp

    vaioj10jp

    Joined:
    Aug 23, 2021
    Posts:
    6
    Hi @rickomax
    I was able to make the original file of fbx transparent by changing the transparency mode with blender.
    Thank you very much.
     
    Last edited: Oct 7, 2021
  41. pr90s

    pr90s

    Joined:
    Oct 26, 2018
    Posts:
    5
    Thanks @rickomax
    Looking forward to that sample.
     
  42. Chopium

    Chopium

    Joined:
    Jun 15, 2015
    Posts:
    19
    Since 2.0 this package has worked super well for us!

    I was wondering why animations stopped autoplaying on load in 2.0, but eventually figured out from the assetviewer sample I can add a check for animation components in my AssetDownloader component and play a clip if available.

    It could be worth pointing this out in the migration post or reference materials! I assumed animations not autoplaying was an issue with my AssetLoaderOptions, because I remember autoplay being there in v1.
     
  43. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    973
    I Unity Editor I am getting this:
    Assertion failed on expression: 'mipLevel < m_MipCount'

    while Android Logcat reports this:
    2021.10.08 02:26:19.133 21369 21427 Error Unity Could not allocate memory: System out of memory!
    2021.10.08 02:26:19.133 21369 21427 Error Unity Trying to allocate: 117330404B with 16 alignment. MemoryLabel: Texture
    2021.10.08 02:26:19.133 21369 21427 Error Unity Allocation happened at: Line:70 in
    2021.10.08 02:26:19.133 21369 21427 Error Unity Memory overview
    2021.10.08 02:26:19.133 21369 21427 Error Unity
    2021.10.08 02:26:19.133 21369 21427 Error Unity [ ALLOC_TEMP_THREAD ] used: 32768B | peak: 0B | reserved: 5898240B
    2021.10.08 02:26:19.133 21369 21427 Error Unity [ ALLOC_TEMP_JOB_1_FRAME ] used: 0B | peak: 0B | reserved: 1048576B
    2021.10.08 02:26:19.133 21369 21427 Error Unity [ ALLOC_TEMP_JOB_2_FRAMES ] used: 0B | peak: 0B | reserved: 1048576B
    2021.10.08 02:26:19.133 21369 21427 Error Unity [ ALLOC_TEMP_JOB_4_FRAMES ] used: 0B | peak: 0B | reserved: 2097152B
    2021.10.08 02:26:19.133 21369 21427 Error Unity [ ALLOC_TEMP_JOB_ASYNC ] used: 0B | peak: 0B | reserved: 26214400B
    2021.10.08 02:26:19.133 21369 21427 Error Unity [ ALLOC_DEFAULT ] used: 183717244B | peak: 0B | reserved: 218112000B
    2021.10.08 02:26:19.133 21369 21427 Error Unity [ ALLOC_GFX ] used: 769688204B | peak: 0B | reserved: 929218560B
    2021.10.08 02:26:19.133 21369 21427 Error Unity [ ALLOC_CACHEOBJECTS ] used: 263636400B | peak: 0B | reserved: 283115520B
    2021.10.08 02:26:19.133 21369 21427 Error Unity [ ALLOC_TYPETREE ] used: 5232B | peak: 0B | reserved: 17825792B

    2021.10.08 02:26:19.133 21369 21427 Error Unity

    and the app crashes.

    It was working on 2.0.17, but I was getting other artifacts.
    Do you have an archive with older versions somewhere, so I could test and find a version, where it works with minimal artifacts?

    How could I get v. 2.1.0 (before mip-map bug fix - according to changelog - I guess this fix might make the app unusable for my fbx files ) ?
     
    Last edited: Oct 8, 2021
  44. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Hey @rickomax sorry for the late reply, I sincerely appreciate your responses to my previous questions, I ended up figuring out a lot of the issues on my end.

    I had another question that maybe you can help me with.
    Is there a way to have more than one humanoid rig mapper in the AssetLoaderOptions? I think it would increase the chances of finding a rig if I allow it to check if "Right Starts with Left" AND "Right Ends with Left", etc.

    Or maybe, can I add "Right CONTAINS Left"? If so, How can I add that?
     
  45. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    This happens because texture resolutions are not power of two and you're compressing them. I'm working on a fix for it.
     
  46. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Will add this loader option!
     
  47. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    973
    Thank you.
    Means I can also switch the texture compression off in Asset Loader Options to get rid of the problem temporarily?
     
  48. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    I've added the "StringComparisonMode.LeftContainsRight" and "StringComparisonMode.RightContainsLeft" modes and it will be included in the upcoming update.
     
    JudahMantell likes this.
  49. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    683
    Yep. Just change your
    AssetLoaderOptions.TextureCompressionQuality
    to
    TextureCompressionQuality.NoCompression
     
  50. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    I am trying to save an AssetLoaderOptions scriptable object created at runtime to Json, but keep getting "-instanceID ...".
    I am using JsonUtility, which I believe is supposed to be able to save ScriptableObjects.
    Is there any way around this, besides creating my own class and writing/reading the individual values to a new AssetLoaderOptions instance?
    Thanks!

    EDIT: My current solution is to save the assetloader as a json string and that is a variable inside another bigger json object. Ideally, I could just have it be a variable without the second layer of Json serialization. But this may be a Unity limitation, rather than a trilib one.
     
    Last edited: Oct 10, 2021