Search Unity

ProDrawcallOptimizer, reduce the number of drawcalls drastically on your project

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

  1. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    336
    Hi, it's specifically due to the "optimize game objects" option that I mentioned. Your tool works fine when that option is not enabled.



    This option removes the transform hierarchy for the bones, reducing the amount of game objects. I'm currently downloading your examples package to test it on your skinned mesh renderer scene, but I imagine it will have the same issue.

    The error I'm talking about is pretty common when duplicating a mesh from a SkinnedMeshRenderer that has a rig that has "optimize game objects" enabled. You can see an explanation here: https://forum.unity.com/threads/optmize-hierarchy-of-a-generated-skinned-mesh.340876/

    I was just hoping that maybe someone else had used your tool on rigs also using that option.
     
    jmunozar likes this.
  2. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Ah, Indeed thats because perhaps internally the number of bones vs vertices are different, Unfortunately if that's the case then yes, it would not work with the tool :-(.

    Does the "Optimize Game Objects" give you a lot of performance compared with what the tool does?, From what I can see (and you mentioned) just removes the game object hierarchy which at the ends translates in a couple of more matrix multiplications for calculating positions/rotations/scale..
    I know its not the best scenario but perhaps "Not optimizing game objects" and atlasing the materials is better.

    I guess you already tried this but what would happen if you optimize with the tool and then when the objects have the materials combined you "Optimize Game Objects"; would that work? This is the only workaround that could come to my head as of right now to use both. (optimize objects with combiend materials)
     
  3. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    336
    According to a Unity staff member in that thread I linked:

    "I don't have numbers on the Wii U, but updating transforms, for characters or objects with a deep hierarchy, generally represents 60-80% of the animation cost, and it can't be multithreaded."

    And my rigs have a lot of bones unfortunately, so it is pretty important for my use case.


    *EDIT*

    Using "optimize game objects" or
    AnimatorUtility.OptimizeTransformHierarchy
    actually works perfectly with ProDrawCallOptimizer, unless you have a skinned mesh renderer with a submesh, as explained in: https://forum.unity.com/threads/optimizetransformhierarchy-generic-rigs.407934/. Sorry for the confusion
     
    Last edited: Mar 28, 2019
  4. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hey @hungrybelome,

    Wow, I didnt know about the animation cost!, TIL something new, thanks for sharing that! :). Yes it sucks this corner case its complex to solve, still if you find any other issue dont hesitate to either post here or just send me an email ;-). Thanks for sharing it by the way! :)
     
    hungrybelome likes this.
  5. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Hi, really want to know if this tool can work on speed tree models. Speed tree exports too many materials just for one tree model. And each tree has to have their own materials set. I'd like to combine several speedtree models materials to one so in an open scene the whole forest several different tree species can use only one material to save the draw calls.
     
  6. jmunozar

    jmunozar

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

    There are a couple of things to check before knowing if it works; if the speed tree exports several materials within the same model it could be that they have different type of shaders, even if they are the same and the rendering type is different Unity internally recognizes as a different type of shader.

    Now; if the resulting tree game objects have a mesh renderer and a mesh filter component then yes, absolutely it will work, if not most likely it will not.

    Another thing to take into consideration is that if the generated tree has the UVs outside of [0,0-1,1] then the generated atlas will just not look correctly.

    Hope this helps! :)
     
  7. lroberts_unity

    lroberts_unity

    Joined:
    Sep 26, 2017
    Posts:
    2
    Hello when i use this program my textures just go black. What would be the reason this is happening ?
     
  8. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @iroberts_unity.

    Thats really strange. That could mean that your game objects' UVs are outside <0,0-1,1>. Are your UVs inside that range?.

    Does the tool gives you any warning messages in the console? :)
     
  9. lroberts_unity

    lroberts_unity

    Joined:
    Sep 26, 2017
    Posts:
    2
    yeah the UV's where outside sorry to bother
     
  10. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hey @iroberts_unity,

    Don't be sorry :). Im glad you found the issue. If you have any other question do not hesitate to post. I'll do my best to help out ;-)
     
  11. icefallgames

    icefallgames

    Joined:
    Dec 6, 2014
    Posts:
    75
    Hi, I'm trying to evaluate purchasing this tool by using the free version. I've found a couple of issues:
    - The Bake Atlas button is disabled unless I select multiple objects. Our common scenario is a single game object with multiple submeshes/materials. Does it not handle that scenario?
    - A common scenario for us is one where some materials might have an albedo texture while others don't. I would expect the color to instead become a portion of the texture, and uvs adjust to sample from that region of the atlas. Does it not do that?
    - The tool throws an exception when trying to save the atlas: "Selected texture format 'ARGB 32 bit' for platform 'Standalone'' is not valid with the current texture type 'Advanced'".
     
  12. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    hello @icefallgames !

    My answers to your three questions/comments:
    - The light version doesnt combine multiple materials for one game object, the pro version does (But the materials need to share the same type of shader).

    -Regarding the second question and some materials with albedo textures and the other with just a color: Unfortuantely, since how the standard shader works internally, a standard material with a color is totally different of a standard material with an albedo texture, hence they will be treated as different type of shaders. Being said that, if you just add a 1x1px texture of the color in the albedo texture spot, then the tool will recognize them as the same type of shader.

    - The error exception, interesting. there are lots of factors that can affect it in the light version. Being said that, if you want, send me an email and I can give you a test version of the ProVersion so you can check if it works out for your needs.

    cheers ;-)
     
  13. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Just bought the updated version.

    When I try to do the entire scene, the tool breaks because there's an animated character in the selection as well.
    I'd wish it would just skip this:
    (Has a SkinnedMeshRenderer instead of MeshFilter)
    Code (CSharp):
    1. MissingComponentException: There is no 'MeshFilter' attached to the "UnderWater_Diver_v2.ODCObj" game object, but a script is trying to access it.
    2. You probably need to add a MeshFilter to the game object "UnderWater_Diver_v2.ODCObj". Or your script needs to check if the component is attached before using it.
    3. ProDrawCall.Utils.CombineObjects (System.Collections.Generic.List`1[T] meshesToCombine, UnityEngine.Material atlasMaterial) (at Assets/ProDrawCallOptimizer/Scripts/Editor/Core/Utils/Utils.cs:223)
    4. ProDrawCall.OptimizableShader.CombineObjectsSelectedForCombine (System.Boolean generatePrefabsForObjects, UnityEngine.Material atlasMaterial, System.Int32 start, System.Int32 end) (at Assets/ProDrawCallOptimizer/Scripts/Editor/Core/OptimizableShader.cs:240)
     
  14. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091

    Hello @MikeHergaarden, sorry for the late reply (i was sleeping :p), interesting, it should just work. Just checking the obvious, does that skinned mesh renderer game object also has a mesh renderer?

    Could you please send me to my email a small example of your scene that breaks so I can debug it here?, I just tested the demo scene with skinned mesh renderers and it works.

    Looking forward to hear from you! :)
     
  15. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    hello @MikeHergaarden,

    Havent heard from you/havent got any email recently, Just wanted to check on you; did you manage to fix your issue?
     
  16. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    The evaluation links don't work, I'd like to try this out before I buy it.
     
  17. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    woaah!, thanks for mentioning this @florianalexandru05 !, indeed you where correct the links didnt work. Might be that the folks at unity changed the links and I wasnt aware.

    Being said that; just corrected and submitted them for review. Organized the links in the 1rst post in this thread.

    the light version can be found here: https://assetstore.unity.com/packages/tools/utilities/pro-draw-call-optimizer-light-16888

    Let me know if you find any other issue/missing link

    Thanks! :)
     
    florianalexandru05 likes this.
  18. GoathamsterStudio

    GoathamsterStudio

    Joined:
    Oct 11, 2019
    Posts:
    1
    Does it work with URP?
     
  19. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    Thanks, I'll try it out. I might just do it in Blender if it doesn't work out for me but if it does I'll buy it for sure!
     
  20. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    yes, it should. The tool works on textures and UVs not on light estimation/how stuff is rendered so you should be good to go :)
     
  21. WaqasGameDev

    WaqasGameDev

    Joined:
    Apr 17, 2020
    Posts:
    118
    Hi, I tried to test your light version tool and when I tried to bake atlas, it gives me this error and the optimization loading bar stays there for ever. I am using 2018.4.10f
    Code (CSharp):
    1. MissingMethodException: byte[] UnityEngine.Texture2D.EncodeToPNG() ProDrawCallLight.ProDrawCallOptimizerMenu.CreateAtlasMaterialAndTexture (System.String shaderToAtlas, System.Int32 shaderIndex, ProDrawCallLight.TextureReuseManager textureReuseManager) (at
     
  22. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @GameHourStudio that happens most likely because your texture format is most likely psd or other format not supported by the unity importer. What are the texture formats you are using?.
     
  23. Matt3D

    Matt3D

    Joined:
    Apr 12, 2013
    Posts:
    32
    I wanted to share some problems that I'm having with the tool, as well as some workarounds, and suggestions for improvements.

    I am using the latest version of ProDrawcall Optimizer, my build target is WebGL. Unity 2019.4.11

    First of all, any texture that is marked as crunch compression produces garbage results when atlased (rainbow patterns). This is also happening for any texture marked as a Normal Map, the resulting normal map is incorrect (mostly all red, missing info in other channels)
    The solution is to have all textures not marked as crunch compression, and not as normal maps pre-atlasing, and then correctly compressing the results after.

    I've also had issues related to using Unity's Standard Shader. Pro Drawcall optimizer does recognize in the inspector different standard shaders with different maps grouping them together (normal, metalness, emissive etc).
    However, when atlased, only the albedo map is atlased, no normal map or metalness map. The workaround was to create my own custom shader using Amplify shader editor. Prodrawcall optimizer correctly created atlas's for all texture maps then.

    In order to preserve individual metalness/smoothness values I've created tiny 32x32 textures to use instead of the Standard Shader's property sliders.
    Apparently though Mesh Baker automatically does this for you, converting any slider properties into a small texture that is atlased. Also most shaders have a color input that the albedo texture is multiplied by. Couldn't the atlased textures easily have that color applied preserving the correct color?

    Also, I'm not sure how difficult this would be, but a little bit more control over mesh combining by creating sub "Groups" that are merged together. Right now you either merge all the meshes sharing the same shader, or only merge ones you select.
    I have several static Vehicles all using the same shader that I do want to optimize & combine, but not all as one mesh, I want the vehicles separated so I can still enable/disable them individually. I could do that by "Grouping" the meshes of each car together which are then combined and atlased.
    A workaround right now is having duplicate copies of the shader per vehicle, that way ProDrawCall optimizer combines them each individually.
     
    Last edited: Oct 18, 2020
    jmunozarUTech likes this.
  24. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Thanks for your thoughts!, my comments below
    Correct, Crunch compression has been producing me headaches since it came out; I have tried several workarounds (like uncompress, bake, compress) but they are just plain unreliable and take more time. Its a topic I am not working with anymore but will take a look into it with the newest versions of Unity (hopefully with the new importer API I can do some magic!)

    Mhhm.. this is strange, I will take a look into this. with your same Version and Build target
    One side note: If you have custom shaders called "Standard" this would be an issue since the tool doesn't have a way to recognize between the standard shader and a custom shader that contains "Standard"

    Great point, I remember trying this when I was writing the tool and the results I had where not as satisfactory since if you use a different shader, lets say a fresnel shader you will have not-so-expected results and its difficult to combine several materials all with different values into a single one

    Converting any slider properties into a small texture that is atlassed actually is a pretty good idea, but how do you combine into the same atlas the bumpiness of one texture and the different bumpiness of another one?

    This is a good point and I never thought about it since this was more of a post thought for further squeezing performance, I will note this to work on it on the future since it shouldn't be too complex. Thanks for this! :)
     
  25. FarhezAhmed

    FarhezAhmed

    Joined:
    Dec 15, 2020
    Posts:
    17
    does this work with unity terrain tress and details ?
     
  26. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    hello @AtlasGamingStudio , to have gameobjects optimized by ProDrawcall, you need your gameobjects to have a Mesh Renderr and a material (the shader doesnt matter). So if the terrain doesnt have a mesh renderer it will not work.
     
  27. jubaerjams8548

    jubaerjams8548

    Joined:
    Jun 8, 2020
    Posts:
    41
    Hi jmunozar , Im using the light version of your pro draw call optimizer ,
    now the issue is, I have total 8 materials in the scene and each textures are almost 512x512 , but in my scene there are thousands of objects ...so , when i am selecting all the objects like more than 5 thousands ...then unity shuts down (
     
  28. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    hello @jubaerjams8548,

    Thanks for reaching out, Your issue is that you have 5k game objects in a single scene, it makes total sense that it shuts down since either your OS kills it to get back resources (memory in this case) or Unity itself shuts down.

    I cannot imagine how many triangles each of your mesh has but if you have 8 materials in your scene only then ProDrawCall will not fix your performance issues.

    If I was you I would start by reducing massively the amount of game-objects either by mesh-combining them and (most likely) start reducing polygons or just remove them and use techniques like bill-boarding or alikes to get your object count down.

    If you are using on the other side DOTS (since you have 5k gameobjects), then your issues still shouldnt be related to Drawcalls but due to something else (most likely trianglecount). You should check with the profiler and your data layout (if you are using DOTS) for bottlenecks in your project.

    Hope this helps! :)