Search Issue Tracker
By Design
Votes
0
Found in
2022.3.10f1
2023.1.15f1
2023.2.0b11
2023.3.0a7
Issue ID
UUM-52415
Regression
Yes
Graphics.CopyTexture() renders artifacts in Player when copying an ARGB32 Texture2D to an ARGB32 RenderTexture
Reproduction steps:
1. Open the attached project "ReproProj" with Android
2. Open the “/Assets/Scenes/TextureCombineFailure.unity” Scene
3. Enter the Play Mode
4. Observe the correctly rendered Scene in the Game view window
5. Build and Run on an Android device
6. Observe the Player
Expected result: No artifacts are seen
Actual result: Artifacts in the 3rd and 4th planes
Reproducible with: 2021.3.31f1, 2022.3.10f1, 2023.1.15f1, 2023.2.0b11, 2023.3.0a7
Testing environment: Windows 10 Enterprise 21H2
Reproducible on:
VLNQA00318, Oneplus OnePlus 7 Pro (GM1913), Android 11, CPU: Snapdragon 855 SM8150, GPU: Adreno (TM) 640
VLNQA00379, Oculus (Quest 2), Android 10, CPU: Snapdragon XR2, GPU: Adreno (TM) 650 (Reproduces with OpenXR and Oculus plugins)
Not reproducible on:
VLNQA00325, Samsung Galaxy Note10 (SM-N970F), Android 12, CPU: Exynos 9 (9825), GPU: Mali-G76 (No artifacts but renders only text for 3rd and 4th planes)
VLNQA00231, Huawei HUAWEI Mate 20 Pro (LYA-L29), Android 9, CPU: HiSilicon Kirin 980, GPU: Mali-G76 (No artifacts but renders only text for 3rd and 4th planes)
VLNQA00231, Samsung Galaxy A5(2017) (SM-A520F), Android 8.0.0, CPU: Exynos 7 Octa 7880, GPU: Mali-T830 (No artifacts but 3rd and 4th plane is black)
Windows Standalone Player
Editor Play Mode
Notes:
- Using Graphics.Blit() resolves the issue
- Reproducible on Quest 2 with OpenXR and Oculus XR Plugin
- Reproducible on Quest 2 with OpenGLES3, but not Vulkan
- FAV for the OnePlus 7 Pro is 2022.2.0b9
- Reproducible on OnePlus 7 Pro with OpenGLES3 and Vulkan
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Crash on BatchRendererCullingOutputs::SyncFences when navigating through a Scene via the Scene view
- [Android][Vulkan] Crash on /system/lib/libandroid.so (ANativeWindow_setBuffersGeometry+4) when the Vulkan Graphics API is used
- Event handlers are preventing operations when trying to copy or paste HTML text in the WebGL Player
- [macOS] Crash on __pthread_kill when Exporting a Package while another export is in progress
- Crash on TransformAccessDestroyCallback when removing a URP Decal Projector component from a parent GameObject that had a URP Decal Projector child GameObject
Resolution Note:
To summarize the issue:
1. RenderTexture.GetTemporary is used to get a temporary RenderTexture. We have a documented optimization that says the previous contents of a new temporary RenderTexture may be undefined. (In general any new RenderTexture may have undefined contents). https://docs.unity3d.com/ScriptReference/RenderTexture.GetTemporary.html
2. A Graphics.CopyTexture operation is used to initialize the contents of the Texture that is a part of the RenderTexture. Since CopyTexture is strictly an operation between Textures and NOT RenderTextures the original RenderTexture still is internally flagged that it can be loaded in a way that discards contents. https://docs.unity3d.com/ScriptReference/Graphics.CopyTexture.html
3. A Graphics.Blit operation is used on the temporary RT that is meant to copy a Texture into a RenderTexture. The Blit operation sets the RenderTexture as active RenderTexture and draws a fullscreen pass that copies the source texture using a custom material. Since the temporary RenderTexture was still flagged as unintialized it was loaded in a way that can discard the previous contents on some platforms and thus produce artefacts.
In conclusion it is important to take notice to the differences of Textures and RenderTextures. GetTemporary() render texture content is marked as discarded, and will not be loaded when the render texture is first activated for rendering. Because CopyTexture is not performing a rendering operation, just a data copy, the temporary render texture content remains marked to be discarded on first activation, so any data copied into it before actual rendering will be lost. Please use rendering commands when working with render textures to ensure proper data usage order.
.It can also be beneficial to use the SRP that gives more hand-on control on these things.