- Home /
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?
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.
@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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Do you have the gizmos drawn in the game view ? Those lines add a draw call.
No, if i add the gizmo it adds a lot of draw calls indeed but that's not the case here.
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...
Your answer
![](https://koobas.hobune.stream/wayback/20220613195010im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
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