Search Unity

Question Configuring PixelFormat for dynamic shadow map texture

Discussion in 'General Graphics' started by bjefix, Apr 16, 2021.

  1. bjefix

    bjefix

    Joined:
    Mar 30, 2015
    Posts:
    9
    Hello everybody!

    When I profiled the game, I saw that the PixelFormat in the shadow texture is Depth32. I am trying to change this format to Depth16. I looked through a lot of articles, posts on the forums, but I still could not find how to do this in the editor. The only option I have found is to write my own shadow cartographer.

    Maybe someone knows how this can be done easier?
    I'll be very thankful!

    Thanks in advance!
     
  2. AljoshaD

    AljoshaD

    Unity Technologies

    Joined:
    May 27, 2019
    Posts:
    232
    Hi bjefix!

    currently you have very little control over the shadow and depth/stencil precision. What platform are you targeting?

    We are just landing some changes in Unity 2021.2 that will allow you to set an exact depth/stencil format for your depth and shadow buffers/textures.
     
  3. bjefix

    bjefix

    Joined:
    Mar 30, 2015
    Posts:
    9
    Hello AljoshaD!

    Thanks for the answer. Our target platforms are iOS and Android. We spoke with an official Apple developer. He checked our project and said that we need to set the Depth16 format instead of Death32.

    We are working in Unity 2019.4.16f1 and we cannot update our project to the latest version of Unity or the new rendering pipeline.

    Thanks in advance!

    Best regards,
    bjefix
     
    Igor_Time likes this.
  4. AljoshaD

    AljoshaD

    Unity Technologies

    Joined:
    May 27, 2019
    Posts:
    232
    older iOS devices don't support Depth16 in metal. If they do, I suspect that a shadowmap is Depth16 by default unless you set prefer32BitShadowMaps in the settings. Vulkan on Android should support Depth16 and use it by default. OpenGL on Android ignores the prefer32BitShadowMaps setting.
     
  5. bjefix

    bjefix

    Joined:
    Mar 30, 2015
    Posts:
    9
    Hello AljoshaD!


    I have set the Prefer32BitShadowMaps option to false. Also I have configured the graphical API to metal.
    After building and running the Xcode Frame Debugger, I saw that the shadow map was generated in Depth32 pixel format.
    Maybe I'm doing something wrong?
     
  6. AljoshaD

    AljoshaD

    Unity Technologies

    Joined:
    May 27, 2019
    Posts:
    232
    Hi bjefix,
    what ios version is your device using? Unity/Metal only support depth16 on iOS13. Earlier versions of iOS will always use depth32 for shadowmaps.
     
  7. bjefix

    bjefix

    Joined:
    Mar 30, 2015
    Posts:
    9
    I tested on iPhone 12 with iOS version 14.2.
     
  8. AljoshaD

    AljoshaD

    Unity Technologies

    Joined:
    May 27, 2019
    Posts:
    232
    That looks like a bug then. Can you file a bugreport?
     
  9. bjefix

    bjefix

    Joined:
    Mar 30, 2015
    Posts:
    9
    Sorry, I don't understand what I need to send you. Do you mean submit a bug report from Unity? And what files do I need to send you?
     
  10. AljoshaD

    AljoshaD

    Unity Technologies

    Joined:
    May 27, 2019
    Posts:
    232
    You can find info on how to submit a bugreport here. You need to attach a minimal project that demonstrates the issue and as much info as possible to reproduce the issue.
     
  11. bjefix

    bjefix

    Joined:
    Mar 30, 2015
    Posts:
    9
    Ok, thanks!

    Have a nice day!