- Home /
Weird rendering glitch when camera and canvas are different sizes.
Hey, I have a script that keeps the camera in the same aspect ratio on any computer. But the canvas still always fills up the whole screen. But when they're different sizes a weird rendering glitch happens where something in the canvas is rendered, but stays there indefinitely unless something is rendered above it. Here's a gif of what it looks like: GIF
Does anyone have a good solution to fix this? It's not game breaking or anything but would be nice without it. Thanks for the help!
Answer by Pangamini · May 13, 2019 at 09:28 AM
You have probably changed the camera's viewport to keep the aspect ratio, right? That means it keeps the rest of the screen untouched. Which means, nothing is clearing that part of the screen to a 'defaut color' - which means anything that's rendered there, stays there (sometimes causing flickering due to the double/triple buffering). Then, your canvas is rendered over that part of the screen, also not overwriting the background.
The solutions here would be: Clear the whole screen to a default color somehow; for example, using another camera (that only clears the screen and renders nothing, and does it before the main one), or having an opaque background in your canvas.
Answer by EternalClickbait · May 13, 2019 at 10:23 AM
Try setting clear flags on the camera. It might not help though
It probably won't, since the camera will only clear it's viewport, not the entire screen
Your answer
Follow this Question
Related Questions
Best way to exclude canvas from postprocessing 0 Answers
Canvas screen space to world space not working. 1 Answer
Camera rendering with canvas overlay shrinking 0 Answers
Psychedelic camera effect 2 Answers