Search Unity

Bug Depth texture is forced on standard render if PPS is used, even if disabled in player settings

Discussion in 'General Graphics' started by sacb0y, Jun 3, 2020.

  1. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    I have a game i release regular builds of for both PC and android and the PC version uses DOF, SSAO and other effects, along with cinemachine effects per camera.

    Apparently, even if I have depth texture and stencil disabled in the player settings, PPS forces it back on. Which kills performance even if the post process effect is not used at all, takes a game from 60FPS to a mere 30-45.

    This is not an issue in URP, i recently did some tests considering switch and ported some shader, and noticed how great the performance was. I made a comparable scene and got not as good performance but much better than my game. And then i added DOF on a VCAM and before the camera was even enabled performance was bad, on URP the effect simply doesn't work.

    How can I fix this problem and permanently disable the depth texture on android? I'm not sure how to post to the issue tracker about this.
     
  2. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class DisableDepth : MonoBehaviour
    4. {
    5.     public Camera mainCamera;
    6.    
    7.     void OnPreCull()
    8.     {
    9.         mainCamera.depthTextureMode = DepthTextureMode.None;
    10.     }
    11. }
    I've tried this and it worked in play mode but not in build :/

    Why is PPS designed to overwrite this so hard?
     
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,260
    The DoF and SSAO effect both require the depth texture to work, which is why it is being rendered if they are enabled.

    Can't say for sure, but disabling these effects should allow you to force the DepthTextureMode to None.
     
  4. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    No for some reason, even if the effects are disabled they still trigger the depth texture which results in overall performance loss.

    In play mode i've tried many methods to disable depth which appear to work fine, but i can't make it work in the actual android build.

    Somehow the act of DOF or SSAO being in a stack anywhere causes the depth texture. Unless i have an easy way to wipe the DOF effect from all virutal cameras just for when i want to do an android build the depth texture will come back T_T. Like i can easily disable Dof from all post processing assets but that won't prevent the depth texture.

    I even tried modifying the effects CS files to commend out when they enable depth but there must be some kind of redundancy DX

    Having some kind of global disable for depth would make this much more mobile friendly when you're targeting multiple platforms which i think is the point of that toggle but it doesn't work with PPS...
     
    Last edited: Jun 3, 2020
  5. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    Also another note, it's very difficult to find scripts that set the depth mode, because PPSv2 is in the packages folder visual studio does not see it so i cannot search all files for "DepthTextureMode" so i can at least see if commenting all them out would work. .
     
  6. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    510
    I'm working on porting my game to android...did you ever figure this out?

    By the way, I usually use the method OnWillRenderObject instead of OnPrecCull.