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. phoenixrising

    phoenixrising

    Joined:
    Aug 9, 2013
    Posts:
    57
    I got a huge amount of game objects, all with references to each other and I am trying to optimize it with this tool.

    When I ran the tool it made new game objects.
    Now, I would need to go in there and manually find every game object reference and replace the original game object with the optimized one!

    Is there any way to replace the material in the original game object so that all the original game object references will be in tack?
     
  2. jmunozar

    jmunozar

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

    Unfortunately no :(, this is because Unity itself has strict regulations on not changing original objects, thats why the tool creates a copy of your game objects (with the original references) :-/
     
  3. HanzaRu

    HanzaRu

    Joined:
    Aug 10, 2012
    Posts:
    11
    Hello Juan,

    I need to optimize around 60 trees, some of they have tiled bark i'm having issues because the tool doesn't bake correctly the trees with uvs off the limits of the texture (but the package claims to do it). I need to configure something before atlas all they? It is not recalculing tiled texture because *Reuse Texture* is enabled?

    Thanks

    Edit: Yeah, i have found the problem is the *Reuse Texture* enabled, but i think the tool should recognize the "Out of bounds UVs" and allocate a custom texture space for the special objects. You can create a option "Create a unique texture space for Outbound UV's" or something like that.
     
    Last edited: Aug 5, 2015
  4. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091

    Hey @HanzaRu :)

    Couple of things, the tool doesn't work if your UVs are outside [0,0-1,1]
    regardless if it's tiled or not :)

    STILL yes, if you have same texture to bake, but different tiles there you have to un check the "reuse textures" because the tool will think it's the same texture (which it is). But has different tiles :)

    Let me know if you have any other issues ;)

    Cheers
     
  5. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    Hi, what do I do with the .ODCObj after I optimized objects?

    I have 5 zombies in a scene, I used the optimizer and each of them have a new .ODCObj child object. Does this mean I can delete the original mesh or uncheck the original in the inspector or do I just leave it alone and keep both?
     
  6. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    Also the zombies in my scene disappeared, when I press play they show up but the player doesnt. I noticed my players mesh is missing.
     
  7. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    What is combine
    The mesh disappears when I create a prefab of the optimized object. The mesh is missing from the all of the .ODCObj objects so when I call the prefab in a new scene I cant see it because no mesh is rendered.
     
  8. jmunozar

    jmunozar

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

    The ODCObj game objects are the optimized ones that you should use. The other ones have their renderers deactivated so they won't be used :)
     
  9. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    When I optimize an object I can see it on the screen and it works fine. However, if I create a new prefab and drag the object to it, it losses the ODCObj mesh. When the prefab gets called by my spawner all I see is the box collider.

    Can I not use my own prefabs with this or do I always have to create new prefabs with pro draw call optimizer?
     
  10. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hey Dean :),

    Yup, you have to create your prefabs from the tool.

    Notice that if you have mono behaviours referencing old unoptimized objects these references will stay untouched as the tool doesn't know which gameobject are referenced in your scripts.

    Cheers
     
  11. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hey @HanzaRu:)

    just wanted to check on you, did you solved your issues ? :)
     
  12. HanzaRu

    HanzaRu

    Joined:
    Aug 10, 2012
    Posts:
    11
    Yeah, i found my way. I created a script to find all UV's out of bound, and fix manually "final atlased uvs" on the atlased texture.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6. public class MassOutOfBoundSelect : EditorWindow {
    7.  
    8.     public const float delta = 0.04f;
    9.  
    10.     [MenuItem ("Edit/Process/Filter Out of Bound UV")]
    11.     static void SelectOutOfBound(){
    12.         List<int> gobj = new List<int>();
    13.  
    14.         bool OutOfBound = false;
    15.         foreach(GameObject g in Selection.gameObjects){
    16.             MeshFilter filter = g.GetComponent<MeshFilter>();
    17.             if(filter){
    18.                 OutOfBound = false;
    19.                 foreach(Vector2 uv in filter.sharedMesh.uv){
    20.                     if(uv.x < 0 - delta || uv.x > 1 + delta|| uv.y < 0 - delta|| uv.y > 1 + delta){
    21.                         OutOfBound = true;
    22.                         break;
    23.                     }
    24.                 }
    25.                 if(OutOfBound)
    26.                     gobj.Add(g.GetInstanceID());
    27.             }
    28.         }
    29.         Selection.instanceIDs = gobj.ToArray();
    30.     }
    31. }
    i still think you should make this happen automatically (as i had to fix up around 60 uvs of barks manually) creating something like a custom tiled copy of texture, repeat as many times necessary (in width and height) for each outbound obj, resize it and fit it on the map, just to make the plugin "NoBrainAutomaticUVCustomRemappingFix_anything_you_want". Simplygon do this kind of thing, but it merge the objects into one (that's not what i want - thats why i needed your plugin), if i need to separe each mesh again, will again fails into not be a "automatic process".

    But again, your plugin saves me a good time of atlas remapping, thanks :)
     
    Last edited: Aug 13, 2015
  13. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hey @HanzaRu thats great you solved the issue :)!,

    Yeah I thought about that idea of tiling the texture over and over and remapping the UVs, but the issue is that sometimes UVs coordinates are far away from [0,0 - 1,1] so you will get an out of memory exception if you have a big texture :/, I will think about it and do some tests tho.
     
  14. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    Asset always freezes on processing shader: Mobile\VertexLit.

    Funny thing is that its not even that big. I have like 3 textures that are only 512x512 but the program just stops at this shader every time.
     
  15. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    Oh, it worked! Just took a long time, sorry.
     
  16. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Was just gonna reply but saw you fixed it :) Awesome!.

    TLDR; Try to use the tool on stand alone whenever possible, else will take more time

    Just want to add a quick note: if you are building for any platform besides Stand Alone (which seems you are) it will take ~2-3x time to atlas your objects, this is because the tool needs to reimport each of your textures to a readable format, read them, import them back to your original format and then process them :).
    Importing and changing texture formats takes _LOTS_ of time so whenever possible just use stand alone bake and then go back to your original platform.
     
  17. chrisbwallace

    chrisbwallace

    Joined:
    Jul 23, 2015
    Posts:
    7
    Hi there! I'm using the pro version of your tool with Unity 5, and although it seems to do a bang-up job atlasing the "Albedo" channel of my "Standard" materials, it universally leaves out the other channels (normal, occlusion, height map, etc). Is this a known bug? I hope that's not the case and I'm just doing something wrong, because otherwise I'll feel really cheated that this tool was sold as being compatible with unity 5.

    For now, I can use the albedo maps as a template and manually create all the other maps - but that will be an enormous amount of work. Can you please advise?

    Using Unity 5.1.2p3 Personal on a Mac
     
  18. jmunozar

    jmunozar

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

    Being "Cheated" is a strong word :-/ please dont use that word hehe ;) I'm always happy to talk through things and if the tool is not for you / is not what you expect I will not hesitate to order a reimburse :). The idea is that you buy a tool that works :).

    When I say its Unity5 compatible is because it will work with the standard shader and any variant.

    Anyways regarding your issue, they do work. Its strange that they dont work for you.
    Couple of questions:
    - Which version of ProDrawCall are you using?
    - Does the Standard Shader scene example works for you? (it has a normal map as well).
    - Do you have a small example I can check it out? (like 2 objects that fail).

    Cheers ;)
     
    Last edited: Aug 15, 2015
  19. chrisbwallace

    chrisbwallace

    Joined:
    Jul 23, 2015
    Posts:
    7
    In the example scene, the Standard Shader example does exactly what I'm describing: All Standard shaders lose all their maps other than albedo when they are atlased. Standard Specular seems to work fine, but a good example is the "hearse" object in the scene - before atlasing, it has a normal map, after atlasing the normal map is gone.
     
  20. chrisbwallace

    chrisbwallace

    Joined:
    Jul 23, 2015
    Posts:
    7
    See the example that can be downloaded here:

    https://www.dropbox.com/s/y24smghmpetyi41/BugExample.unitypackage?dl=0

    This is a simple scene that uses one mesh and two standard materials. I've included a scene that shows the materials before atlasing, and a scene that shows it after the process is completed.

    Though in this example the other maps are getting atlases (normal, occlusion, etc) - which is not the case in other scenes I've tested this on - you can see from the example that the result is still completely messed up.

    Unfortunately, I think a refund may be in my future. :(
     
  21. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hey Chris :)

    Checkout this screenshot, its from the "Example 7 Standard shader":

    Screen Shot 2015-08-15 at 16.18.20.png
    I just baked it, as you can see, it generates normal maps and albedo mats (in this case). I'm going to check your example tho and will get back to you ;)
     
  22. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    I just saw the problem, indeed its a bug I'm fixing it :) I'll get back to you soon!
     
  23. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Ok, this is actually extremely weird.... it just worked now! D: Screen Shot 2015-08-15 at 16.30.31.png
    I'm still checking what's happening, do you want me to mail you a prefab of the combined object in the meanwhile? :), just private msg me.
     
  24. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    hey @chrisbwallace,

    it works in here perfectly as you saw in the picture above, I have private msged you with a fix that should work :)
     
  25. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
  26. jmunozar

    jmunozar

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

    For those of you who have the infamous "Malformed UVs" warning on your meshes. Here's a workaround you can do to make it look better and avoid having overlapped UVs on your atlases.

     
  27. mehrankan

    mehrankan

    Joined:
    Apr 12, 2015
    Posts:
    61
    Hi, just bought your plugin , and it does a great job of atlassing. so

    but i have ran in to a problem with baking my objects. what's happening is that since you are resizing the uv's (for atlassing) their scale in light map is kinda getting screwed. In other words it looks like Uv2 is also getting scaled, is that the case? cause when I bake these new objects I get very different results.
    It would be awesome if you can have the script update the lightmap scale accordingly too. or not rescale the UV2's?
    do correct me if I am wrong, and let me know if there is a fix for this.
     
    Last edited: Aug 26, 2015
    jmunozar likes this.
  28. jmunozar

    jmunozar

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

    Haha, thanks for the kind words :)!
    UVs have to be remapped so they can fit (0,0-1,1) in the generated atlas; else you will have shared textures across your objects and they will look bad :(. On UV2, its the same story.

    What different results are you having?, could you send me a screenshot and perhaps a small test case where you get different results so I can check it out? :=)
     
  29. huynhke

    huynhke

    Joined:
    Jul 9, 2014
    Posts:
    15
    Hmm, I'm wondering, as I add selected objects to my list of things to optimize, how is it choosing the size that the texture is? Next to the texture (on the list) it'll say (2048x2048), but the object that I chose has a texture size of (256x256).

    I'm asking this because the object is a small object and it's taking more space than the larger objects on the atlas page.
     
  30. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    hey @huynhke ,
    The atlas texture size is an approximation, this is because the algorithm to organize all your textures in a big atlas is NP complete.
    Now, if you are not reusing textures and you have more than one of the same game objects repeated, this will increase your atlas size.

    Hope it was clear :) else, just let me know ;)
     
  31. mehrankan

    mehrankan

    Joined:
    Apr 12, 2015
    Posts:
    61
    @jmunozar, but for uv1 (second uv channel) I would like to have my UV's intact, because the light map scale is very improtant for me in my work. The light mapper and the second uv channel work independently from what is happening in the shader (in terms of what the uv 0 scale is), so (IMHO) there is no need to tweak the lightmap uvs.
    right now the workflow I am looking at is
    1 : shade the objects
    2: optimize with the pro optimizer)
    4: set light map scales correctly
    3: and than light bake,
    but since you are changing the uvs in light map channel my calculations for the lightmap scale are coming out very very wrong, and after the bake the object is getting much less pixels in the lightmap than it would have gotten with out the optimizer.
    in short I dont want to optimize my lightmap space, I just want to optimize my shader space , so is it possible to just put a check box in there to not bake the light maps?
    (do correct me if I am wrong)
     
  32. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    hey @mehrankan

    Yes, you are right, that's the workflow one should follow :).

    BUT, I'm modifying the other UV channels because 1 month ago another guy complained that his light maps where overlapping (hence the image was looking bad).

    STILL: you have a valid point regarding not atlasing certain UV channels. I'm going to look into it today and will get back to you ;)


     
  33. mehrankan

    mehrankan

    Joined:
    Apr 12, 2015
    Posts:
    61
    @jmunozar you is a champ man :) thanks . I think it could be nice if you can just add some sort of a checkbox "Don't atlas lightmap uvs" :D or something like that, this way everyone wins.
     
  34. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hey @mehrankan,
    indeed, that's what I'm planning to do 4 checkboxes one for the 4 uv channels available, you select the ones you dont want to atlas ;)
     
  35. jmunozar

    jmunozar

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

    just sent you a private msg. I'm uploading the new version as I'm writing this as well.
     
  36. huynhke

    huynhke

    Joined:
    Jul 9, 2014
    Posts:
    15
    I hope I'm reading correctly, but I'm not asking about the atlas that gets outputted. But I have an image here to describe what i'm talking about!

    The image is a 256x256 texture, but in the ProDrawCall window it appears as a 2048x2048
     

    Attached Files:

  37. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Ah, I understand.

    That happens because the tool works with the original image file, not with the compressed version that Unity creates for you that you can tweak at your will :). There is not much that can be done there but resize your image with a 3rd party program if you want your texture to be 256x256.

    If you want just open that image in Gimp / Photoshop and check its size and it will be that big :)
     
  38. huynhke

    huynhke

    Joined:
    Jul 9, 2014
    Posts:
    15
    Ohh okay thank you it works! Bummer, was hoping it could take the size that unity compresses it to so it's more convenient if we want to up-rez down-rez. But then again, this whole plug in is convenient already ^_^, thank you!
     
    jmunozar likes this.
  39. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Thanks to you for supporting my work :), I'm glad you like the plugin and helps you out with the workflow! :)
     
  40. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    How can I use a second atlas? I need to optimize twice, 1 for my scene and 1 for my characters because I have to chose create new prefabs with them. After I optimize my scene I have 1 atlas but when I optimize for my characters it erases the scene atlas and I'm left with just the characters optimized. How can I keep both atlases? The asset seems to work better when I optimize my charactes separately anyway. If I do scene and characters together then I get a blended atlas with scene textures on my characters and vice versa.
     
  41. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    hey @DeanMarquette ,

    Just uncheck the "Remove atlasses before bake" checkbox in the advanced menu and you are good to go. :)

    With that whenever you bake something, the atlases already baked are not going to be deleted.
     
  42. jeffries7

    jeffries7

    Joined:
    Jun 25, 2014
    Posts:
    59
    Just bought the asset and it works really well, i'm really impressed.

    However I seem to be getting issues on certain objects being not optimizable with an error description that isn't very imformative (i'll attach a screenshot). The mesh has a mesh filter, renderer and only 2 materials. Any ideas?

    Also sorry if this has been addressed previously, I looked back through the thread but I couldn't find anything.
     

    Attached Files:

  43. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    hey @jeffries7,

    Thanks for supporting my work! :)
    Try expanding the window it *should* give you the complete message (if not then its a bug! and I will fix it. Let me know tho).

    Second thing, it might be that the object that has 2 materials has different shaders, if it does then its impossible to optimize because the tool would not know which shader to use when combining your materials :)

    Let me know if you still have issues tho! ;)
     
  44. jeffries7

    jeffries7

    Joined:
    Jun 25, 2014
    Posts:
    59
    Thanks for the quick response.

    I think it is a bug as the first thing I tried was to widen the tab, i'll attach a screenshot.

    The object(s) are all using the standard shader, the only difference is that some are using solid colours and other are using textures but I didn't think that this would cause the issue.

    It's worked on some of my assets, but not on the ones that need combining the most unfortunately.
     

    Attached Files:

  45. DeanMarquette

    DeanMarquette

    Joined:
    Feb 10, 2015
    Posts:
    165
    PERFECT! I had forgotten to rate this asset but I just did and gave it 5 stars.

    Pro Material Combiner - I never seen this asset before! If I get this would I use it before or after Pro Draw Call or do I just use one?
     
  46. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Haha hey @DeanMarquette

    Thanks a lot!, it really helps me out and thanks for the kind words!.

    If you have already pro drawcall optimizer there is no need to buy pro material combiner :), As pro drawcall does that for you already in the tool automatically ;)

    Again, thanks!
     
  47. jmunozar

    jmunozar

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

    Seems it's a small bug the GUI thingies, I'll fix it when I get home;.

    Regarding the assets to combine, could you send me that mesh as a package so I can check it out and tell you what's happening?.

    If you can't it's totally understandable, send me screenshots of your materials instead :)
     
  48. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    Can you choose the size of the resulting atlas? Let's say you want it to be 2048 or 4096 or whatever. Will this auto shrink them causing the textures to blur or will it keep the original texture map sizes.
     
  49. jeffries7

    jeffries7

    Joined:
    Jun 25, 2014
    Posts:
    59
    Unfortunately I can't send the mesh as a package as it was for our company. I can however send sceenshots just before leave the office.
     

    Attached Files:

  50. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello @Teila
    Short answer: not possible
    Reason:

    This happens because the tool atlases your textures exactly as you have them so you don't lose quality :( (even tho you do at some extent because of floating point errors in UV coordinates).
    BUT what you can do and it will work just fine is resizing the resulting atlas after baking.