How to get fillrate or average overdraw from unity profiler

Hello, I am trying to get fillrate and average overdraw value of each frame with unity profiler. Then I am able to draw a line chart with the data. But it seems there is no way to achieve it with unity profiler, isn’t it? I have googled a lot, but I cannot find the way to solve it.

1 Like

I’m not entirely sure that’s possible, at least not in a practical way. Measuring overdraw would require you to count the number of times each pixel is drawn to on the graphics card, which would represent a fair bit of overhead. You could probably do custom shaders to achieve this, but I’m not sure the results would be meaningful.

There is an option to visually see the overdraw right in the editor.
In the scene tab right in the top left corner there is a drop down that defaults to shaded, you can drop that down and get quite a few different options and Overdraw is one of them.

1 Like

Thanks a lot. I guess you are right. I am trying to write a shader to view it.

Thank you! Do you know how to measure it in the runtime? For example, we can get to know there is 5x overdraw per pixel in a frame.

I have no idea how to do that, I use dual monitor setup with the game on one and the editor on the other. I can then watch the editor in Overdraw mode to see how dark the overdraw is, then try to correct it. Did that with alpha as well, as mobile phones are horrible at drawing nothing and drawing too much.

they had some compute shader to measure overdraw, not sure was that also for runtime, but probably should work: *at 36min - >

source code
https://github.com/Nordeus/Unite2017

6 Likes

Oh!! Thank you so much!! That’s exactly what I need. It helps a lot!

This is what I render using the shader in GitHub - Nordeus/Unite2017


Thank all my friends who helped me!

Hello prayshouse, I could open the OverdrawToolWindow which is an editor window that shows average overdraw, but I couldn’t get the overdraw debug view to show in the game view as in your screenshot. Can you please explain how you could prepare it to work?

Thanks.

public class OverdrawMonitor : MonoBehaviour
{
    private static OverdrawMonitor instance;
    public static OverdrawMonitor Instance
    {
        get
        {
            if (instance == null)
            {
                instance = GameObject.FindObjectOfType<OverdrawMonitor>();
                if (instance == null)
                {
                    var go = new GameObject("OverdrawMonitor");
                    instance = go.AddComponent<OverdrawMonitor>();
                }
            }
            return instance;
        }
    }

    private new Camera camera;
    private Shader replacementShader;

    public void Awake()
    {
        if (Application.isPlaying) DontDestroyOnLoad(gameObject);
        replacementShader = Shader.Find("Debug/OverdrawInt");

        camera = GetComponent<Camera>();
        if (camera == null) camera = gameObject.AddComponent<Camera>();
        camera.CopyFrom(Camera.main);
        camera.SetReplacementShader(replacementShader, null);
    }


    // Use this for initialization
    void Start()
    {
        camera.enabled = false;
    }

    // Update is called once per frame
    void Update()
    {

    }

    public void LateUpdate()
    {
        Camera main = Camera.main;
        camera.CopyFrom(main);
        camera.clearFlags = CameraClearFlags.SolidColor;
        camera.backgroundColor = Color.black;
        camera.SetReplacementShader(replacementShader, null);

        transform.position = main.transform.position;
        transform.rotation = main.transform.rotation;
    }
}

I use the code to create a overdraw camera. In this camera, shaders are replaced by the overdraw shader. Once you switch to the overdraw camera, you will see what I see in the screenshot.

1 Like

hi., your platform is android? on android platform shader is wrong~~

I have test my project on xiaomi 5. It works well.