Search Unity

One Batch: Combine hundreds of materials into one draw call

Discussion in 'Assets and Asset Store' started by jbooth, Sep 14, 2018.

  1. AlterSpace

    AlterSpace

    Joined:
    Jun 29, 2014
    Posts:
    34
    Could you take a look to the OneBatchData function for the Amplify Shaders and see if everything is working fine? In my previous message I described what I've found, but sadly I have no idea how to solve it.
    I was sure it would have worked out-of-the-box and now I'm stuck with an incomplete optimization :'(
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Yes, I'll take a look soon.
     
  3. AlterSpace

    AlterSpace

    Joined:
    Jun 29, 2014
    Posts:
    34
    Thanks. I'm on a razor's edge for a demo that I should show, so here it is why I'm so annoying :confused:
     
  4. ivangarciafilho

    ivangarciafilho

    Joined:
    Sep 2, 2015
    Posts:
    27
    I had some issues :
    • The occlusion map slider on onebtach config is handling the emission of my materials;
    • Emission slider isn't handling anything at all (with or without a map);
    • Metallness and smoothness values are not handling anything at all (with or without a map);
    • Cutout value isn't handling the cutout value of my vegetation and it's weirdly handling the opacity of my detail maps;
      The emission color nor the albedo color are not HDR as the standard shader does;
    • Trying to increase the resolution of my maps from 1024 to 4096 is causing my unity to crash;

    Few things i would be really thankful if you could implement them (even on another paid extension pack of shaders variants) :
    • Compatibility with LWRP/HDRP;
    • Compatibility with most of the uber shaders on Assetstore : Uber / Lux Plus / Apollo;
    • Different Versions of OneBatchShader : vegetationVfx / snowVfx / mossVfx / wetVfx / puddlesVfx / rainVfx / sandVfx / GlassVfx;
     
  5. patrykk

    patrykk

    Joined:
    May 20, 2017
    Posts:
    13
    I've upgraded my project to 2019.1 (not any scriptable render pipeline, just the old default one), and suddenly all my onebatched objects became completely black - seems like a shader issue?

    Anything I can do about it?
     
  6. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You might try reverting them and recombining them. I did a quick test of one batch on 2018.1, but maybe something didn't upgrade right on the already batched assets?
     
  7. patrykk

    patrykk

    Joined:
    May 20, 2017
    Posts:
    13
    @jbooth Thanks for the reply. Tried reverting - it did absolutely nothing, and also some of the meshes are no longer assigned to the meshfilter - show up as "missing mesh", even though the meshes created (copied?) by your module actually exist in the Onebatch folder. So I ended up undoing all this manually, cause I have to move on with the project.

    So as far as you know all should work OK on 2019.1?
     
  8. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So, I may remove all of those sliders and settings in a future version of One Batch. The thought is to make the workflow such that you uncombine the objects and change settings, then recombine them. The main reason to do this would be to make supporting more shaders easier- because right now the process of supporting shaders is very labor intensive. If there's no GUI to write for each shader, then it makes it a lot cheaper to add new ones.

    The main way I've seen One Batched used at the studio level is as part of the build process, which doesn't need a GUI for. But I do realize some people use it for individual assets and such, not project wide.

    It's unlikely that one batch can be made to work with 3rd party shaders and released- this is because it would require taking their shader code and heavily modifying it all, which would mean releasing their shader code as part of my asset. You could do those modifications on your own branch of course, but depending on how those shaders are structured it might be quite difficult.
     
  9. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Like I said I tested on my example project and it worked fine, but it's quite possible your setup has some new complexity which causes an issue. There is a new prefab workflow and they may have changed some internal or something.
     
  10. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    Hi, could you make an update for 2018.3? I'm running 2018.3.14 and the example scene is just black. All the examples are there but no textures are being displayed.
     
  11. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I’ll take a look
     
  12. toctoccontato

    toctoccontato

    Joined:
    Jan 14, 2019
    Posts:
    11
    eu comprei o ativo oneBatch porem nao consigo usar cutout, fade e tranparencia funcionam, mas o cutout nao. oque devo fazer? Agora não funciona frente verso "double sided" Existe algo que pode ser feito? obs: cheguei aqui clicando em "Site Suport".
     

    Attached Files:

  13. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    @JasonBooth Hi have you make any progress on this yet? Totally unusable in 2018.3.14 at the minute unfortunately.
     
  14. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I installed on 2018.3 and 2019.1 and can't repro your issue. If you are installing into an existing project you might try installing it into a new project to verify.
     
  15. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    316
    Hmm, not sure what's wrong then. I installed into a fresh project, opened the demo scene and the examples are still just completely black. The textures are set, but blank on the material, though you are able to see a preview.

    This is across all views - Scene, Game and Play Mode. Is there some extra step required for installation apart from importing from the store?
    OneBatch.jpg
     
  16. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    nope, can you try a different unity version and see what happens? When I get back home I can test on windows as well (on OSX laptop).

    One other thought- make sure your not running under graphics emulation..
     
  17. Cowsep

    Cowsep

    Joined:
    May 31, 2017
    Posts:
    5
    Hi,

    My materials also turn black when using One Batch on Unity 2018.3.0f2 (even example ones)

    Is there a fix to it? Is it maybe a version issue?

    Thanks!
     
  18. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That's odd since that's the development version. On windows? OSX? I take it your materials are using the standard shader?
     
  19. Cowsep

    Cowsep

    Joined:
    May 31, 2017
    Posts:
    5
    It was on Windows. Originally I was using a different shader but I switched to Standard and it still didn't work.

    I also tried just using the example and still got black spheres.

    https://gyazo.com/860c0d8b3710ed27d4fa131b16c4b448

    I'll probably be updating soon so I can let you know if that fixes the issue, maybe I just did something wrong somewhere.
     
  20. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Actually, check to make sure the example scene isn't already converted (using the one batch shader).
     
  21. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    438
    HI,
    awesome asset! But since my project relies heavily on HDRP - do you maybe have some ETA about srp compatibility for OneBatch?
     
  22. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Not working on this currently, especially as the pipelines are not really stable yet.
     
  23. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    438
    Maybe I am wrong but it seems that LWRP is out of preview state. HDRP is scheduled for 2019.3 I belive.
     
  24. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    LWRP is “out of preview” but yet they are doing massive breaking changes to it. You can believe the hype, but neither pipeline is near stable enough for the average asset store project. If you have a graphics engineer on hand, great, but most don’t. Producing anything of significant shader complexity for the SRPs is just a massive headache right now, especially since they scrapped the surface shader abstraction.
     
  25. DavidLieder

    DavidLieder

    Joined:
    Feb 14, 2016
    Posts:
    84
    Hi Jason, in regards to LWRP, etc., do you suggest that projects starting now should just stick with vanilla 3D workspace, with optimizers like Microsplat and One Batch (and other optimizers for vanilla 3D Unity)?

    Given the Unity history of needing years to work out bugs in new stuff...??

    I ask because I'm beginning an important new project that will take a few years to complete. If you could give me your thoughts I would appreciate it. From what you've said (and I implicitly trust your opinion), I'm thinking these pipelines are a gamble at the moment, and might be for a while, considering that my studio is trying to create a professional product to release on the market.
     
  26. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Do you have a graphics engineer? If you do then something like LWRP might make sense. Without one it’s a harder decision.
     
  27. Rodmanix

    Rodmanix

    Joined:
    Dec 4, 2012
    Posts:
    14
    Hey Jason, I bought this tool but unfortunately I'm still working in Unity 2017 and it would not let me download it. Switching over to 2018 is not an option. Any way possible you could do a build for 2017?

    Thanks,
    Rod
     
  28. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    No, it uses 2018 only features.
     
  29. Rodmanix

    Rodmanix

    Joined:
    Dec 4, 2012
    Posts:
    14
    Any way that I could get a refund?
     
  30. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    PM me..
     
  31. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Hi Jason, does this work with the Hybrid Renderer?
     
  32. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You mean rendering from DOTS? Shouldn't care- there's no runtime component what so ever, it just generates meshes/materials at edit time that share a single material.
     
  33. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Yes, that is what I meant :) Sounds good, will give it a try!
     
  34. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Another question we have an in-game editor where we assemble our assets, is it possible to do the generation at runtime?
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Not really designed or suitable for that.
     
  36. anpd03

    anpd03

    Joined:
    Aug 7, 2013
    Posts:
    65
    Got it, thanks.
     
  37. zeux-n00b

    zeux-n00b

    Joined:
    Nov 4, 2017
    Posts:
    73
    Hi!
    I need a clue: I have lots of (3d objects) meshes that share over 50 materials here and there + 6 material are Uber Shader. And baking is fine if all uses Standard Shader, but not if some are Uber, so...?
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    switch them to the standard shader - or remove those objects and keep them as the Uber shader.
     
  39. rmon222

    rmon222

    Joined:
    Oct 24, 2018
    Posts:
    77
    Hi. We have a semi-large project with 60 or so materials made with OB. Each material has several textures. As soon as I instantiate the first object the screen freezes for 10 seconds. Subsequent instantiations are instant. Is this normal? Any way to stream the loading process in the background?
     
  40. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You should catch it in a profiler and see what is causing it. It's possible that you're not prewarming your shaders and since the standard shader is massive (and OB uses a modified version of the standard shader) that it's compiling it on the fly, but that depends on what platform your running on (some use precompiled shaders, some compile on first use). But the sure fire way is to look in the profiler and see what is happening.
     
  41. rmon222

    rmon222

    Joined:
    Oct 24, 2018
    Posts:
    77
    The profiler just hangs for 10 seconds just like the editor so additional data points there. So, the behavior is, while in the editor there's a 10-second hang when the first of 60 OB materials is rendered. While in the build, there's a 10-second hang when you launch the app which is the best place for it but it still adds 10 seconds to loading time. I'm on a PC which I assume uses precompiled shaders in the build.

    Correction: all 60 objects actually share one OB material. Our 3d artist really optimized these objects.
     
    Last edited: Oct 5, 2019
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    You’ll have to use a non-unity profiler that can show you what unity is doing while it’s paused. Without that it’s impossible to say what it might be; on Windows the shader would already be compiled, so it’s not that.

    one rare case I’ve seen is Unity serializojg texture arrays into YAML instead of binary when set to forced ascii, but that’s only in the editor.
     
  43. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    Hi

    Awesome tool

    What about URP support for 2019.3-4?
     
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    not working on it currently..
     
  45. CD_MT

    CD_MT

    Joined:
    Jul 18, 2019
    Posts:
    9
    Hello. I'm getting the following error when building for Oculus Quest (aka Android) :
    Texture Creation failed 'ASTC_RGBA_8x8' is not suported on this platform


    Would you be able to provide any guidlines for settings for this platform please? (I'm trying some things, but Unity rebuilds the whole project when you change such settings, so it's quite a slog)
    Cheers!

    Further to this, its worth pointing out that this results in a NullRefException Error, which results in at least one of the meshes not being set to the OneBatchStandard shader. Additionally it leaves me unable to revert the combine.
     
    Last edited: Dec 2, 2019
  46. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    That seems a little odd since I'm pretty sure ASTC is the suggested format in the Quest docs. Note that the texture format can be overriden on the config, so you don't have to reimport your whole project to test. Your other option would be to try ETC2.
     
  47. CD_MT

    CD_MT

    Joined:
    Jul 18, 2019
    Posts:
    9
    Hey @jbooth - I've not been able to get this to function with my scene.

    Setting all 'Default Texture Settings' to ForceETC2 did eventually allow the process to run with no NullReferenceException error.
    I do still get warnings though...
    ETC2_RGB' is not supported on this platform. Decompressing texture. 
    (also for RGBA8)
    The result is a scene with texture arrays that appear ok, but black geom in the scene with the oneBAtch shader applied with these tex's - presumably due to the decompress error above.

    Also some geom prefabs got corrupted by the process...
    Specifically, those prefabs that have multiple geom objects in them - IIUC these are the meshes OneBatch reconstructs. In these cases it appears that the transform was ignored.

    If I send my scene could you take a look and tell me where I'm going wrong please? Cheers.
     
    Last edited: Dec 6, 2019
  48. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Sure, and this is on android as a build target right? I recently updated MicroSplat to do a fallback method until if finds a texture format which is supported, so I could port that over as well.. Even though ETC2 is required by the openGLES3.0+ specs it seems some hardware is still saying it doesn't support it, which is odd.
     
  49. Tashkeel

    Tashkeel

    Joined:
    Mar 13, 2019
    Posts:
    8
    Hi @jbooth! I'm also getting the ASTC error that the above folks are..I'm on Android platform, and the error seems odd as my build settings are also ASTC...

    Oddly enough, even changing the compression setting to 'Force ETC2' causes the same error for me :
    Texture creation failed. 'ASTC_RGBA_8x8' is not supported on this platform. Use 'SystemInfo.SupportsTextureFormat' C# API to check format support.


    its that setting there, right? (I also tried putting in a platform override for android with the same results.

    upload_2019-12-6_12-21-9.png

    edit: forgot to post my unity version: I'm currently on 2019.2.11f1
     
  50. Tashkeel

    Tashkeel

    Joined:
    Mar 13, 2019
    Posts:
    8
    A thought just occured to me; I'm using Amplify Shader editor with my material, and it happens to come with a texture array creator. The main functionality of your tool that I need is the part where vertex colors are applied and the PropTex is generated..so is there a workflow method with this tool where I can choose to just perform that part of the operation and use my own premade texture arrays?

    I understand if that's a big feature ask, and if it is no worries, just wondering if that would make the whole pipeline easier for us with texture arrrays ready to go.