Search Unity

SimpleLOD user support thread

Discussion in 'Assets and Asset Store' started by Orbcreation, Nov 25, 2014.

  1. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    richard (thingy) orbcreation (dot) com
     
  2. Walton

    Walton

    Joined:
    May 2, 2015
    Posts:
    78
  3. Walton

    Walton

    Joined:
    May 2, 2015
    Posts:
    78
  4. Wenceslao

    Wenceslao

    Joined:
    Feb 7, 2009
    Posts:
    142
    So I was having an issue with Simple LOD where as I created LODs over and over again, testing settings, the LODMeshes folder was growing out of control. I found 3 new LOD models every time I hit the button. (I'd get LOD_1, 2, 3. Next time I'd get 4, 5, 6 then 7, 8, 9, etc). I would rather the LODs I remake just replace the old ones. Is there a reason it was coded to create unique ones every single time?

    So I looked at the code and replaced the call for MeshPath with just a simple string assembly instead of AssetDatabase.GenerateUniqueAssetPath(). Now when I create LODs, change settings and click the 2a button, it just replaces LOD1, LOD2 and LOD3.

    Code (CSharp):
    1.     private string CreateLODSwitcherWithMeshes(GameObject aGo) {
    2.         if(aGo == null) return "No gameObject selected";
    3.         string path = StoragePathUsing1stMeshAndSubPath(aGo, "LODMeshes");
    4.         if(path != null) {
    5.             float[] useCompressions = new float[nrOfLevels];
    6.             Mesh[] meshes = null;
    7.             MakeBackup(aGo, true);
    8.             for(int i=0;i<nrOfLevels;i++) useCompressions[i] = compression[i];
    9.             try {
    10.                 meshes = aGo.SetUpLODLevelsWithLODSwitcher(GetDftLodScreenSizes(nrOfLevels), useCompressions, recalcNormals, smallObjectsValue, useValueForProtectNormals, useValueForProtectUvs, useValueForProtectSubMeshesAndSharpEdges, useValueForProtectBigTriangles, useValueForNrOfSteps);
    11.             } catch(Exception e) {
    12.                 Debug.LogError(e);
    13.                 return e.Message;
    14.             }
    15.             if(meshes != null) {
    16.                 string sizeStr = "";
    17.                 sizeStr = "LOD 0: " + meshes[0].vertexCount + " vertices, " + (meshes[0].triangles.Length / 3) + " triangles";
    18.                 path = path + "/" + aGo.name + "_LOD";
    19.                 for(int i=1;i<meshes.Length;i++) {
    20.                     sizeStr = sizeStr + "\nLOD " + i +": " + meshes[i].vertexCount + " vertices, " + (meshes[i].triangles.Length / 3) + " triangles";
    21.                     if(meshes[i] != null && meshes[i].vertexCount > 0) {
    22.                         //string meshPath = AssetDatabase.GenerateUniqueAssetPath(path + i + ".asset");
    23.                         string meshPath = path + i + ".asset";
    24.                         AssetDatabase.CreateAsset(meshes[i], meshPath);
    25.                         AssetDatabase.SaveAssets();
    26.                     }
    27.                 }
    28.                 Resources.UnloadUnusedAssets();
    29.                 return "Finished! LOD meshes were saved under "+path+"[1..."+meshes.Length+"].\n" + sizeStr;
    30.             }
    31.         }
    32.         return "No mesh found in gameobject";
    33.     }
     
    ZenMicro and hopeful like this.
  5. Wenceslao

    Wenceslao

    Joined:
    Feb 7, 2009
    Posts:
    142
    I also added [CanEditMultipleObjects] LODSwitcher_Editor so that I can mass edit the LOD Screen Sizes for multiple objects.

    Code (CSharp):
    1. [CustomEditor(typeof(LODSwitcher))]
    2. [CanEditMultipleObjects]
    3. public class LODSwitcher_Editor : Editor {
    4. ...
    5. }
    In case anyone is curious I'm trying out Simple LOD to take tree assets over a large area and build LODs for them.
     
  6. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    That's great Wenceslao! The reason for the flooding of that folder is that I am careful. I'd prefer the way you do it now myself as well, but for a commercial product I can't risk to write over existing files. Very good that you altered the code yourself, that's the whole point of selling the code instead of some black box DLL.
     
  7. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    I finally got around to using this on my project. So far, I'm very impressed. Only issue I'm running into is that the texture Atlas tool doesn't seem to process my normal maps into a separate texture file. As such, I'm left with only a detail texture and nothing else. I notice that when I click the "make readable" button in the texture Atlas screen, it makes the normal maps pink and they are then removed from the Atlas creation process. Is there something I'm doing wrong?
     
  8. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Actually ... never mind. Use error. Is there a reason the Atlas texture maker makes normal maps pink?
     
  9. Wenceslao

    Wenceslao

    Joined:
    Feb 7, 2009
    Posts:
    142
    @Orbcreation, I understand. Data loss is the worst sin any application can commit. Thanks for the wonderful product. The code is written well and was easy to read and modify. I'm using simple LOD to do a large low poly environment with a long view distance. I want to make lots of low poly assets even smaller at a long distance. I'll post my results once I have some!
     
  10. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,685
    It seems to me you could include the "LOD overwrite option" as box that is unchecked by default. I suppose for some people it would be important to keep all those LODs, but for me they're always throwaways. All I need is the original model.
     
  11. Wenceslao

    Wenceslao

    Joined:
    Feb 7, 2009
    Posts:
    142
    I'm having issues with Unity 5.1.1 where each time I open Unity the Simple LOD window does not restore. It's just a blank window that if I touch throws the "Invalid editor window UnityEditor.FallbackEditorWindow" error. Is there a script compilation order I can change in order to keep my window? Not a major issue, but semi-annoying.
     
  12. BTables

    BTables

    Joined:
    Jan 18, 2014
    Posts:
    61
    Hi there, getting an issue when trying to do a runtime skinned mesh merge. Running latest unity 5, non optimized gameobjects.

    Any ideas how to fix this?

    Also is it currently possible to merge optimized skinned meshes?

    Code (CSharp):
    1. Array index is out of range.   at OrbCreationExtensions.GameObjectExtensions.MergeMeshInto (UnityEngine.Mesh fromMesh, UnityEngine.Transform[] fromBones, UnityEngine.Material[] fromMaterials, System.Collections.Generic.List`1 vertices, System.Collections.Generic.List`1 normals, System.Collections.Generic.List`1 uv1s, System.Collections.Generic.List`1 uv2s, System.Collections.Generic.List`1 uv3s, System.Collections.Generic.List`1 uv4s, System.Collections.Generic.List`1 colors32, System.Collections.Generic.List`1 boneWeights, System.Collections.Generic.List`1 bones, System.Collections.Generic.List`1 bindposes, System.Collections.Generic.Dictionary`2 subMeshes, Boolean usesNegativeScale, Vector4 lightmapScaleOffset, UnityEngine.Transform fromTransform, UnityEngine.Transform topTransform, System.String submeshName, System.String[] skipSubmeshNames) [0x0019f] in D:\Code\idlehands\UnityProject\Assets\SimpleLOD\Extensions\GameObjectExtensions.cs:1189
    2.   at OrbCreationExtensions.GameObjectExtensions.CombineMeshes (UnityEngine.GameObject aGO, System.String[] skipSubmeshNames, Boolean makeNewGameObjectWhenRendererPresent) [0x003de] in D:\Code\idlehands\UnityProject\Assets\SimpleLOD\Extensions\GameObjectExtensions.cs:473
    3.   at CharacterMeshManager.BakeMesh () [0x0004a] in D:\Code\idlehands\UnityProject\Assets\Scripts\Core\CharacterMeshManager.cs:128
     
  13. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    257
    Testing Unity 5.2.0b1 and Simple LOD. I'm getting the following error:

    Assets/SimpleLOD/Extensions/MeshExtensions.cs(308,30): error CS0121: The call is ambiguous between the following methods or properties: `UnityEngine.Mesh.SetTriangles(System.Collections.Generic.List<int>, int)' and `UnityEngine.Mesh.SetTriangles(int[], int)'

    It is failing on this statement (line 308):

    mesh.SetTriangles(null, mesh.subMeshCount-1);

    EDIT: managed to get past this by replacing null with new List<int>()
     
    Last edited: Jul 10, 2015
    sathya likes this.
  14. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    Hi,

    the mesh reduction works really well.
    I got a question about the LODSwitcher though: it seems to work great when only moving the camera around.
    But what about changing the FOV?
    It doesn't seem to affect anything ... must I call ComputeDimensions everytime I change it?

    Thanks!
     
  15. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,685
    BTW, remember devs don't always get notification of your post in the forums. If you need emergency support, contact them by PM ( @Orbcreation ) or by their support email.
     
  16. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    Thanks for your comment, I wrote Orbcreation on July 13th but havent heard back. Vacation time I guess ... we'll probably go with the LOD-feature of Unity pro. It would still be good to know some day or for the others =)
     
  17. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I came here to post the same thing. You should not replace it with a new list, you should replace it with:

    mesh.SetTriangles((int[])null, mesh.subMeshCount-1);

    @Orbcreation - As a heads up, Unity 5.2 adds new overloads to a lot of mesh methods which can now take array's or List<>'s, so any code that passed nulls will now have to cast the null or it will fail to compile because of ambiguous calls. There were two instances of this in SimpleLOD that I had to fix.
     
    hopeful likes this.
  18. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    Sorry people, I have been on vacation. Hence the delayed feedback.

    @shcipwa Your error seems to have something to do with the bones. Unfortunately I have already made some edits in the files and line 1189 now points to something else. So I downloaded the somewhat older version that is on the asset store, but there 1189 points to a line with only a closing brace. Are you using the latest version? Or could you mail me your model?

    @mr_zog Yes, sorry about that. The LODSwitcher tries to have a super small performance impact. It makes some pixel size computations beforehand, so it can make a very quick check in the Update() function. As a result, changing the FOV doesn't influence the LOD level, unless you force the LODSwitcher to recompute. As an alternative you could use Unity's LODGroup or get QuickLod from the asset store

    @makeshiftwings Thanks for finding that out. Will upload a new version that is fully up to date with 5.1 and casts these null values today.
     
    Last edited: Aug 11, 2015
  19. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    Hi and thanks for the confirmation.
    In fact we ended up using Unity's LOD Group and it works fine with the meshes generated with your plugin.
     
  20. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi Guys!

    I'm using Simple LoD for creating LoDs for props in a scene, they are static and would use Lightmaps, how you do to make the LoDs get the lightmap from the original model, or better i ask, how i do to properly have the ligthmaps on all the LoDs generated? I feel like it is a dumb question, but wanted to know the best approach.

    Thanks in advance!

    Cheers!

    Rhod,
     
  21. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    Not a dumb question at all. Using SimpleLOD to combine meshes takes some careful planning, because your lightmaps will go crazy if you dont.

    It would be too much to cover it in this forum reply, but I have written a documentation page about this. You can find it here: http://orbcreation.com/orbcreation/docu.orb?1233
    If it is not clear, or some questions still remain, don't hesitate to ask.

    Mind you this applies to merging meshes. Merging multiple meshes into 1 breaks the lightmap, because of the lightmap offsets. But once the meshes are merged and the lightmap is ok, you can knock yourself out on the decimation and generating LOD levels. Because that step has no effect on the lightmaps anymore.
     
  22. Tom_Timothy

    Tom_Timothy

    Joined:
    Nov 21, 2013
    Posts:
    132
    Had a question are models have children that we turn on and off so I can not combine the children into the model as a whole. Is it possible to make lod for children and the main mesh using your system. Would like to know before i purchase.
     
  23. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    Hey @Tom_Timothy You can open a simpleLOD panel where you can specify which children you want to merge. This way you can merge or not merge whatever you like.
     
  24. Tom_Timothy

    Tom_Timothy

    Joined:
    Nov 21, 2013
    Posts:
    132
    But can i make lod for the children pieces as are models average 45 children that turn on and off?
     
  25. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    Do you think your asset will help with my issue? Pretty sure I need to simplify my mesh to get rid of moire.


    Also see the issue

    pw unity

    too_many_lines.jpg
     
  26. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    Yeah, sure. You can select any gameobject or child of a gameobject and either merge meshes underneath or decimate a mesh or create lod levels for it.
     
  27. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    @eco_bach I don't know if it will help. just give it a try and let us know. It's not like your $30 will be wasted money if it doesn't and neither is it an amount that will make you starve you to death. And if it doesn't help you with your moire problem and you can't use it for any of your other models, just let me know and you will get your money back.
     
  28. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello guys,

    Would this works on XBOX ONE?

    Regards,
    Carlos
     
  29. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    @strongbox3d SimpleLOD affects the mesh only, so no worries there. But if you start making atlases as well, you shoud make sure the texture format is ok for your target platform.
     
  30. andyastro

    andyastro

    Joined:
    Sep 17, 2015
    Posts:
    16
    Hi, I have a very specific problem to handle in my application and someone just suggested your asset as a possible solution, therefore I came to ask you a quick question. Would it be possible to use your asset to erase inner parts of meshes? I have an application where big objects are generated procedurally, by aggregating other small prefab meshes.

    However, in the end, although I got fairly satisfactory results, I end up with plenty of vertices and faces inside the final object, due to the random combination of the smaller constituent blocks that make the final object. I wonder if your tool would help me deleting those? What I am describing is what some 3D editors allow, like:http://meshlabstuff.blogspot.com/2009/04/how-to-remove-internal-faces-with.html

    Thanks anyway and congrats for the great asset.
     
  31. djgriff

    djgriff

    Joined:
    May 29, 2014
    Posts:
    279
    Hi guys, not sure if this is off topic or not, Basically i have bought this asset which is cool. but i am struggling to find the best way to use it. For instance, i have a level that has lots of the same mesh all over the level. A do i create LOD levels for each of the individual tree prefabs? or do i combine the mesh and apply a LOD.

    Could someone point me in the right direction, i have also purchased other assets for instance Super Level Optimiser, and ProDrawCallOptimiser.

    Some advice on how to best go about optimising for mobile would be awesome as i have trawled forums and threads not really getting a decisive answer.

    Many Thanks

    Daniel
     
  32. djgriff

    djgriff

    Joined:
    May 29, 2014
    Posts:
    279
    anyone know what would cause this error:
    NullReferenceException: Object reference not set to an instance of an object
    LODSwitcher.ScreenPortion () (at Assets/SimpleLOD/LODSwitcher.cs:144)
    LODSwitcher.ComputeLODLevel () (at Assets/SimpleLOD/LODSwitcher.cs:156)
    LODSwitcher.Update () (at Assets/SimpleLOD/LODSwitcher.cs:125)


    thanks
     
  33. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    @andyastro There is a feature to remove occluded vertices. It was designed for removing skin underneath clothing. But you could use it for your purpose as well. The distance between the occluded vertex and the covering surface is max 100 mm. You could overcome this by scaling down the mesh before you run this.
    And please also note that it is not 100% thorough. It may leave some vertices behind, as this was designed for clothes. It also doesn't know anything about transpant surfaces, which is why you have to manually select the submeshes that can occlude what's underneath.

    @djgriff If you have multiple instances of the same mesh, the best thing to do is create LOD meshes of 1 of those instances. Then add an LODSwitcher component to each of your instances and drag the same LOD meshes to all of those LODSwitcher components.

    But when you have clusters of these instances that are very near to each other, it may be better to combine them into 1 mesh, then generate LOD levels and use them is 1 gameobject with 1 LODSwitcher. This way all objects in the cluster are switched between LOD levels at the same time, but it saves you a few draw calls.

    The error you show is very likely due to having no Main Camera in your scene or having a Main Camera that is dynamically created or assigned after startup. You can fix this/prevent the message by making sure your LODSwitchers are not enabled until your Camera is in place. You can also call ComputeDimensions() on each of the LODSwitchers manually after the Camera is in place.
     
    Last edited: Sep 21, 2015
  34. djgriff

    djgriff

    Joined:
    May 29, 2014
    Posts:
    279
    Thanks for the reply, I will take you up on the suggestions of grouping and lod level.
    The error though is odd. it works fine then randomly kicks in. I have a main camera that is set as a child to the main character. It looks like it isnt finding it though.
    Do you know if there is a away to set it as the main camera so your asset locates it?
    not sure how to make the maincamera appear first. if this is indeed the issue.

    The way i am setting up LOD is to have a prefab with lod applied then dragging the models in to place using the prefab.

    Thanks

    Daniel


    EDIT: Set the Camera in the inspector resolved this.. Thanks
     
    Last edited: Sep 21, 2015
  35. djgriff

    djgriff

    Joined:
    May 29, 2014
    Posts:
    279
    got bit of an issue, if i applt the smallest amount of lod to my model it will delete the top of my pine trees.. really annoying.. is there away to stop it doing this?

    If you look at the image of the tree near and the one not too far away it takes the top of the tree off..

    Suggestions welcome.

    Thanks
     

    Attached Files:

    • LOD.PNG
      LOD.PNG
      File size:
      468.2 KB
      Views:
      865
    • LOD2.PNG
      LOD2.PNG
      File size:
      371.8 KB
      Views:
      1,549
  36. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    If you click the more... button, you get an option to set the max size for the removal of small objects. If you slide that to 0, the top of your tree should remain in place.
     
  37. djgriff

    djgriff

    Joined:
    May 29, 2014
    Posts:
    279
    Thanks for the fast reply,
    Hmm it doesn't seem to make any difference, however if i group trees to couple or more it doesn't seem to remove the top of the tree so will use that work around for the mo.

    Thanks thought

    Best

    Daniel
     
  38. t.beauchemin

    t.beauchemin

    Joined:
    Nov 21, 2013
    Posts:
    3
    Hi there, I'm very please with this asset, my only concern is this:
    When I select children mesh and use batch Operation A or B, the results are nicely nested in the parent.
    However when I use the C option they are created at the root of the scene.

    Could this be easily fix ?
     
  39. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    @t.beauchemin Yes, I have fixed it. It will be in the next version that is uploaded for review by the AssetStore today.
     
    hopeful likes this.
  40. protoshape

    protoshape

    Joined:
    Aug 2, 2015
    Posts:
    9
    Hi,

    I just downloaded Simple LOD and seems to work fantastic except 1 fatal unexpected situation.

    I try to create lod levels for a rigged single mesh model.

    Create Lod Levels options B and C are working fine but option A which is "Create LOD Levels and LodSwitcher" freeze and crash Unity.

    I'm using SimpleLOD 1.5 and Unity 5.2.1 f1

    I need your help please.

    Thanks.

    screen-capture-21.png
     
  41. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    @protoshape Making LOD levels for skinned meshes and using the LODSwitcher on them works fine in my copy of SimpleLOD. Can you mail me a copy of your model?
     
  42. paulojsam

    paulojsam

    Joined:
    Jul 2, 2012
    Posts:
    575
    i am getting the following error, when i create the Lods, the result is invisible, what can i do to correct it
     
  43. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    You say you get "the following error", but you don't specify it in your post???

    Inisible results can be due to a lot of things.:
    - the transform is somewhere off screen
    - the scale is tiny
    - no MeshRenderer attached
    - .....
     
  44. paulojsam

    paulojsam

    Joined:
    Jul 2, 2012
    Posts:
    575
    i notice only the 3 button that creates the lod group, makes the group lod invisible, and the transform is in the wrong position but with no visible meshes. The no meshrenderer makes sense. Let me check it.
     
  45. tinman

    tinman

    Joined:
    Jan 8, 2011
    Posts:
    229
    Does the LOD creator create new FBXs which can then be exported out of Unity? Also, is the texture atlas maker compatible with new Unity PBR materials/shaders?
    Thank you! It all looks very promising
     
  46. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    hopeful likes this.
  47. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi there Orbcreation,

    I'm having some problems with the Material Atlas Window:

    upload_2015-11-4_20-42-37.png

    Where is the "Make readable button"? I cant drag the materials...
    Using unity 5.2.2f1 (there was not compiling errors on import of the package).
     
  48. camel82106

    camel82106

    Joined:
    Jul 2, 2013
    Posts:
    304
    Hi,
    I'm trying to use your plugin. But I'm getting too simplified result. You can see it on images:


    I have tried it with remove small parts set to 0 with same result. What am I doing wrong?
    I cannot simply set lower compression through editor 0.01 is minimum

    Thanks
    Peter
     
  49. Orbcreation

    Orbcreation

    Joined:
    May 4, 2010
    Posts:
    231
    @Project Mysh You have no main texture in your materials. The easiest thing to do is set a dummy main texture, make everything readable, create atlases and remove the fake texture again. I'll try to have the next version test for the existence of textures in all slots.

    @camel82106 You model is probably very small. The LODMaker uses the actual size of a triangle (among other things) to determine if it can easily be removed. If you increase the scale before you generate the LOD levels, I think you will have better results.
     
    Project-Mysh likes this.
  50. camel82106

    camel82106

    Joined:
    Jul 2, 2013
    Posts:
    304
    Thanks, changing scale on 3D model worked. Scale on prefab instance was ignored.