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 @ader42 ,

    Its not likely that I will release a version that works with skinned mesh renderers just because the light version (even though it seems it does the same) its totally different on the inside from the ProVersion. And that requires time. The main intention for the light version is to quickly assess if the tool will work for your needs or not.

    Being said that, seems that if you want to just combine materials I would recommend you to use ProMaterialCombiner https://assetstore.unity.com/packages/tools/pro-material-combiner-29312 or the ProMaterialCombiner++ version: https://assetstore.unity.com/packages/tools/pro-material-combiner-22860

    They do both exactly the same; the only difference is that in the ++ version you have access to the source code and you can batch several objects for material combine.

    Hope this clears more your needs :). Of course, if you still want to buy the Pro Version of ProDrawCall, I assure you it works with skinned mesh renderers. DO make sure that your objects' UVs are contained within [0,0 - 1,1] though, and that should be enough :)
     
  2. ader42

    ader42

    Joined:
    Jan 5, 2015
    Posts:
    7
    Hi @jmunozar, thanks for coming back to me, will check out your various products again but yes I now think your Pro Material Combiner ++ is what I need.
     
    jmunozar likes this.
  3. narger

    narger

    Joined:
    Dec 2, 2014
    Posts:
    51
    Hello @jmunozar and thanks for your asset. I'm developing a 2D mobile game and i'd like to see it running at 60fps, therefore i need to combine as much draw calls as I (you xD) can.
    I was wondering if this gonna work with both sprites and Text Mesh Pro (in my scene i've only got sprites (Sprite-Diffuse shader) and texts (TextMeshPro-DistanceField shader).

    Thank you in advance
     
  4. jmunozar

    jmunozar

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

    Unfortunately it will not work, your game objects need to have a mesh renderer and a mesh filter; and in your case your game objects dont have a mesh filter. hence will not work :-(
     
  5. narger

    narger

    Joined:
    Dec 2, 2014
    Posts:
    51

    Ok good to know, thanks anyway. Gonna buy it as soon as I'll start 3d developing :p
     
    jmunozar likes this.
  6. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Thanks to you for supporting my work :)!
     
  7. Rodmanix

    Rodmanix

    Joined:
    Dec 4, 2012
    Posts:
    14
    Considering purchasing this asset but I have one question first. How does it handle large scenes with more than a thousand game objects with many different materials?

    Thanks!
     
  8. jmunozar

    jmunozar

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

    It will be slow. Reaaally slow. Material combine is dead slow. And if your scene is really really huge. You might need to split it in different parts to batch them as you might get an out of memory exception

    Hope it answers your question :)
     
  9. Slowbud

    Slowbud

    Joined:
    Jul 19, 2015
    Posts:
    81
    Hi @jmunozar
    the optimizer tells me "Different types of sta". I guess it means: different types of standard shader.
    But I set all (they are 28 for one mesh ;) ) to Standard (metallic) and Opaque.
    Any suggestions?

    Edit: They are 28 materials and 14 shader
     
    Last edited: Mar 20, 2018
  10. Slowbud

    Slowbud

    Joined:
    Jul 19, 2015
    Posts:
    81
    Another question. After baking (another object), I get an .ODCObj, this has no mesh assigned, how can I get the mesh. I need it for exporting a mod.
     
  11. jmunozar

    jmunozar

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

    In the settings, set the "generate prefabs" checkbook. That should generate you a prefab and a mesh for each optimized object ;-)
     
  12. jmunozar

    jmunozar

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

    What that message means is basically that you have set different different slot textures in the materials. In order for.it to.work; you need to set all your material's texture slots to be the same. I.e all the materials having albedo textures.

    Let me know if it's not understood and I can elaborate more :).
     
  13. Slowbud

    Slowbud

    Joined:
    Jul 19, 2015
    Posts:
    81
    @jmunozar So, if I set in one shader a normal map, I have to put in all 14 shaders a normal map, Same witht the metallic slot? But these maps/ textures can be different in the other shaders?
     
  14. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Yes. That's basically it.

    It happens because the standard shader compiles internally as a different shader depending on the textures you have assigned. Hence it's treated as a different shader both by unity and the tool :)
     
  15. Slowbud

    Slowbud

    Joined:
    Jul 19, 2015
    Posts:
    81
    Thanks, you helped me a lot :)
     
    jmunozar likes this.
  16. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Awesome! :). I'm glad you solved your issue :)
     
  17. Slowbud

    Slowbud

    Joined:
    Jul 19, 2015
    Posts:
    81
    @jmunozar Sorry, another issue, above works now, but the Atlas for the normal maps is pink instead like the originals purple. So the normal map is far away from working correct. And can I get the Atlases bigger? I'm told they will be 9758 x 9785 + 2,5% TOO BIG Atlas will be sp... rest is truncated. A 8192 px would be fine.

    Edit: It it doesn't seem to reuse the textures as checked, each texture is 4 times on the Atlas.
     
    Last edited: Mar 21, 2018
  18. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    hello @Slowbud, For the normal maps, there is now way to assess for the tool if a texture is a normal map or not, sometimes the tool might infer but its now always the case. For that, you will have to go to the project folder and go to the generated normal map texture and set it as a normal map.

    Another thing that you have to bear in mind is that you are combining different materials with different bumpiness values. The result is 1 material but you will have to tweak manually the result material to your desired bumpiness both in the material properties or in the texture itself (in case is a normal map).

    Regarding the atlases size. the max atlas size supported by unity is 10k, The result size is an estimate as it cannot be calculated beforehand precisely.

    Regarding the texture reuse; you have to make sure that all your textures from all the materials are exactly the same to be able to have a texture reuse, else it will not do so. and if you have the same texture but duplicated in the project; it will be treated as a different texture also :). Hope this helps :)
     
  19. Slowbud

    Slowbud

    Joined:
    Jul 19, 2015
    Posts:
    81
    @jmunozar The next one ;)

    Error when Generate Prefabs is checked. What happens, the new mesh is created about more than 1 meter above, outside the rigged bones.

    Mesh.boneWeights is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array.
    UnityEngine.Mesh:set_boneWeights(BoneWeight[])
    ProDrawCall.MaterialCombiner:CombineMaterials(GameObject, String, Boolean) (at Assets/ProDrawCallOptimizer/Scripts/Editor/Core/MaterialCombiner.cs:104)
    ProDrawCall.OptimizableObject:processAndCombineMaterials() (at Assets/ProDrawCallOptimizer/Scripts/Editor/Core/OptimizableObject.cs:68)
    ProDrawCall.OptimizableShader:OptimizeShader(Boolean, Boolean, Boolean) (at Assets/ProDrawCallOptimizer/Scripts/Editor/Core/OptimizableShader.cs:159)
    ProDrawCall.ProDrawCallOptimizerMenu:OnGUI() (at Assets/ProDrawCallOptimizer/Scripts/Editor/GUI/ProDrawCallOptimizerMenu.cs:138)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  20. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Interesting.

    Send me an email with your order number and a small test case that I can reproduce :)
     
  21. shrinebot

    shrinebot

    Joined:
    Sep 12, 2014
    Posts:
    16
    Hello, im using Unity 5.6.3f1 and getting the error after downloading (I notice a previous issue with this on a different version of unity), any updates. Thanks

    /ProDrawCallOptimizer/Scripts/Editor/Core/ShaderManager.cs(39,39): Error CS0019: Operator `==' cannot be applied to operands of type `UnityEngine.Rendering.TextureDimension' and `UnityEditor.ShaderUtil.ShaderPropertyTexDim' (CS0019) (Assembly-CSharp-Editor)
     
  22. jmunozar

    jmunozar

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

    What version of ProDrawCall are you using?. That bug was fixed long time ago. Could you please PM or email me your order number, OS being used and target platform :)
     
  23. AdamKane

    AdamKane

    Joined:
    Dec 3, 2012
    Posts:
    134
    Hi, In this shot, how to I make it so that I can read the red error text? It is clipped.

    error.png

    Thanks,
    Adam
     
  24. jmunozar

    jmunozar

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

    That says "Different types of standard shader". I am working on an update to address those GUI problems for clipping.

    Basically what it says is that that object has multiple materials and the materials are different. (Even though if they use a standard shader). They are different because your materials use different texture slots.

    So to solve that issue, you need to make all your materials in the standard shader use the same number of textures.

    Hope it helps and again I'm working on a UI update. ;-).

    Do let me know if you have more questions.
     
  25. AdamKane

    AdamKane

    Joined:
    Dec 3, 2012
    Posts:
    134
    In the city model asset I'm using, some of the standard shader materials use 1, 4, 5, 7, 9, 11, 12, or 17 textures (see below). Is it right that all materials, must use exactly a certain number, like 6?

    city.png

    How might I proceed if there are hundreds of different materials, all using Standard Opaque shader, but with lots of different numbers of textures?

    Thanks,
    Adam
     
  26. jmunozar

    jmunozar

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

    Yes, you will have to add white textures and make all the materials have the same textures. This is how Unity's standard shader works.

    Unity Internally changes the standard shader depending on the number of textures you have assigned; hence the engine treats different assigned textures on the standard shader as different variants of standard shader.

    So at the end yes, its a "Standard opaque shader" but one standard opaque shader with 2 textures is a completely different standard opaque shader with 3 textures (as in it gets processed in a different pass call).
     
  27. shrinebot

    shrinebot

    Joined:
    Sep 12, 2014
    Posts:
    16
    I noticed that the version in the readme was 4.2, so I copied the ProDrawCallOptimizer folder from another project I had which was on Unity 5.5.2 and it had 4.3 in the readme, even though I had downloaded that last August. So seems like something strange with Unity downloading an older version!?!? That or something to do with ghosts...

    Anyways error has disappeared, cheers
     
    jmunozar likes this.
  28. Middelbo

    Middelbo

    Joined:
    Apr 30, 2013
    Posts:
    9
    Just purchased the pro version and found that normal maps end up like this:
    upload_2018-5-24_14-32-21.png

    The texture is imported as a normal map in Unity ...
    Until this is fixed the plugin is useless.
     
  29. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello middelbo.

    As I have mentioned before. The tool infers if your textures are normal maps or not. It's not always accurate.

    To solve this issue. You just need to select the generated texture. Set it as a normal map and and click in the checkbook (in the texture import settings) "generate alpha from grayscale". That will fix your normal textures :).

    Do remember that you are combining all your material's so some tweaking in the "bumpyness" in the final texture will be needed to be done. :)
     
  30. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hey Midelbo,

    Another user just mentioned me this:
    "set textures with the texture type "normalmap" to a default texture format before it converts and then set it back to "normalmap" texture type after conversion. Then you convert normapmaps correct!"

    I will be taking a look into this issue throughout the day but in the meantime you can try this workaround :).
     
  31. fariazz

    fariazz

    Joined:
    Nov 21, 2016
    Posts:
    55
    Hi there, just purchased the plugin. Got a massive draw call reduction which pushed our game from 45 fps to 58 fps in GearVr.

    We are however experiencing a problem with a texture which looks horrible.

    This is what it looks like before atlas generation: https://www.screencast.com/t/PAbRwC0v

    This is what it looks like after atlas: https://www.screencast.com/t/PAbRwC0v

    This is the texture settings: https://www.screencast.com/t/EJWng7HRij

    Plugin settings (tried with and without power of two): https://www.screencast.com/t/N9NWXYRj

    Generated atlas file: https://www.screencast.com/t/Jc4747l82elh


    Do you know how to fix this issue?
     
  32. jmunozar

    jmunozar

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

    The before and after results look the same (you uploaded the same image twice :-(). But as I see a road I can guess that maybe it looks with neighbor textures. The reason of this is that you are tiling the mesh from the uv coordinates instead of the material property.

    To understand this checkout this video:


    And a video on how to kinda fix it:


    Hopefully this will help you guys out :), let me know how it goes ;)
     
  33. fariazz

    fariazz

    Joined:
    Nov 21, 2016
    Posts:
    55
    jmunozar likes this.
  34. fariazz

    fariazz

    Joined:
    Nov 21, 2016
    Posts:
    55
    I didn't get warnings in the console like in the video. The model was of extension ".asset" (it had been exported using the Mantis LOD plugin) so I couldn't open it anywhere to check it's uv mapping. Ended up just re-exporting the models from Blender and doing the vertex reduction there, then your plugin worked like a charm!

    Next time I use Mantis LOD I'll use the Windows app instead of the Unity Editor plugin, as I think that one exports as fbx not asset.
     
    jmunozar likes this.
  35. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Ah thats pretty neat!, I'm glad it worked for you guys! :)
     
  36. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    422
    @jmunozar

    Just a few thoughts... that normal map issue is super annoying, although once you know about it, it's easy enough to click on 'create from greyscale' and then Apply. It's information that's soon buried in a thread like this. You should add it to the Known Issues in the readme.

    Also, I found that when combining a cutout shader, (LegacyShaders/transparent/Cutout/BumpedDiffuse) the alpha cutoff in the newly created material was way off. As each (source) material may have different values it might be an idea if the new value took perhaps a mean of the sources. In my case they ranged from 0.05 to 0.15 but the new material defaulted to 0.5 which actually made my objects invisible. Took me ages to work out what was going on! :)
     
  37. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hey @jeromeWork !,

    Thanks a lot for the feedback!, indeed, I will add the "Create from grayscale" known issue to the Readme.

    Regarding the Alpha values on the cutout shader, you are right But, the issue is that there is no way to know beforehand when someone has a float value what does it do. That's the reason the values are set to the default the shader comes with. You do have a valid point; I will add that to the known issues.

    Again, thanks to the feedback :)!, And for everyone, do not hesitate to pm me with issues/feedback; I'll be more than happy to make modifications that make sense to make the tool better! ;)
     
    MoribitoMT and jeromeWork like this.
  38. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    301
    Hi,

    I have a simple suggestion for this tool. When its creates Prefabs, it puts Mesh and Prefab files in same folder. It would be better to have Meshes / Prefabs folder separately, it could be optional.
     
  39. jmunozar

    jmunozar

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

    Good suggestion, it would make generated assets more organized. :)
    Added it to my todo!
    Thanks!
     
  40. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    301
    Hi,

    I want to tile specific textures from created atlas, how can I achieve this, do I need new kind of shader, any tips on this ? I have 4 floor textures mapped into 1 atlas. I ave 1x1 prefabs size, I want variation like 3x3, 10x10 size, so new sizes I want to use same atlas and tile each floor texture individually..
     
  41. jmunozar

    jmunozar

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

    In that case you will have to bake three different atlases and change the textures on the fly within the tool after a texture is baked, its not possible to modify it as several objects share some parts of the texture.

    Hope this helps! :)
     
  42. foxbooz

    foxbooz

    Joined:
    Sep 3, 2017
    Posts:
    11
    Hello
    We needed a quick method to generate LODs with fewer materials. The problem comes in when you have multiple individual objects that get dynamically loaded rather than a whole scene of items. It would be much better if you could build each object individually, then add as you need. Currently you need to separate the objects into their own scenes in order to do this.
     
  43. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @ImagFox,
    To solve this, what people normally do is create a scene with the objects and generate prefabs from the objects; with this you can place your objects dynamically just by loading them from the pre-baked prefabs :)
     
  44. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    422
    @jmunozar I'm trying to combine the materials on a skinned mesh (using ProDrawCallOptimizer v 4.3.5 on Unity 2018.2.20) All use the Standard shader but using different rendering modes - some are opaque, some cutout, some transparent.
    I was hoping that ProDrawCallOptimser would allow me to create three different atlases for each of the shader variants, but I'm getting a 'Not Optimizable' error. The explanation gets truncated in the window's GUI so it's impossible to know what the actual problem is:

    I'm guessing the problem is that the asset can't create three different materials on the same object? Is it possible to add this functionality?
     
  45. jmunozar

    jmunozar

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

    The standard shader is a shader that mutates and compiles internally to a different shader when different variables are set. This includes the rendering mode.

    Unfortunately this means that if the shaders have different modes it implies that they are recognized as different shaders.

    If you still want to combine them then you will have to (unfortunately) set your objects to have the same type of rendering mode and same texture slots; combine them and then change the rendering mode afterwards.

    Still this will not represent an improvement as internally they will be two different shaders :)

    Cheers :)
     
  46. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    422
    @jmunozar Thanks that makes sense. Would it at all be possible to add the functionality to ProDrawcallOptimizer so that it atlased the similar variants into different material slots?
    So in my example above, where I have three types of render modes (shared across 15 materials), the mesh after optimisation would then have only three material slots - each with the different materials atlased by shader type.
    Does that make sense?
     
  47. jmunozar

    jmunozar

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

    Yes it possible to reduce the multiple materials into smaller subset of materials but that would require a whole restructure of the architecture of the app as there are new edge cases to take care of; Being said that. Its one of the things I have in mind to address in the far future but as its something that requires a revamping on the whole app and needs a _lot_ of time. Now; if you are referring to different game objects then that functionality is already implemented except for render modes (if i remember correctly) as its something that Unity's API opened after the initial version was developed :).
     
    jeromeWork likes this.
  48. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    422
    Well if you could add that functionality it would be a great addition, and definitely a selling point for potential buyers :)
    And yes, I do mean on a single gameObject.
    Thanks again.
     
    jmunozar likes this.
  49. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    336
    @jmunozar Hello, when attempting to use this plugin on a rigged model with "optimize game objects" enabled, I get these errors:

    Code (CSharp):
    1. Bones do not match bindpose.
    2. UnityEditor.AssetDatabase:CreateAsset()
    3. ProDrawCall.OptimizableShader:CreateAtlasMaterialAndTexture(Atlasser, String, TextureReuseManager, Int32, Int32, Int32) (at Assets/ProDrawCallOptimizer/Scripts/Editor/Core/OptimizableShader.cs:423)
    4. ProDrawCall.OptimizableShader:OptimizeShader(Boolean, Boolean, Boolean) (at Assets/ProDrawCallOptimizer/Scripts/Editor/Core/OptimizableShader.cs:212)
    5. ProDrawCall.ProDrawCallOptimizerMenu:OnGUI() (at Assets/ProDrawCallOptimizer/Scripts/Editor/GUI/ProDrawCallOptimizerMenu.cs:138)
    6. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    Code (CSharp):
    1. The input bones do not match the skeleton of the Avatar(HumanMale_no-body-morphsAvatar).
    2. Please check if the Avatar is generated in optimized mode, or if the Avatar is valid for the attached SkinnedMeshRenderer.
    Is this a known limitation? I'm trying to optimize my skinned mesh renderers as much as possible (hence using this atlasing plugin), so I use "optimize game objects" for all of my rigged models.
     
  50. jmunozar

    jmunozar

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

    Seems to me that your skinned mesh renderer doesnt have the same amount of vertices vs bones, hence the plugin will generate a mismatch and it will pop that error.

    The included examples come with a skinned mesh renderer scene; there there is a character that has bones, If you can, Open said avatar and yours on any 3D modeling tool that supports animations and compare that avatar vs your avatar and you will likely see that your mesh is incomplete/has unmatching number of bones vs vertices :).

    Hope this helps! ;)