flickering lines when zooming fov (both GUI and ortho cameras).

I swapped from using planes with an orthographic camera to using OnGUI draw calls, because of flickering that occurred when moving the camera around and zooming out.

Now I notice a similar problem when scaling the GUI.


int px = -Screen.width / 2;
if (zoomX > 0)
{
px = px * -1 ;
}
int py = -Screen.height / 2;
if (zoomY > 0)
{
py = py * -1;
}
GUIUtility.ScaleAroundPivot(new Vector2(zoomX, zoomY), new Vector2(px, py));
//Onto draw textures

Textures larger than 128 * 128 pixels, have lines drawn on them out of nowhere and gaps between them.

Compare this (zoomX=1 zoomY=1)
6753-flickeringlines2.png

With this (zoomX=0.75 zoomY=0.75):
6754-flickeringlines.png

The lines keep flickering as the area rendered moves.

Why is this the case? How can I fix it?

This has been driving me mad for the entire day now :frowning:
Please help!

It’s okay guys, found a solution.

Simply set the wrap mode of each texture to clamp and used
GUI.drawTexture instead of graphics.DrawTexture

and that fixed it. :slight_smile:

I think the Camera should always be moved in LateUpdate… As when we move the camera with the position of the object in Update or OnGUI it flickers… But if we move the camera in LateUpdate first the object takes position in Update then camera sees it in LateUpdate…