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

Question Update Depth texture draw calls?

Discussion in 'General Graphics' started by roundyyy, Nov 29, 2020.

  1. roundyyy

    roundyyy

    Joined:
    Dec 23, 2019
    Posts:
    112
    Hello. I'm trying to optimise project I'm working on. I'd like to ask you if this is normal. I get doubled draw calls and tris amount every time I switch on shadows, even when distance to draw them is 0.1. Light is baked, 1 directional light set to mixed, tried vertex lit shaders, different light modes etc. I'm new to Unity so maybe it's normal? Please have a look on my video, everything is shown there. I just don't understand why depth texture draw calls appears even if there is no shadows drawn. Unity 2018.4.12, build in renderpipe. I've tried to set this with script : Camera.main.depthTextureMode = DepthTextureMode.None; , but didn't change anything. Any help would be highly appreciated. Thank you in advance!
    https://ttprivatenew.s3.amazonaws.c...ents/15370326/TinyTake29-11-2020-12-28-59.mp4

    I'm sorry if this is posted in wrong section, wasn't sure where to post it.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Unity's main directional light's real time shadows are rendered by generating a camera depth texture and casting shadows onto the world position reconstructed from that camera depth texture. So by having any shadow distance, it's automatically enabling the rendering of the camera depth texture. And that camera depth texture is "generic", in that it doesn't try to limit itself to only render objects that are within the shadow distance. There are a lot of other effects that make use of the depth texture, like soft particles or post processing effects, so it normally doesn't make a lot of sense to special case it.

    Now, you might be thinking "but I'm using baked lighting, why is it trying to do real time shadows?" Your light is set to mixed. That means if you have any shadow casting object in your scene that's not set to be static, that object's shadows will by dynamically cast and received.

    So yes, this is normal and expected.
     
    roundyyy likes this.
  3. roundyyy

    roundyyy

    Joined:
    Dec 23, 2019
    Posts:
    112
    Thank you for your great answer, things look clearer for me now. So I understand that Depth texture is being rendered "just in case" cause in view I showed on video all objects are static, nothing dynamic (dynamic object appears later in game). In my case, it's kind of waste of resources, but I believe it just "must be like that". Thank you again, now I know that there is no point to try to do anything with this. It's for VR so every draw call matters for me, that's why I was wondering about that. Cheers :)