Search Issue Tracker
By Design
Votes
0
Found in
2020.3
2021.1
2021.1.19f1
2021.2
2022.1
Issue ID
1365395
Regression
Yes
Webgl Player renders transparent images when using Graphics.blit with a material
How to repro:
1. Open users' attached “SubmitBug.zip” project
2. Open “SampleScene” Scene
3. Switch Build Platform to WebGL and then “Build And Run”
Expected result: 3 squares appear on the screen
Actual result: Only 1 square appears other are invisible
Reproducible with: 2020.3.0f1, 2020.3.23f1, 2021.1.28f1, 2021.2.3f1, 2022.1.0a16
Not reproducible with: 2019.4.31f1
Notes:
- Not reproducible on Mac WebGL Player, all 3 squares show up
- The expected result can be seen in the Editor in Play Mode
Comments (1)
-
Smitzo
Jul 30, 2023 01:01
Why don't you add this information to the documentation here: https://docs.unity3d.com/ScriptReference/Graphics.Blit.html
That would have saved me 2 days digging into this.
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
- UI Builder can't set a background image to a sprite from a multi-sprite spritesheet in the Resources folder
- Light2D freeform does not render the internal part when rendered in certain shapes
- Using AddCopyPass causes an incorrect merging of passes.
- Negative Enum value is not pasted correctly when copying from another array
- Silent Crash when generating Lightmap UVs for a model with a large object scale
Resolution Note:
Graphics.Blit draws a quad using the provided shader. Because the depth buffer of the render texture can contain arbitrary values (uninitialized in this case), shaders used for Graphics.Blit should disable depth testing by adding "ZTest Always" to the shader. This is true for any shader used as a post process effect.
In the given example, Unlit/Texture does not pass the ZTest. You can use the default Graphics.Blit shader by not including the Material in your call to Graphics.Blit(StartTexture, rt). Or use a custom shader which includes "ZTest Always".