Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Shadarath1 · Apr 09, 2019 at 01:39 PM · renderingoptimizationassetsdrawcalls

Draw calls are adding up fast with asset packs

Hello,


For some time now I have been trying to wrap my head around how to use asset packs properly. What is worrying me are draw calls growing fast with every asset placed in a scene.


From what I remember, adviced draw call limit for mobile platforms is about 50, for PC maybe few hundreds, with general idea being the lower the better.


I have downloaded one of low poly asset packs from Kenney and setup a quick and simple scene, consisting of 18 objects, 1 directional light and 1 point light. Every material has only color set, no textures used. (see image)


low poly scene


This tiny setup is already using 123 batches and 64 draw calls, with more being added with every additional object...


I do know there are many, many ways to reduce draw call count. I could use a single material and apply different colors with shader instancing. I could combine all vertices to single mesh and flatten materials to vertex colors.


However, even if I make everything instanced and drawn with one material only, there is still tens of draw calls made for the purpose of light maps.


But most important thing is, if I am required to modify meshes or materials of ready to use packages I somehow feel I am using them wrong way... Or maybe if all geometry is so simple it is not a problem to have houndreds of draw calls even for mobile device?


Any tips welcome.
Thanks, Bartosz

unity-draw-calls.png (146.8 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by highpockets · Apr 09, 2019 at 05:41 PM

Since you are just setting a color and no texture on most objects, I suggest that you use one material for all of them and use vertex colours to change the colours in the start method. All objects with that material will then just produce one draw call. I did make a shader that has vertex colors and also allows for a custom lightmap which in my case is just a lightmap texture baked in blender, if you want I can send you the shader over

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image highpockets · Apr 09, 2019 at 06:12 PM 0
Share

I’ll extend this by saying the reason I made my lightmaps in blender is because I got 1 good quality 1024x1024 lightmap in blender when I was getting 4-5 1024x1024 lightmaps of lesser quality in unity. Since you are downloading assets, I’m not sure how hard it would be for you to export your scene into your favourite 3D modelling software to bake the scene in there, but this might be a place to start and then you can put the lightmap on the same material and thus your draw calls will be much lower

avatar image Shadarath1 highpockets · Apr 11, 2019 at 07:07 PM 0
Share

Thank you, I will probably end up doing exacly that. I love the idea to bake lightmaps in blender, somehow I forgot that this is even an option.

avatar image highpockets Shadarath1 · Apr 11, 2019 at 08:30 PM 0
Share

Sounds good, here is the shader if you want it. Note that it says supports lightmap, but I just put that in there and it's not supported by unity's lightmap, it's just a texture. You'll also note that there is a base texture, but you can remove it if you don't need it. I have a base texture for the first UV map as just a black and white texture to add details and then the lightmap for the 2nd UV map. Cheers,

 Shader "Custom/VertexColor (Supports Lightmap)"
 {
     Properties
     {
         _$$anonymous$$ainTex("Base (RGB)", 2D) = "white" {}
         _Color("$$anonymous$$ain Color", Color) = (1,1,1,1)
         _Light$$anonymous$$ap ("Light$$anonymous$$ap", 2D) = "white" {}
     }
 
         Category
         {
             Tags{ "RenderType" = "Opaque" }
             Lighting Off
 
             SubShader
             {
                 Pass
                 {
 
                     CGPROGRA$$anonymous$$
                     #pragma vertex vert
                     #pragma fragment frag
 
                     #include "UnityCG.cginc"
 
                 struct appdata_t 
                 {
                     float4 vertex : POSITION;
                     fixed4 color : COLOR;
                     float2 uv : TEXCOORD0;
                     float2 uv2 : TEXCOORD1;
                 };
 
                 struct v2f
                 {
                     float2 uv : TEXCOORD0;
                     float2 uv2 : TEXCOORD1;
                     float4 vertex : SV_POSITION;
                     fixed4 color : COLOR;
                 };
 
                 sampler2D _$$anonymous$$ainTex;
                 float4 _$$anonymous$$ainTex_ST;
                 sampler2D _Light$$anonymous$$ap;
                 float4 _Light$$anonymous$$ap_ST;
                 fixed4 _Color;
 
                 v2f vert(appdata_t v)
                 {
                     v2f o;
                     o.vertex = UnityObjectToClipPos(v.vertex);
                     o.uv = TRANSFOR$$anonymous$$_TEX(v.uv, _$$anonymous$$ainTex);
                     o.uv2 = TRANSFOR$$anonymous$$_TEX(v.uv2, _Light$$anonymous$$ap);
                     o.color = v.color;
                     return o;
                 }
 
                 fixed4 frag(v2f i) : SV_Target
                 {
                     float4 col = tex2D(_$$anonymous$$ainTex, i.uv) * tex2D(_Light$$anonymous$$ap, i.uv2);
                     fixed4 vcol = i.color;
                     return col * vcol * _Color;
                 }
                 ENDCG
             }
         }
     }
             //FallBack "$$anonymous$$obile/Diffuse"
 }
avatar image
0

Answer by Zaeran · Apr 09, 2019 at 05:12 PM

Lighting and shadow is likely the largest cause of your draw calls. Two lights casting shadows and interacting with each other is definitely going to cause a performance hit.

If you don't need the lights to move or change, try baking a lightmap.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

126 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why is the CPU usage so high? 1 Answer

Optimisation: fewer draw calls or smaller draws? 1 Answer

Drawcalls or Batched, which is more important to performace? 1 Answer

Why a normal 3D scene that is somewhat complex giving me 60 Fps in my android device but a completely 'empty scene' with only a camera in Lightweight RP giving me only 15 Fps? 0 Answers

Is it possible to utilize iphone dynamic batching with "traditional" animated sprite techniques? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges