Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

TriLib - Model Loading Package

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

  1. michalekmarcin

    michalekmarcin

    Joined:
    Mar 28, 2019
    Posts:
    5
    Hi @rickomax

    Can you check this fbx model in newest version? I just migrated to 2.0.13b (30 min ago) and I have problems with textures and animations in 2.0.13b. On 2.0.10b animation was fine, but also trilib can't load textures.

    This model works in 3D viewer application (windows) and in FBX Review from Autodesk.
     

    Attached Files:

  2. mj-3dqr

    mj-3dqr

    Joined:
    Mar 30, 2017
    Posts:
    11
    Hi @rickomax,

    we are playing around a bit with your new trilib version. We are currently testing the khronos sample models and are realy impressed about the current feature set. nice work!.

    but we also found a model which crashes our unity in editor mode (scripted import):
    https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/ToyCar

    maybe you can have a look on this files.

    (we are using unity 2019.4.19 and Trilib 2.0.13b)

    Thank you.
     
    Last edited: Feb 3, 2021
  3. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Your model has some issues, but I've managed to include the needed fixes in the upcoming update.
    You can test it at:
    https://ricardoreis.net/trilib/trilib2demo/modelviewer/
     
  4. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    I will check it out asap.
     
  5. theonerm2_unity

    theonerm2_unity

    Joined:
    Sep 7, 2018
    Posts:
    91
    Hello. I'm making a Game Maker type game and I want the player to be able to put in their own models with the rig and materials. Will this work for that?

    Edit. I bought it. But I haven't tested enough to see if it will fit into my project.Although it does load the model and the rig.
     
    Last edited: Feb 3, 2021
  6. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Thank you for the purchase. Count on me if you have questions or issues. There is an update coming out the next days, so if something doesnt work right, I would advice waiting two or three days.
     
  7. theonerm2_unity

    theonerm2_unity

    Joined:
    Sep 7, 2018
    Posts:
    91
    I have a quick question. How do I get a reference to the loaded gameobject and its children? RootGameObject is null. Instance is the gameobject the script is attached to. The gameobject I want a reference to is a child of the instance. When I try to do a foreach loop on it like this foreach (Transform child in instance.transform) to get my reference it just doesn't seem to work. I need to add a component to each child.

    Nevermind I coded a way to do what I wanted.
     
    Last edited: Feb 4, 2021
  8. Luedrin

    Luedrin

    Joined:
    Aug 21, 2018
    Posts:
    4
    I've sent u an email yesterday about my issue, I hope you received it well.
    I've also tried the models that don't work in the new demo u linked (https://ricardoreis.net/trilib/trilib2demo/modelviewer/), but i'm also receiving errors in that demo.

    Code (csharp):
    1. [Error] line 328:3 missing {CHARACTER, INTEGER, FLOAT, STRING} at '}'
    Code (csharp):
    1. [Error] line 405:1071 missing '}' at 'E'
    Code (csharp):
    1. [Error] TriLibCore.General.ContextualizedError`1[TriLibCore.AssetLoaderContext]: A contextualized error has occurred. ---> System.Exception: Property UVIndex for geometry not found.
    2.   at TriLibCore.Fbx.FBXProcessor.ProcessGeometryLayer (TriLibCore.Fbx.FBXNode layerElement, TriLibCore.Fbx.FBXLayerType layerType) [0x00000] in <00000000000000000000000000000000>:0
    3.    --- End of inner exception stack trace ---
    4. (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
    5.  
    6.  
    7.     _JS_Log_Dump (80abe77c-f2cf-4a4b-ab19-97cf3b416b61:8:49795)
    8.     wasm-stub
    9.     <?>.wasm-function[4340]
    10.     <?>.wasm-function[4336]
    11.     <?>.wasm-function[4333]
    12.     <?>.wasm-function[4328]
    13.     <?>.wasm-function[13850]
    14.     <?>.wasm-function[75790]
    15.     <?>.wasm-function[75792]
    16.     <?>.wasm-function[34431]
    17.     <?>.wasm-function[75987]
    18.     <?>.wasm-function[24982]
    19.     <?>.wasm-function[75780]
    20.     <?>.wasm-function[34481]
    21.     <?>.wasm-function[34480]
    22.     <?>.wasm-function[31764]
    23.     <?>.wasm-function[34260]
    24.     <?>.wasm-function[34263]
    25.     <?>.wasm-function[34262]
    26.     <?>.wasm-function[76549]
    27.     wasm-stub
    28.     dynCall_iiiiiiiii
    29.     (anonymous function) (80abe77c-f2cf-4a4b-ab19-97cf3b416b61:8:488670)
    30.     invoke_iiiiiiiii (80abe77c-f2cf-4a4b-ab19-97cf3b416b61:8:353877)
    31.     wasm-stub
    32.     <?>.wasm-function[34258]
    33.     <?>.wasm-function[34319]
    34.     <?>.wasm-function[24769]
    35.     <?>.wasm-function[67429]
    36.     <?>.wasm-function[22671]
    37.     <?>.wasm-function[76541]
    38.     wasm-stub
    39.     (anonymous function) (80abe77c-f2cf-4a4b-ab19-97cf3b416b61:8:486719)
    40.     invoke_iiiii (80abe77c-f2cf-4a4b-ab19-97cf3b416b61:8:349961)
    41.     <?>.wasm-function[76541]
    42.     <?>.wasm-function[71595]
    43.     <?>.wasm-function[70903]
    44.     <?>.wasm-function[4552]
    45.     <?>.wasm-function[4551]
    46.     <?>.wasm-function[8212]
    47.     <?>.wasm-function[8210]
    48.     <?>.wasm-function[8214]
    49.     <?>.wasm-function[8520]
    50.     <?>.wasm-function[11080]
    51.     <?>.wasm-function[10801]
    52.     <?>.wasm-function[10801]
    53.     <?>.wasm-function[10796]
    54.     <?>.wasm-function[10789]
    55.     <?>.wasm-function[76565]
    56.     wasm-stub
    57.     (anonymous function) (80abe77c-f2cf-4a4b-ab19-97cf3b416b61:8:498068)
    58.     browserIterationFunc (80abe77c-f2cf-4a4b-ab19-97cf3b416b61:8:182964)
    59.     runIter (80abe77c-f2cf-4a4b-ab19-97cf3b416b61:8:186029)
    60.     Browser_mainLoop_runner (80abe77c-f2cf-4a4b-ab19-97cf3b416b61:8:184494)
     
  9. IgorRazin

    IgorRazin

    Joined:
    Oct 11, 2014
    Posts:
    11
    It's always maps cutout material. Why?
     
  10. daniel-md

    daniel-md

    Joined:
    Jan 26, 2015
    Posts:
    5
    Hi @rickomax, first of all thank's a lot for your great asset!!

    When trying to import different models, I noticed a few things, especially about the metallic/roughness import from gltf-models:
    • when I use the Standard "UniversalRPMaterialMapper" created with the context menu, the "RoughnessFactor" of the gltf is returned from GetGenericFloatValue(GenericMaterialProperty.Glossiness) and then used as "Smoothness" Multiplier value in the Unity Material. Smoothness should actually be 1 - Roughness, right?
    • While Unity directly accepts a multiplier for smoothness, the "Metallic" multiplier of the Unity Material seems to be ignored as soon as a texture map is added to corresponding channel, while in the specification of GLTF the value should still be multiplied. I saw that you are using shaders to sort the color-channels of Metallic Textures - maybe a fix could be multiply the "MetallicFactor" to the corresponding channel there?
     
  11. timtreurniet

    timtreurniet

    Joined:
    Jan 29, 2021
    Posts:
    2
    Hi there! I have tried contacting through your website's contact form, just in case that didn't work:
    I am trying to load different animations from seperate FBX files at runtime. However, I do not know how to apply these animated rigs to the existing model (from a different FBX file loaded at runtime). It does look like your plugin allows for this, but I can't find how to do this in the docs. https://twitter.com/realrickomax/status/1182489418160103426
     
  12. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    I'm checking out the emails. Sorry about the delay.
     
  13. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    You can change the behavior by modifying the "Resources/Materials" from the pipeline you're using on TriLib package folders.
    TriLib creates two materials by default to simulate semi-transparent areas to write/read from the depth buffer. To disable this behavior, set your AssetLoaderOptions.AddSecondAlphaMaterial to false.
     
  14. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Hi!
    It does allow, but I've discovered recently that Unity won't allow creating humanoid/generic clips on runtime, so I'm working on a solution for this.
     
  15. unitydevstudio

    unitydevstudio

    Joined:
    Jun 24, 2017
    Posts:
    22
    Hi, @rickomax
    Did u resolve the Mac OS filepicker bug I've mentioned on the new Version 2.0.14b?
     
  16. IgorRazin

    IgorRazin

    Joined:
    Oct 11, 2014
    Posts:
    11
    No, it doesn't work. It's ALWAYS maps the cutout material (TriLibStandardAlphaCutout). There must be some secret.
     
  17. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    I have tested on my Mac Mini and got no issues at all with the player.

    I took some screenshots to show you, but I forgot to copy them to my Windows machine.

    Anyway, please update to the 2.0.14b version, and if you still get the errors, I can check them out via TeamViewer.
     
  18. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Did you set your AssetLoaderOptions.AddSecondAlphaMaterial to false?
     
  19. IgorRazin

    IgorRazin

    Joined:
    Oct 11, 2014
    Posts:
    11
    I updated, the behavior has not changed, always takes TriLibStandardAlphaCutout material. Maybe it's the model? Give me yours that you tested on. Just in case, Unity version 2020.1.3f1
     
  20. akbar74

    akbar74

    Joined:
    Nov 16, 2017
    Posts:
    20
    hi.
    when i load my asset there is some "missing object" in asset loader script.
    how can i found what are those asset?
     
  21. akbar74

    akbar74

    Joined:
    Nov 16, 2017
    Posts:
    20
    hi.
    the new version has some problem with fbx file and make crash on loading. I test it in the web demo too and demo says memory access out of range. but the previous version can load the fbx.
    is there something I can do to fix this problem or I should migrate to previous version?
     
  22. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Hi!
    Could you send me the model for testing?
    contato@ricardoreis.net
     
  23. IgorRazin

    IgorRazin

    Joined:
    Oct 11, 2014
    Posts:
    11
  24. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Sorry!
    I guess I will add an option to switch between cutout and alpha materials, so users don't have to change the TriLib material resources.
    I'm about to release an update and I will try to add this feature to the update.
     
  25. daniel-md

    daniel-md

    Joined:
    Jan 26, 2015
    Posts:
    5
    Hi @rickomax, a small feedback would be great, to understand if I'm on the right path or just misunderstood something... I didn't manage yet to let imported models materials look like they should
     
  26. akbar74

    akbar74

    Joined:
    Nov 16, 2017
    Posts:
    20
    Ive sent you the model.
    and as i said in the mail, when i change the "Enforce16BitsTextures" to true the model load successfully.
    now i have another problem and that is that trilib cant load the normall.
    the CheckNormalMapTexture in materialMapper cant recognize the normalMapTexturePropertyName.
    and when i change the propertyName manully to "BumpTex" i get the the error with this details :

    " Graphics.CopyTexture called with mismatching texture data sizes, perhaps formats are incompatible? (srcsize=2796200 dstsize=1398100) "
     
  27. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Hi!

    Would be better if you could send me the model you're trying to load so I can compare the results with some GLTF viewers.

    I've changed some GLTF textures conversion code in the latest update, but I could be missing something.
     
  28. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Upcoming TriLib update (2.0.15) changelog:
    -Added the LoadTexturesAsSRGB loader option to load textures as sRGB (enabled by default).
    -Added LODScreenRelativeTransitionHeightBase to set the initial relative transition height when creating LOD Groups.
    -Fixed PLY binary reader.
    -Fixed headless mode Material Mappers inclusion (You can set the material mapper via the -trilib_mappers command line parameter).
    -Fixed linear colorspace texture issues.
    -Fixed avatar root position issues.
    -Fixed LOD Groups creation.
    -Fixed FBX accessors out-of-bounds bug (Some FBX files contains invalid data, which TriLib ignores now).
    -Fixed FBX animation start-time regression bug.
    -Fixed HDRP material mapper checking name.
    -Fixed HDRP mask textures creation.
    -Changed FixNormalMaps loader option behavior. Now it does the normal map to use the ABBR channel scheme instead of the RGBA.
    -Deprecated AssetLoaderOptions.AddSecondAlphaMaterial and AssetLoaderOptions.UseAlphaMaterials settings in flavor of adding the AlphaMaterialMode setting.
    -Deprecated AssetLoaderOptions.Enforce16BitsTextures. Now all textures are loaded using their original bit-depth.
    -Deprecated AssetLoaderOptions.IndexFormat. Now All meshes are created with 32 bits indices.
    -Added TRILIB_USE_UNITY_TEXTURE_LOADER compiler directive to use Unity internal image loader instead of stb_image.
    -Added tangents loading to GLTF meshes.
    -Added FbxReader.PivotMode to change how TriLib handles FBX mesh pivots (Experimental).
     
    Bartolomeus755 likes this.
  29. poolts

    poolts

    Joined:
    Aug 9, 2012
    Posts:
    113
    GC_Issue_TrilibObjLoader.png

    Hi Ricko,

    We've had FBX loading seamlessly loading via Trilib for a while now, but we've just moved our obj loading to trilib 2 and load times have significantly increased.

    I've posted a screenshot of the profiler and I can see the GC.alloc is very high. Any ideas why the GC would be taking up so much resource?

    Thanks.
     
  30. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Hi!

    Could you send the OBJ file you're trying to load to contato@ricardoreis.net?

    I can check out what is causing the memory spyke.
     
  31. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    29
    I just tried out the latest TriLib version but reading glb files with alpha != 1 is loaded fully opaque.
    Tried "Cutout" and also "Transparent" modes.

    Ah and by the way: There are no onMaterialsLoaded callback parameters in the AssetLoader.LoadModelFromStreamNoThread() method (and methods internally using this)

    Thanks!
     
  32. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    There is a beta update with transparent material fixes. I'll PM you.

    Regarding the "onMaterialsLoaded" callback, there isn't such a thing when you do synchronous loading because the models are loaded linearly. You should have all the model data after the loading method call.
     
  33. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    29
    Thanks for this quick beta fix!
    I think though this was also some wrong interpretation of blender glb material export from my side.
    Seems the "Alpha" value on the principled BSDF Shader does not get exported but the alpha channel of the color itself :confused:

    You are right with the onMaterialLoaded. I just used the result context of the synchronous method and used this for my 'onMaterialsLoaded'. :) thanks for the hint!
     
  34. chrpetry

    chrpetry

    Joined:
    Mar 7, 2018
    Posts:
    29
    Oh god... Blender changed the alpha value behaviour of GLTF/GLB exports somwhere between 2.83 and 2.92.
    Before you needed to set the base color a channel. From 2.9 onwards the "Alpha" of the principled BSDF Shader is used.
    Just updated Blender and wondered... :rolleyes:
     
  35. look001

    look001

    Joined:
    Mar 23, 2017
    Posts:
    65
    Is there a function to check if an extension is supported like in trilib 1.0?
    Is it possible to get a view in the the source code for TriLibCore?
    Thank you for the new version
     
    Last edited: Mar 1, 2021
  36. yacine93

    yacine93

    Joined:
    Nov 3, 2020
    Posts:
    3
    Hello,
    does the GenerateColliders option function work?
    Trilib v :2.0.15
     
    Last edited: Mar 3, 2021
  37. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Hi!
    The source code for pre-compiled libraries is not available yet.
    The TriLib 1.0 source is available, just send me your GitHub username by PM or e-mail (contato@ricardoreis.net).
    If you need any assistance with TriLib 2.0, just e-mail me.
     
  38. kwsuzuki

    kwsuzuki

    Joined:
    Dec 9, 2014
    Posts:
    1
    Hi,
    I'm using trilib2 in my HoloLens2 app, and after updating from 2.0.11 to 2.0.15, loading FBX files became very slow.
    It takes more than 20 times longer than with 2.0.11.
    It loads fine in Unity Editor and the PC build, but it is slow in HoloLens2.
    Is there any way to fix this problem?
    Thanks!
     
  39. daniel-md

    daniel-md

    Joined:
    Jan 26, 2015
    Posts:
    5
    Sure, let's take for example the "MetalRoughSpheres" from the official khronos samples repository (https://github.com/KhronosGroup/glTF-Sample-Models) which can be opened in their official viewer (http://gltf.ux3d.io/) and look like this:
    metalroughness-khronos.jpg

    There are two versions of it, one with Textures for the Metal/Roughness Parameters, the other one with pure numeric parameters.

    Here's how the first version, with textures, looks like when opened in Trilib (Unity 2020.2.2) with the same environment, perfectly correct:
    metalroughness-trilib-withtex.jpg

    However, when opening the version with pure numeric parameters (which should look exactly the same) in trilib, it looks like this: metalroughness-trilib-notex.jpg

    As you can see, in trilib:
    - the numerical roughness factor is inverted
    - the numerical metalness factor is ignored

    I'm not sure this can be solved without writing a custom shader (because unitys standard shader ignores the metalness-factor by default as soon as a texture is applied), but I would think it is rather important, because all gltf-models using these paramters (e.g. most of sketchfab-models) will be rendered wrong otherwise.

    [EDIT]: I used the newest Trilib version 2.0.15 for testing
     
  40. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    I don't have the device for testing, but I will profile it on UWP.
     
  41. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Important: TriLib 2.0.15b causes compilation issues when building Unity Player. A hotfix has been sent to Asset Store. Sorry for the inconvenience!
     
  42. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Hi!

    TriLib uses a fallback where it generates a tiny texture containing the roughness value when no roughness texture is supplied, so it can work with the Standard shaders.

    I will check out this issue.
     
  43. LR-Developer

    LR-Developer

    Joined:
    May 5, 2017
    Posts:
    109
    Hello,

    I upgraded to the latest version with package manager.

    When I run my program and load my glb files they are loading and after that I see them for just a moment, then they are gone! If I take a look in the editor they cannot be found, they seem to delete themselves after they loaded completly... that did not happen before.

    I load GLB files from disk... Unity 2020.1.8

    upload_2021-3-9_10-50-44.png

    Code (CSharp):
    1.         private void DownloadDragModel(string uriString, GameObject downloadGo)
    2.         {
    3.             var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
    4.             //assetLoaderOptions.UseFileScale = false;
    5.             AssetLoader.LoadModelFromFile(
    6.                 uriString,
    7.                 OnModelLoad,
    8.                 OnMaterialsLoad,
    9.                 downloadGo.GetComponent<DownloadPreview>().OnProgress,
    10.                 downloadGo.GetComponent<DownloadPreview>().OnError,
    11.                 downloadGo,
    12.                 assetLoaderOptions);
    13.         }
    Thanks for the support!
     
    Last edited: Mar 9, 2021
  44. LR-Developer

    LR-Developer

    Joined:
    May 5, 2017
    Posts:
    109
    Deleting everything and re-importing TriLib seems to help. Now it is working again.
     
    rickomax likes this.
  45. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Hi!
    I have made some fixes into my working-version and it is now generating the textures correctly for the non-texture metal spheres version:



    The generated textures are tiny and are used to mantain compatibility with the standard shaders.

    I will include this fix in the upcoming update.
     
  46. daniel-md

    daniel-md

    Joined:
    Jan 26, 2015
    Posts:
    5
    That's great, thanks a lot for the quick fix!! :)

    Sidenote: i think there could be a case left where your current approach might not work: when the the gltf material has a metallic texture AND a scaling factor (which then should be multiplied to the whole texture). But this is much less common and not so urgent from my point of of view. :)
     
  47. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Just fixed the Android/UWP breaking issues. Will include these in the upcoming update.
     
  48. kamihiro74

    kamihiro74

    Joined:
    May 15, 2013
    Posts:
    20
    Hi, Trying to load the PLY file by using the sample scene "LoadMdelFromURL."
    it looks like loading something but after completed the loading, nothing shows up.
    any solution for this ?

    Unity 2019.4.21f1
    Mac
     
  49. rickomax

    rickomax

    Joined:
    Jun 11, 2013
    Posts:
    542
    Hi!

    Does the same model works when loading from the local file system?
     
  50. kamihiro74

    kamihiro74

    Joined:
    May 15, 2013
    Posts:
    20
    I changed the PLY file and it works for offline and online.
    Sorry for making such a fuss..
     
unityunity