Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 barbe63 · May 07, 2015 at 12:06 PM · draw calls

Problem with draw calls

Hello

I'm struggling to understand what's happening. I have a gameobject that is set to mobile diffuse shader, no shadows and it's doing 2 draw calls and 1 if i remove the only directional light which is set with a culling mask that doens't include the object layer. No layer in the mask = no extra draw call. Any layer = 1 more draw call.

And of course it's happening to all my gameobjects.

Any ideas?

Comment
Add comment · Show 6
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 komodor · May 07, 2015 at 12:12 PM 0
Share

http://forum.unity3d.com/threads/what-are-draw-calls.27416/

avatar image joshua-lyness · May 07, 2015 at 12:21 PM 1
Share

This is because the if you have mixed lighting, I think it creates a draw call for dynamic lighting and static lighting. Don't quote me on that ... :) batch draw calls

Its not the same as how draw calls work on their own, but I think that is the method as unity figures out draw calls.

avatar image barbe63 · May 07, 2015 at 12:40 PM 0
Share

@joshua i thought it was that since i had some results that showed me it was calling one extra draw call with mixed and not with realtime. So i added a realtime light just set to one single layer that is not the gameobject layer, set the other to baked only and... it still make one extra draw call. Inconsistants results makes me think of a bug.

avatar image barbe63 · May 07, 2015 at 01:13 PM 0
Share

Another "hint"...

If i set the light with no shadow i don't have any extra draw call. $$anonymous$$y gameobject is set to shadow off and don't receive shadows either.

avatar image barbe63 · May 07, 2015 at 01:16 PM 0
Share

Also I can't reporduce the issue with a new scene with primitive objects. $$anonymous$$aybe it's because i'm using prefabs that was made with unity 4?

edit: Hmm seems not, if I add a primitive into my scene it's the same issue.

Show more comments

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by screenname_taken · May 07, 2015 at 12:24 PM

1 draw call for the object, and one for the light to affect said object. If your objects are not moving, mark them as static and try using mobile unlit and bake a lightmap.

Comment
Add comment · Show 1 · 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 barbe63 · May 07, 2015 at 12:30 PM 0
Share

try to read me again please...

I quote you the important part "which is set with a culling mask that doens't include the object layer"

I see it in the stats if i remove the renderer with this light that should not affect the object at all it removes 2 draw calls. If i remove the light and do the same it removes 1. I only have 1 material btw.

avatar image
1

Answer by dudester · May 07, 2015 at 03:42 PM

this is simply one of unity 5's many bugs , culling masks dont work in unity 5 at all well with lights atleast , try for yourselves add a directional light to the scene and set its mask to nothing and watch as every object has illumination strange really how they missed this bug but yeah , just submit a bug report to them with the project so they can get the problem resolved. hope this answers your question, unfortunately theres not much we can do to avoid the issue.

Comment
Add comment · Show 2 · 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 barbe63 · May 07, 2015 at 03:54 PM 0
Share

The problem doesn't occurs when i set the mask to nothing and the gameobjects are not illu$$anonymous$$ated but still make an extra draw call... but apart from that i think you are right, it must be a bug.

avatar image dudester · May 07, 2015 at 03:59 PM 0
Share

strange that it works for you , you are lucky , for me no matter what i set the mask to it always illumates everything .edit my mistake if i set the mask to mask everything except one layer it'll illu$$anonymous$$ate everything.

avatar image
0

Answer by Catlard · May 07, 2015 at 01:20 PM

If your object's appearance is affected by lighting, Unity must do another round of calculations for each object that is affected by the light. 1 object 3 lights = 3 draw calls. 40 objects 40 lights = you just crashed your mobile device.

Comment
Add comment · Show 1 · 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 barbe63 · May 07, 2015 at 01:29 PM 0
Share

The apparence of the gameobject is not affected by the light, if i remove the light probes checkbox from my renderer the object is black, as it should be. Please understand that my light have a culling mask that prevent the object to be affected.

avatar image
0

Answer by barbe63 · May 07, 2015 at 01:37 PM

Let me get it straight because it seems many people don't understand my problem.

I combined all my static gameobjects and baked the lightmap, so far so good. I have only one directional light that is set to baked only.

I want the option to have some real time shadows if the device can support it so i add another light set to realtime with a culling mask to only affect the gameobject i need to have real time shadows.

And here comes the trouble: All my gameobjects have an extra draw call reported in the stats, even if they are supposed to be unaffected by the real time light.

I know my english is quite bad but i thought i made it clear enough.

Comment
Add comment · Show 9 · 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 _dns_ · May 07, 2015 at 01:59 PM 0
Share

Hi, could it be the shadow pass ? Objects casting a shadow must be rendered from the light point of view as well as from the camera point of view.

Also, if you use Unity5, the "frame debugger" should help you see exactly what happens.

avatar image barbe63 · May 07, 2015 at 02:03 PM 0
Share

Ok so i figured out how to reproduce it in a new scene so someone could tell me if the problem occurs as well or what i'm doing wrong.

Create a new scene, set the camera to solid color. Then add a sphere, make sure it is visible by the camera, remove the 2 shadow properties (cast and receive), set the sphere layer to the one of your choice, set the culling mask of the light to another layer(click on nothing then on the desired layer) and... TADAAA! 2 batchings and 2 setpass calls

Disable the renderer : 0 batching ,0 setpass calls Remove the light or set shadows off : 1 batching, 1 setpass Duplicate the sphere (ctrl d): 4 batching (but 2 Setpass calls)

Edit: actuallly i was in dx9 setting. In dx11 the problem is the same but with an extra batching.

avatar image _dns_ · May 07, 2015 at 02:20 PM 0
Share

Do you have the gizmos drawn in the game view ? Those lines add a draw call.

avatar image barbe63 · May 07, 2015 at 02:31 PM 0
Share

No, if i add the gizmo it adds a lot of draw calls indeed but that's not the case here.

avatar image barbe63 · May 07, 2015 at 02:37 PM 0
Share

Frame debugger:

1: Clear

2: draw mesh - standard pass # 2 SHADOWS_DEPTH

3: Clear

4: draw mesh - standard pass # 0 DIRECTIONAL-SHADOWS

I don't understand what that means...

As far i undeerstand it seems that culling mask of the light affect the visual of the gameobject (no light on it and no shadows) but there is still some ghost pass on it (and maybe then it have no performance impact?)

Edit: I just sent a bug report, just in case...

Show more comments

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

25 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

Related Questions

Baked Light Maps 2 Answers

Strange static batching behaviour 0 Answers

Multiple Shaders vs. Single Texture - Please help me overthink this. 2 Answers

Share material to reduce draw calls 3 Answers

Performance issues with grid based terrain 2 Answers


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