Home Technical Talk

Materials and draw calls

jordank95
polycounter lvl 8
Offline / Send Message
jordank95 polycounter lvl 8
Hi all -

This is a very basic question and Im sorry if the wording is a bit off, still trying to wrap my head around this - Working on a sidescroller 3D game with some friends and wondering about some technical issues we might run into in the end. Im reusing as many assets as possible to build out these levels, but we also have a ton of new assets that come into play for each section we come across. Trying to be really mindful of using tiling textures and trim sheets where I can, with some unique textures for some props as well. Im just more curious when draw calls become an issue with materials? If I have like 20 materials on screen at once is that going to be an issue? When does it start becoming an issue for something like Switch or mobile?

Replies

  • rollin
    Options
    Offline / Send Message
    rollin polycounter
    Each unique material is a draw call. Each unique object is an additional draw call. There are many things causing draw calls. Which engine are you using?

    Generally speaking: you should avoid any unnecessary draw calls.
    Then you test it if it runs smooth enough on your target device
    If necessary you reduce them even more by reducing the complexity of your concept. 
  • jordank95
    Options
    Offline / Send Message
    jordank95 polycounter lvl 8
    rollin said:
    Each unique material is a draw call. Each unique object is an additional draw call. There are many things causing draw calls. Which engine are you using?

    Generally speaking: you should avoid any unnecessary draw calls.
    Then you test it if it runs smooth enough on your target device
    If necessary you reduce them even more by reducing the complexity of your concept. 
    Using Unity. Doesn't Unity batching objects reduce mesh draw calls?
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    It does but it doesn't mean that you can do anything. It can render things like that only when they are totally the same thing except the transform. Objects with different materials cannot be batched. From my experience, even a few hundred materials can be fine depending on the hardware.Mobile stuff, not so much.
  • jordank95
    Options
    Offline / Send Message
    jordank95 polycounter lvl 8
    Obscura said:
    It does but it doesn't mean that you can do anything. It can render things like that only when they are totally the same thing except the transform. Objects with different materials cannot be batched. From my experience, even a few hundred materials can be fine depending on the hardware.Mobile stuff, not so much.
    Yeah, I did know that - only batches the same object minus the transform. Ok, thats good to know about materials. Im trying to be as optimized as possible when it comes to material draw calls, so its good to know that I have more room to manage than I thought. Thanks!
  • jordank95
    Options
    Offline / Send Message
    jordank95 polycounter lvl 8
    @Obscura One more question (and I think I know the answer but I just want to make sure) - for example, would it be better to have a single 4x4m blank mesh that I use for building out walls/floors and just apply whatever material I want it to have in the level itself, or would it be better to have separate 4x4 mesh pieces for each material that I need? So in the browser I would have multiple 4x4 meshes with the materials already applied. Opposed to just a single 4x4 mesh in the browser, that I just apply whatever material I need to it in the scene? Assuming the latter in this situation, am I correct?

    While Im on this question, should I have multiple pieces (4x4, 8x8) or just use a 4x4 and just use those to create an 8x8?
  • rollin
    Options
    Offline / Send Message
    rollin polycounter
    I'm not Obscura :p but I would say It doesn't make a difference from a performance point of view as the batcher should be able to collect the matching instances.

    Anyway: you have a tool in unity which gives you a perfect answer to all of your questions:
    Use the frame debugger https://docs.unity3d.com/Manual/FrameDebugger.html
  • jordank95
    Options
    Offline / Send Message
    jordank95 polycounter lvl 8
    Another question regarding this same topic...figure I would reply here rather than start a new thread - 

    Are draw calls based on materials on screen at the same time? So If I have 10 different meshes all using the same wood tiling material, thats still 1 draw call for the material rather than 10 different draw calls? Since its calling the material into the scene once for those 10 objects. Correct?

    And lets say, theoretically speaking, if I have 10 materials being drawn on screen at the same time, does it matter how many materials each mesh has applied to it? So if Im drawing 10 different materials on screen at once, can 1 mesh alone have 10 different materials and its ok? Since it all really depends on whats being drawn on screen overall rather than each individual object?

    Sorry if this is confusing me
  • jRocket
    Options
    Offline / Send Message
    jRocket polycounter lvl 18
    Is it based on the number of objects/subobjects on screen at any given time. Off-screen objects are culled based on their bounding box. Also, keep in mind that object shadows cause additional draw calls, and depending on which renderer you're using- you'll get additional draw calls for depth/normals pre-pass. You can use the frame debugger in Unity to actually see what calls are being made.

    You can enable instancing on your material to render multiple objects in the same draw calls(only for indentical objects).

    You usually don't have to worry about it until you get into the several hundreds of draw calls for mobile/switch, thousands for PC/console. Also, the new SRP batcher is much more efficient if you're using HDRP/URP.
  • jordank95
    Options
    Offline / Send Message
    jordank95 polycounter lvl 8
    @jRocket OK thanks that clears it up a bit. I was just trying to be cautious by applying like 8 tiling materials to one object with lots of different pieces. But I guess that doesnt matter since those 8 tiling materials are being used in the same scene on other objects as well.
Sign In or Register to comment.