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. Dismiss Notice

ProDrawcallOptimizer, reduce the number of drawcalls drastically on your project

Discussion in 'Assets and Asset Store' started by jmunozar, Mar 27, 2014.

  1. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @honiku,

    if you clear the meshes your scene should go back to normal as all the generated objects are removed. (have you tried closing and opening the project again? It could be a memory leak in the engine).

    Being said that; it makes sense the scene will be a little bit more heavy because there will be unused space in the generated atlases. Thats why you APK goes from 31.99kb to 33.66kb.

    Regarding the scene sizes; it makes sense that it will increase like that; this is because in your scene both your original textures and the generated atlasses textures are in the same place (even though the renderers are disabled). that's why you see a ~2x size in your scene. In order to solve this, you will have to delete your original objects (which I totally DONT recommend because you will not be able to go back to your original scene) to get back to your more or less original scene size (maybe a little bit bigger because the unused space in the atlasses).

    Let me know if you have any other question / I can assist you with anything else :)
     
  2. Honikou

    Honikou

    Joined:
    Feb 18, 2013
    Posts:
    91
    Yes, I had already delete other atlas !

    I solve the problem with prefab.

    But my new problem is, I decide to change a mesh of an element. There is anyway to update an atlas and a prefab without delete all ?
     
  3. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @Honikou ,

    if you change the mesh, you will have to redo the whole process; this is because the mesh you set has to be read; processed and remapped to the new Atlasses positions. Unfortunately for changing meshes there is no workaround as UVs have to be recalculated for the meshes.
     
  4. Honikou

    Honikou

    Joined:
    Feb 18, 2013
    Posts:
    91
    You could keep the name and prefab to replace automaticly, even if we have to recalculate.

    I made a plateform game, if I want to change an object, everything is delete...
     
  5. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @Honikou,

    I more or less understasnd you; you are saying that you want to keep your baked objects when you do another bake. For that there is a solution; go to the Settings and Uncheck "Remove atlased before bake" with that, you can carry on atlassing objects without losing the old ones :).

    Hopefully that answers your concern ;). Do let me know if thats not what you meant
     
  6. Honikou

    Honikou

    Joined:
    Feb 18, 2013
    Posts:
    91
    Yes but I would like your plugin to replace the correct prefab without doubling it again and again everytime I generate atlas on a scene if I need to made modification.



    For example, I add an atlas with only 2 objects, I want to add one, then now I have 5 prefabs instead of 3.

    That would be perfect if your plugin with the name of object I add, If I select prefab, that replace correctly the prefab.

    Bug:
    I have a bug that your plugin activate mesh on object I don't select on the scene.
     
    Last edited: Mar 16, 2017
  7. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @Honikou , I understand, Unfortunately that's not possible becaus each gameobject has an instance ID so it will be impossible to know which GameObject is tied to which one.

    Being said that, what you could do is this: Activate the checkbox "Remove before bake". with this your atlasses are going to be regenerated everytime and deleted the old ones BUT, when you generate a prefab, and you are happy with it; what you do is take out the generated prefab, generated mesh and generated material out of the folder where they get generated and with that your objecs are not going to be deleted :).

    I dont understand your english whe you mention that my plugin activates a mesh on objects that you dont select on the scene; could you send me a video?
    Cheers ;-)
     
  8. Raveerojh

    Raveerojh

    Joined:
    Nov 28, 2016
    Posts:
    2
    Comment in these lines below for resolve this error, I think that is error of Unity 5.x;

    for(int i = 0; i < count; i++) {
    if(ShaderUtil.GetPropertyType(mat.shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) {
    // if(ShaderUtil.GetTexDim(mat.shader, i) == ShaderUtil.ShaderPropertyTexDim.TexDim2D) {
    string shaderDefine = ShaderUtil.GetPropertyName(mat.shader, i);
    if(includeNullTextures) {
    shaderTextureDefines.Add(shaderDefine);
    }
    else {//here we check if the texture retrieved from the shader is null, if it is dont include it
    if(objectMaterial.HasProperty(shaderDefine)) {
    Texture2D retrievedTextureFromShader = objectMaterial.GetTexture(shaderDefine) as Texture2D;
    if(retrievedTextureFromShader != null)
    shaderTextureDefines.Add(shaderDefine);
    }
    else {
    Debug.Log("Couldnt find material property '" + shaderDefine + "' for shader: " + shaderName);
    }
    }
    // }
    }
    }
     
  9. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @Raveerojh, the error happens because you are not using the latest version of Prodrawcall. Please update to the latest version and it will be solved. ;-)
     
    Last edited: Mar 18, 2017
  10. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    422
    Baking is failing with a single error in the console:
    MissingReferenceException: The object of type 'Texture2D' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    ProDrawCall.Utils.TextureSupported (UnityEngine.Texture2D tex) (at Assets/ProDrawCallOptimizer/Scripts/Editor/Core/Utils/Utils.cs:82)
    ProDrawCall.Atlasser.SaveAtlasToFile (System.String pathOfAtlas, System.Collections.Generic.List`1 texturesOfMaterial, System.Collections.Generic.List`1 scales, System.Collections.Generic.List`1 offsets) (at Assets/ProDrawCallOptimizer/Scripts/Editor/Core/Atlasser.cs:117)
    ProDrawCall.OptimizableShader.CreateAtlasMaterialAndTexture (ProDrawCall.Atlasser generatedAtlas, System.String shaderToAtlas, ProDrawCall.TextureReuseManager textureReuseManager, Int32 atlasNumber, Int32 start, Int32 end) (at Assets/ProDrawCallOptimizer/Scripts/Editor/Core/OptimizableShader.cs:434)
    ProDrawCall.OptimizableShader.OptimizeShader (Boolean reuseTextures, Boolean generatePrefabs, Boolean generatePowerOf2Atlases) (at Assets/ProDrawCallOptimizer/Scripts/Editor/Core/OptimizableShader.cs:212)
    ProDrawCall.ProDrawCallOptimizerMenu.OnGUI () (at Assets/ProDrawCallOptimizer/Scripts/Editor/GUI/ProDrawCallOptimizerMenu.cs:138)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    temp.png

    Is it because Texture is being resized? (PC has 64Gig RAM and a Nvidia 1080 GPU, so not likely it's running out of resources?)

    What can I do to fix this?

    Many thanks
     
  11. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091

    Hello @jeromeWork ,

    What platform are you aiming? if its a platform different from StandAlone, could you please try baking in stand alone?, which version of Unity are you using? are you using textures bigger than 4k?

    Even if you have 64gb of ram, Unity is limited by the amount of memory your OS lets each application have. even though that should not be a problem.

    Are you using any strange texture formats / generating prefabs / combining lots of materials?, the supported texture formats for read and write are: TextureFormat.ARGB32, TextureFormat.RGBA32, TextureFormat.BGRA32, TextureFormat.RGB24, TextureFormat.Alpha8.

    Try this: only bake legacy shader/vertex lit alone and let me know if the problem persists.

    if possible, send me a small package of your project that reproduces that error so I can fix it for your specific case.
     
  12. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    422
    @jmunozar Thanks for the super fast response :)

    So, yes I was targeting Android, changed to Standalone and now baked without errors. Thanks for the heads up. Sorry, I had to idea that platform was an issue. Will know for next time.
     
  13. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    So. I have say 300 prefabs that each have their own materials and LODS (0,1 +2)
    I drag them into the scene and select them all.

    I choose bake atlas and the resulting models all use the same material. Which is obviously foolish as they cant contain the individual UV offsets. and all look mangled.

    What am I missing?
     
  14. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @jeromeWork,

    The platform is not an issue, the problem is that when you are compiling to a platform the tool also has to change the texture formats to be able to read the textures and then change back the format to the original platform; hence it takes a lot of time and memory. Still, great thing it worked out :)
     
  15. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    hello @twobob the idea of the tool is to get all the materials (that share the same type of shader) into an atlas with one single material that contains all the textures of the scattered materials in your original scene; with this the video card minimizes the amount of times it takes it to draw a single frame; hence increasing the performance of the scene.

    if your result textures look disfigured, it might be a UV problem, to fix this checkout this video:


    For working with LODs checkout this video also:


    Hopefully this answers your questions, else dont hesitate to write back in here :)
     
  16. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    No. And I have owned this since the last version and just updated but never really understood what was wrong so never bothered using it. so, I watched that LOD video before I posted here and am really trying to understand what you are saying.
    You create three materials. and assign them. then you run the optimiser.

    I am talking about the materials that are created as a result on the new things all share the material.
    How then, in that case, does the model know where on the new Atlas to look.

    Since one material can only contain one offset.

    ALSO minor errata:
    In the "Generate Hierarchies for optimized objects" you say "Bare in mind" - that should be "bear in mind"

    Is it supposed to be baking a copy of the mesh with the UV co-ords in there?
    Because I have yet to make it work even once properly on anything. so I must be missing something - all my results always look mangled.
     

    Attached Files:

    Last edited: Apr 9, 2017
    jmunozar likes this.
  17. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @twobob,

    now I understand what you mean.

    So the way the LOD works is that it changes meshes against the distance from the camera. If the meshes use all the same material and texture you are just gaining performance on vertex count.

    If you happen to have LODs with different texture resolutions/details then in that case the tool will atlas your different materials and change meshes according to the distance from the camera.

    The tool gets each mesh in the LOD group and maps it to a certain position in the atlas and if the textures are different then the UVs are mapped to different places. In this process the old meshes are disabled and new meshes with the UVs remapped are created. Does that makes sense?

    You will have to change the references for the LODs to get the new meshes created by the tool; but I remember someone posting a simple tool to do that here in this thread

    In the case 1 material is rendered with only 1 mesh, then there is no advantage as the meshes change. I'm not sure if the materials and textures are loaded in memory beforehand or on the fly by the engine but if 1 atlas is loaded you can just access it vs having to load different materials. (but im not sure how the internals work).

    PD: Thanks for mentioning the errata!, I will fix that right away :)
     
    Last edited: Apr 9, 2017
  18. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Hmm. So. I am going to have to hand edit hundreds of LOD prefabs. Ouch

    If there is a simple tool for that why not subsume it into the main tool?
    Sigh. My issue is I get a couple of LOD fish or something and try and combine them and I seem to just get junk as the results.

    confused. I'll keep plugging on see if I can figure out why.

    Additionally on things like floors where it is typical to have a pre tiled texture the resulting output is very confusing. perhaps there is some part of the readme I missed or some nuance of a video, but it doesn't seem very straightforward. Sorry
     
  19. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @twobob,

    Hopefully you will not have to set LODs manually! :), again, another user (M2H) in the forums created a quick tool that sets the references automatically. I haven't tested it though, but you can find it here: https://gist.github.com/naruse/409649dfd65958f4a8ebc3b9cdd348d8

    Regarding the tiling. Tiling works if you set the tiling in the material; if the mesh has UVs outside [0,0-1,1] then the UVs are malformed and the resulting atlas will look bad; this is because as UVs are outside of [0,0-1,1] the generated mesh will use neighbor textures in the atlas, hence looking strange.

    Let me know if you have issues with that script. again. I havent tried it out but with some tweaking should work. And post as many times as you want to clear all confusions please, I'm here to help as much as I can! :)
     
  20. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Right. I don't see why you don't just put that code in the app? for LOD models? at the relevant moment.
    With a tick box "Auto fix LOD references"

    Without the "EDITOR" bit? I suppose I should go hunting through the code and see why you didn't

    We appear to be talking at cross purposes. I know what atlases are, UV's, I know how LOD works and yes I have watched your videos about malformed coords.

    Consider the case where you choose to combine to models [COMBINE box] but they have different tiling values before you start. in this case the output will be junk. Yes?
     
  21. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    You are right, I just havent added it to my codebase. I havent tested it out and right now I'm working on an STL tool. Hopefully I will add it in the future.

    Regarding your question about different tiling values. I dont know. I will have to test that out and let you know :/
     
  22. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    "Hopefully I will add it in the future", wow. now that's commitment.

    Hmm. I did yet another very simple test case and got a pretty terrible result. bad.GIF

    the white floor material is before atlasing. even at 256x256 it looks as good as that.
    The red stuff is your "combined" effort of the same material - post process at 1024x1024.

    It's really mangled so I must have to untile the thing first maybe completely and retile after the render?
    Or something? highly confused at this point.
     
  23. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    I just sent you a private message.

    I will be testing that and hopefully will add that LOD thingie in the future :). To me, hopefully means I will. Sorry if it doesnt translates correctly to english. I'm not a native english speaker.
     
  24. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    In the future - since LOD is so common on models. a video that explains the process of batching together a couple of PREFAB - LOD models and making them be stored - with the right meshes - as prefabs again - would be great. ( and that would be enough information to do any amount from there)

    Also: I know that working with existing non-scene prefabs requires you to make an interim object and that work also doesn't look to have been done. Perhaps some code to prevent people choosing prefabs might be a good option until then.
     
  25. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @twobob,

    Actually, the LOD video is a great suggestion!, Makes a lot of sense not only a video but an actual example scene to include in the tool for people to play around with.

    Good point regarding the prefab choosing from the project view; optimizable objects only work on the scene view. I just noted that down to fix it; thanks!
     
    twobob likes this.
  26. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Okay so. If you are combining something like floor and large geometry pieces that are already tiled (very standard setup)

    First: Lower the tiling back down to (1,1) (0,0) or the resulting texture will be based on the tiled texture.
    better.GIF

    This is the same shot as above but first I made the Rocks 1,1 and then optimised - THEN made the texture tile.
    This gave MUCH better results in line with expectation.

    Which begs the question why there either is no warning - or something - when textures are non 1,1
    Maybe I missed it. Anyway, I got a single test to do something I expected on two objects with no LOD.

    Yay. progress. a bit :)
     
  27. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    I tried a non LOD set of fish and tried to do them as a batch...
    This oddly stretched the mesh of some fish really horribly. There were no warnings in the log.
    I will try again tomorrow. Need to rebuild my prefabs maybe, think I have mangled them during all this testing.

    Hey ho. Maybe tomorrow will bring better luck
     

    Attached Files:

  28. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello twobob,

    The tool issues a warning if your UVs are outside 0,0-1,1 mentioning that your meshes might look wrong. Because sometimes the UVs might be let's say -0.01, 0. So is barely noticeable.
     
  29. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    As I said "no warning" was issued. So I found out 3 models that just will NOT covert over, Their resulting meshes appear to have some weird linkage to world 0,0,0 in them.

    I got a handful of the other to actually convert in the end.
    I didn't delete those three generated prefabs - I will forward you those three models and the resulting prefabs at some point if you like. They were processed IDENTICALLY to everything else in that batch: 12 worked, 3 got junked.

    One more question - and when I get back from this funeral toady I will read the entire manual to double check.
    Don't you have a "Oh yes that is great, I am happy - let's commit and delete all the old stuff (like disabled meshes)" button? I didn't see one. Just concerned all those meshes references are left in the build. Build will swell in size for no reason.

    Thanks man

    You can see in the picture attached above that the models "stretch" to 0,0,0 for no obvious reason
     
  30. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    anyway - on a happier note - I /think/ these ones converted ok

    Not a bad draw count for 500 fish ( no shadows)
     

    Attached Files:

    • 500.GIF
      500.GIF
      File size:
      514.9 KB
      Views:
      784
  31. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @twobob,

    Only 10 drawcalls for all those meshes. Not bad :).

    Regarding the stretching. That's strange. Actually has never happened to me before. Do you have a small repro case you could send me (1-5 objects that when you bake reproduce that error?).

    On the other hand. There is no button to delete your original game objects. This shouldn't affect your buildsize as unity will include in your scene only the materials that are being used (for what I have been told). The reason I couldn't add this feature is because at the very beginning (pre-pro draw call 1.0) the tool used to have a button that removed the original game objects and it got rejected by the asset store upon submission because tools shouldn't delete original parts in customer's scenes (according to them at that time) hence I couldn't add it unfortunately :-/. The way I suggest customers to follow is to duplicate the scene and delete original objects while processing as that's as much the asset store allows.

    I'm sorry about the funeral.
     
    twobob likes this.
  32. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Regarding the warning (which I forgot to address). When the material is tiled to something different than 1,1 yes there is no warning. I thought you where referring to something else. I have to think on a way to mention that the textures might look bad if the tiling is too much due to compression issues. I will have to experiment more with different settings and compression values when tiling to be able to correctly emit a message or a warning. Noting that down on the Todo-list.
     
    twobob likes this.
  33. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Re mangle:
    I can do better than that. I'll send you the original models and the resulting prefab meshes.
    I maybe messed it up - but it was all done in one pass over all the models. 3 died - the rest lived.
    Just got back from the services, this'll keep till tomorrow if you don't mind.

    Re. Removing stuff.
    Well. Just derp up an editor file, Gist it. link to it. Video guide. What more can you do. :)

    Thanks man
     
    jmunozar likes this.
  34. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    sounds like a plan :)
     
  35. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Hmm yeah. but as they are skinned as you can see the calls are then very high from the resulting passes afterward.
    I recall Animation Baker can fix that by embedded your meshes into a solid pass (perfect for my simple swim animations)
    https://www.assetstore.unity3d.com/en/#!/content/83620
    So I might play next with making it a truly scary low draw count...

    I have managed to get a semi-solid workflow now for combining + atlasing solid objects.
    But I always seem to get junk when I try it on objects with a cutout shader. If I get a chance I will work on that today and out the weird models but I have to paint a toilet first.

    My Rock and roll lifestyle knows no bounds.
    Thanks for your excellent and timely, knowledgeable support.
     
  36. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @twobob,

    Quick thing regarding the cutout shader, The cutout shader uses a slider for showing / cutting out some parts of the generated mesh depending on the alpha of the texture so if the different materials have different slider values then you will get kinda junk, sometimes its unfortunately unavoidable and the tool would not work in those cases; some other times you can play with the cutout slider and tweak the atlas material and get it back to more or less how the scattered materials where; hope this helps in case you havent checked it already :)
     
    twobob likes this.
  37. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Thanks. That gives me something to test on the cutout workflow then.
    Getting a much nicer count overall now thanks to your great work (and some extra baking love)
    9DrawCalls.GIF

    < 10 draw calls for the basis of a scene (no cutouts), with a working animated model is pretty special. Getting there, thanks for your direction.
     
    jmunozar likes this.
  38. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    pretty nice! :), same works for all other shaders, they might need some tweaking after atlassing.
     
  39. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Got cutout working. Have to remember to manually set it to cutout. thanks
     
    jmunozar likes this.
  40. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    So basically for LOD. Run the thing.

    Run: The original LOD fixerUpper
    https://gist.github.com/twobob/9ae6df45f24340852bb08e799f122764

    Then Run:
    Here is a quickie DIRTY script that simply searches for the string LOD and removes any matching gameobjects that have a disabled meshrender component. (use at your own risk, works okayish here, the borrowed safeDestroy is unneeded overkill)
    https://gist.github.com/twobob/90fb93504b4c7076818a5de393773fdb

    Finally Run:
    This one lets you save all the selected scene objects into a configurable folder as separate prefabs (I just spruced a wiki one, it could do with more love to ensure it only saves the parent objects as prefabs, currently objects must be collapsed in the hierarchy to save correctly) https://gist.github.com/twobob/deff9e20b94b6c80839426bdfbce4ac7


    Hope that helps.
    Doesn't look like to much work to weld that onto a couple of buttons in your code now.
     
    Last edited: Apr 13, 2017
    jmunozar and zenGarden like this.
  41. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Thanks for sharing this!, I will check it out, do some tests on all platforms + all Unity versions and if everything goes well add it to the code in the next few days.
     
  42. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Line 182 of the atlasser should have a wrapper around it to prevent trying to access crunch format files.
    Color[] texturePixels = texToProcess.GetPixels(); Will die horribly.

    The second script I posted that removes the old LOD's needs more love.
    It fails to remove a few (editor frame timeout race condition maybe). On subsequent use it will clean up more.
     
    Last edited: Apr 15, 2017
  43. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Line 88 Debug.LogWarning("Skipping " + arr.name + " game object as is already optimized.");
    This logic should be moved further up somewhere.

    Since it completely trashes the current run in an unrecoverable way if you include LOD objects that have meshes with your OCDobj (or whatever) suffix to them.
     
  44. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Now you uderstand why I dont include stuff immediately :). ProDrawCall is a pretty complex tool inside and has grown a lot across the past years (even after all the refactoring that I do continuously). Thanks for pointing the crunch format. I'll check that.
     
  45. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Certainly do. Since there currently is no way to "Confirm" that you are "Happy", then models get left with the suffix.
    This can result in models accidentally being deleted from the scene when you press CLEAR ATLAS.

    Some sort of "Yes I am Happy - Commit this lot to a prefab - and delete the suffixes" process, would be a good idea.

    Since you have the code to build the full prefabs anyway, that seems like the most sane option.
    Build a complete, structurally identical prefab, to the original and save it.

    Finally getting rid of all the interim suffix complications for good.

    (also, you say this will be slow, it takes under a minute to do TONS of prefabs, not really that slow)
    I did manage to slow it down with 2000 prefabs and a 4 way combine to a few minutes - but really.. not that slow

    Additionally, when combining meshes the created mesh is not actually stored to a prefab.
    I have written a script to let me fix (somewhat tediously) this but saving them to a prefab is preferable.

    Many thanks
     
    Last edited: Apr 14, 2017
  46. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Getting rid of the suffix is not a trivial thing as there is no way to identify already optimized objects as InstanceIDs of gameobjects change.
    Being said that, I'm happy you dont think its that slow. In my computer it is. One of the main reasons to provide the source code is to let people do what you are doing, adding plugins, and modifying the tool to fit their needs.
     
  47. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Yeah fine. I'll figure out a script to do it then or something.

    One thing that would be nice for the combine facility is to split up the combined object into logical squares.
    (Mesh Materializer Davit Naskidashvili) does this (Okay so I asked him to)

    This results in the underlying system being able to cull sections and prevents the user having to jump through hoops to get that done.

    Thanks :)
     
    jmunozar likes this.
  48. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Interesting.
    Could you please elaborate more on the logical squares? I dont completely get it :)
     
  49. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Sure, in the case of something cuboid like the Unity Terrain mesh it is easiest to think about.

    renderer.mesh.Bounds.size then split that into 'n' X 'n' lumps based on the total cuboid volume.

    Is that clear enough?

    In most cases this would actually result in a 3x3x1 result (or whatever x 1) since many models when "combined" are mostly flat.

    In fact simply providing a NxN solution that only does one depth would be fine also. Thanks :)
    In the interim I am going to play with chopping it up with some post tools see if I can do it myself.

    If not, I will have to add some code that provides "logical grouping based on World location" to the current combined output workflow that you provide to get any sort of sensible culling.
     
  50. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    This also gives you a more sensible way of combining really bigs models (or model counts), currently you push out the total vertices iterated over in big lumps (I imagine you count to 65k and then just do the next lot). Subdividing them by World space and THEN combining them would give culling for free.