WebCam background optimisation

Hi everyone, i am creating an app where there is a background with camera feed, it’s supposed to be gray like in the screenshot below.

Now the problem is that with current code, on Android app runs with 3FPS when 1280x720 on SGS4, not good (and I don’t want to have resolution of 320x240).
What I want is somewhat good quality as well as at least 30FPS.

Right now I am using CameraWebTexture, which is saved in Color array, then I process this Array to make image gray and brighten it. Then I apply this array to Texture2D which is further applied on RawImage texture and material.mainTexture.

What I need is ways to optimize the code or alternatives which would let accomplish this task.
This should be possible , as for example SnapChat has the same effect on login screen.
Willing for your help :slight_smile:

WebCamTexture webCamTexture;
    Color32[] modColors;
    Texture2D modTexture;

    void Start()
    {
        SetupTexture();
    }

    void Update()
    {
        ModifyTexture();
        ApplyTexture();
    }

    void SetupTexture()
    {
        webCamTexture = new WebCamTexture(1280,720,30);
        webCamTexture.Play();

        modTexture = new Texture2D(webCamTexture.width,webCamTexture.height);
        RawImage rawImage = GetComponent<RawImage>();
        rawImage.texture = modTexture;
        rawImage.material.mainTexture = modTexture;

        
    }

    void ModifyTexture()
    {
        modColors = webCamTexture.GetPixels32();
        for (int i = 0; i < modColors.Length; i++)
        {
            byte modColor   = (byte)((modColors<em>.r + modColors_.g + modColors*.b) / 3);*_</em>

modColor = (byte)(192 + (modColor / 4));
modColors = new Color32(modColor, modColor, modColor, 255);

}
}

void ApplyTexture()
{
modTexture.SetPixels32(modColors);
modTexture.Apply();
}

@Roktom, On Android especially, WebCamTexture has terrible performance. Try using NatCam.