Search Unity

Bug Unity 2020.2.0f1: CopyTexture has a new bug?

Discussion in 'Universal Render Pipeline' started by Haapavuo, Dec 20, 2020.

  1. Haapavuo

    Haapavuo

    Joined:
    Sep 19, 2015
    Posts:
    97
    Hi!

    Unity 2020.2.0f1 causes an error that didn't happen in 2020.1:

    CopyTexture called with mismatching sample count per pixel (src 2 dst 1).


    This happens when calling CopyTexture with

    • src = RenderTexture and

    • dst = Texture2D.
    Both have mipCount set to 1. Seems to have no effect on the issue.

    Both have TextureFormat.ARGB32 / RenderTextureFormat.ARGB32.

    Anyone have an idea on how to overcome this?

    Thanks!
     
  2. Yetman

    Yetman

    Joined:
    Jan 29, 2016
    Posts:
    5
    I don't know how to overcome this since I didn't face that problem... yet.

    However, the issue seems to be that the function cannot automatically resolve the samples from 2 down to 1 while copying. If I remember correctly, whenever I had a render texture with multiple samples, it would be automatically resolved to 1 sample by unity before reading (with the exception of depth textures). May be that behavior changed (I didn't try 2020.2 yet).

    I'm not sure but this may help: https://docs.unity3d.com/ScriptReference/RenderTexture.ResolveAntiAliasedSurface.html
     
  3. Haapavuo

    Haapavuo

    Joined:
    Sep 19, 2015
    Posts:
    97
    I worked my way around this by not using CopyTexture at all.

    Previous solution was to convert RenderTexture into a Texture2D which was used to create a Sprite.

    New solution is to use RawImage instead of Sprite which can take RenderTexture so we don't have to copy the data into a Texture2D.
     
  4. hellowill89

    hellowill89

    Joined:
    Jan 8, 2013
    Posts:
    45
    For me, disabling MSAA fixed the issue.
     
  5. wechat_os_Qy0z8BvwMbFjgilHRP8vcapHI

    wechat_os_Qy0z8BvwMbFjgilHRP8vcapHI

    Joined:
    Apr 16, 2021
    Posts:
    1
    thanks!!