Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Update DepthTexture - Is it 'free' on any platforms?

Discussion in 'General Graphics' started by Prodigga, Dec 19, 2015.

  1. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,121
    Hey guys

    The documentation says:

    Does this mean the depth texture is 'free' on certain hardware? When I run the framedebugger in the editor, regardless of whether I am doing forward or deferred, I get a whole lot more drawcalls as unity needs to do a seperate pass for the depth buffer (Update DepthTexture).

    Is this operation 'free' on when deployed on certain hardware? Can I access it in forward rendering?
     
  2. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,121
    Also, stated here:

    http://docs.unity3d.com/Manual/UpgradeGuide5-Shaders.html
    So, enabling shadows gives me a depth texture, too ?
     
  3. Zuntatos

    Zuntatos

    Joined:
    Nov 18, 2012
    Posts:
    612
    Assuming:
    Depth Texture = read/write enabled texture storing depth
    Depth Buffer / Z buffer = screen space buffer used to store depth of pixels written to check later pixels against for possible discarding.

    IIRC it should be 'free' on deferred if in DX11/OpenGl (ES) 3+ / metal / xbone / ps4 as you should be able to use the Z buffer as a texture. On DX9 / OpenGL (ES) 2 / WebGL it depends on driver/card support if it's possible to use the Z buffer, otherwise it's drawn to a texture and the buffer itself is discarded, causing extra draw calls to fill said texture.

    Shadowmaps are a different word for depth textures, but from the perspective of the light. Rather unrelated to screenspace depth textures.

    I've got no idea about forward rendering, never used it.

    Edit: Using a directional light with cascaded shadows <may> force a depth texture to be used.
     
    theANMATOR2b likes this.
  4. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,121
    Thanks for the response! Though I am working with forward rendering! Should've mentioned that. :)
     
  5. StevenGerrard

    StevenGerrard

    Joined:
    Jun 1, 2015
    Posts:
    97
    Here is the truth
    => DepthTexture never free.

    So why doc says it is free when enable shadow mapping or deferred ?
    => Because such algorithm need depth buffer accession.
    => So unity build depth buffer internally.
    => So it is "free" for custom usage. In fact you always cost much more cycles to build depth buffer.
     
  6. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,121
    Ofcourse, that is what I ment. So, to confirm, in Forward Rendering, assuming I enable shadows on my directional light, I will have access to the depth buffer?
     
  7. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,121