Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Draw call targets and different virtual reality platforms

Discussion in 'AR/VR (XR) Discussion' started by astracat111, Nov 26, 2017.

  1. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    Hey there,

    I've been developing a simple rpg that plays out like a story for over a year now. I've been switching to virtual reality recently as the new platforms that are coming out are exciting to me.

    To have a test platform to try out VR I've recently bought a samsung s6 and a samsung vr headset. I got this as when the Occulus Go was announced, it was also announced that the Go would run games that were already on the smsung vr platform, which is basically saying that the occulus go will more than likely run a version of android.

    Now, in the developer section of occulus's website, they mention what you should try aiming for draw call and fps wise. Here's where my trouble has been...

    For my game I'm using a plugin called simple mesh combiner in combination with a free script called custom camera layer culling (or something similar to that). With these two tools I've been having great success at optimizing the game, as well as limiting shadows and pixel light count.

    The problem is that the best I can really do is to get the draw calls down to around 150-250 on average, sometimes peaking at 330 at times when one would look over a horizon or something. For a PC this is fine. For the Rift they say on their website that you should aim for 500-1000 draw calls max so I'm doing good there.

    For mobile, then, they say that you should aim for 50-100 draw calls. With every optimization I can throw at unity, more than likely due to terrain and the fact that I didn't really model my trees or houses to necessarily be optimized as fbx files, I don't think I will ever be able to get down to this rate. The game doesn't use an optimized terrain but rather just Unity's standard terrain, and I actually would rather like to stick to it as it's so easy to use. Mostly it's trees and houses from there, and the characters take 1 draw call as they are pixel-art characters within a 3d environment...

    My main targets were the occulus store and google play for my project, more specifically the occulus go headset. I'm thinking that that is probably not the best idea now and maybe looking at targeting the hololens or the new vr windows platform that's coming out. I don't know.

    Do you think the occulus go will be able to handle more than a typical mobile platform? I couldn't imagine so priced at $200. My thought is that they just want to get as many people using vr as possible. If this is the case, the market is extremely ripe right now so it's exciting...but getting draw calls down is an extreme challenge.
     
  2. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    To achieve 60fps on mobile VR it's essential to stay around 50 (and up to 100) draw calls. Not only are the devices limited on power, gpu, etc but we also don't know how many other apps the user is running and how much memory/cpu is being utilized outside of the VR App itself. I can't imagine the $200 Oculus Go is going to have any "new" hardware in it, most likely older chipsets like Snapdragon 810 or something, luckily it probably will have lower pixel density than some of the expensive phones like an S8, so there should be less pixels to render. But at $200, John Carmack better have some gpu driver magic up his sleeve to get equal performance as a Samsung S8 in a GearVR. Luckily with a dedicated unit, there probably a lot less random apps and crap running on the hardware like you'd find a regular user's phone.

    As far as performance goes, you're already doing a lot of what's possible to get draw calls down. Manually merge meshes into bigger pieces, atlas textures so you don't need so many materials, you should know exactly what meshes, textures, materials, and shaders are being used on everything in the game. Resource Checker script helps a lot with this: https://github.com/handcircus/Unity-Resource-Checker

    Unless you're under 100k tris and 50 draw calls, don't even consider any per-pixel lighting effect such as dynamic lights, don't use Unity standard shader anywhere, switch to Legacy Vertex Lit rendering path. Most all shaders used should be unlit or vertex lit. Minimal transparency effects, don't use default Unity skybox consider an actual dome mesh with a single unlit texture on it.

    As far as Player Settings, don't use depth or stencil buffer, try to disable 32 bit display buffer (MAY give worse performance for some Daydream devices), Try to disable static and dynamic batching if possible and handle batching yourself (like with mesh combine tool). I rarely see any benefit from Unity's Occlusion Culling system in mobile VR, it's faster and easier for me to just toggle gameobjects on and off based on player's location and what's visible, using triggers to enable/disable major meshes in the game world to only show what's visible to player location.

    My video covers a lot of settings to get mobile vr running at 60fps:
     
    SiliconDroid and astracat111 like this.
  3. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    @Selzier Wow, thanks Selzier this is a humongous help! I have not been using the legacy shading, so I will run some tests in taking those steps (as well as playing with all of the other things you mentioned). This is exactly what I've been looking for.

    So for the samsung vr also they do not want apps that exceed 500MB. This game has 32 scenes, so in essence each scene should average at <15MB... When combining meshes as you probably already know the scene size goes up, most likely due to the mesh being stored inside of the scene file?

    I am already right now , but I have not been using baked lighting.

    As far as draw calls are concerned, my average for the game is going to be 200-300, there's just literally nothing I can do about that the way I've designed it, and the game wouldn't look like I want it to look otherwise. Here's a sample screenshot. Sorry I can't make it smaller in the forum:




    The trees that I have there are what I want in number, and that complicates things for me. Even though on my desktop I've gotten it down to 250-300 draw calls in this scene which any ol computer these days can run circles around, especially considering I suppose how the graphics are all low-res, the test phone I have right now is a samsung s6...

    Mainly the reason the draw calls are so high is using Unity's default terrain, which as I've said above I'm not going to change just as I'm too far into development with it, it's convenient and easy to use. Also, the artwork only works if you can see the massive terrain in the distance.

    One thing I do have going for me I think is that everything is low-res, although I'm not entirely sure how I can further capitalize on that.

    Again, I will try everything you've got here out next time I get the chance.
     
  4. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    astracat111 likes this.
  5. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    Wow this is really great, you sure know your mobile tricks! Thanks again!

    P.S - I wonder if this will work with combined objects...?

    Looking it over, it looks like combining the trees won't even be necessary using this! Wow, I didn't know this kind of thing existed, this is MORE than worth the price.
     
    Last edited: Nov 28, 2017
  6. nat42

    nat42

    Joined:
    Jun 10, 2017
    Posts:
    353
    Is the shadowing realtime or a baked lightmap? Are you doing anything to optimise all those 'cutout' foliage textures (any alpha/discard on a model and it can't be handled by tile-based GPU's tile sorter and has to be rendered after in an alpha pass... so mobile performance guides for many years have suggested even 2d games with sprites render as much as they can in an opaque pass using more tris and then just have the edges rendered in the alpha pass)
     
    astracat111 likes this.
  7. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    I guess that is just my achilles heal, because virtually every single tree is cutout. At the time it just seemed like the fastest most convenient way of creating them, and I had figured that "Hey, it's 2D and it's low-res so it's gotta be faster". In the end it puts me into a draw call and optimization nightmare, as I wasn't aware last year what a draw call even was. As an artist I looked at 3d forests and just thought to myself that if I did it my way I would create more variation. The problem with variation is that you have to think about optimization. I had wondered why all of those optimized games had used only one tree and just resized and morphed it, making sure to use the same tree over and over.

    And then on another note, for anyone interested in creating terrains, if you're using blender or maya to create 3d models create your terrains inside of those programs, export, and bring them into Unity. Unity's default terrain is easy and convenient, but it is another draw call nightmare for people that want to target mobile devices if you want to create terrains that are huge. You really have to give thought to this stuff early I'm learning.

    The billboarding plugin seems absolutely perfect for me, although I'm assuming it would be used for farther away trees. I'm not entirely sure how it can do what it can do so fast and efficiently yet, so I'm going to play around with it at report back here.
     
    ROBYER1 and Selzier like this.
  8. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    Since someone recently liked this, I want to update this.

    Since Unity 2018 Unity has had GPU Instancing, so you can use that for mobile devices. What I've found in recent times, and this is coming from someone that's made huge use unfortunately for me of alpha test (cutout shaders for materials), is that the thing you really want to watch out for now is CPU with these new devices coming out. Maybe someone could correct me if I'm wrong, but just watch your scripts and make sure you don't have your Update() methods doing unecessarily cumbersome things, or that you don't have like 20 NPCs, none of them being culled or stopped, all running Update() methods with some sort of cumbersome task. Keep things as light as possible from the get go on the CPU.
     
    EricCruden likes this.