Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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:
    57
    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:
    57
    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.
     
unityunity