0
\$\begingroup\$

I'm having an issue where my UI lags if I try to fill an image that is placed in front of another image. Here is the effect I am trying to achieve:

enter image description here

As you can see I have an image in the background (dashed line) and I am attempting to fill another image in front of it (green line). It's hard to see in the GIF but my game is 60 FPS and the fill animation is noticeably jittery. It took me a while to figure out that the background image is what is causing the stutter, but I am certain it is.

As soon as I disable the background image (or set its fill to zero) the green line animates buttery smooth:

enter image description here

Again, it is quite hard to see in the GIF but I can confirm that without the dashed line, the animation is buttery smooth at 60 FPS.

Does anyone know how I can overcome this jitter? I need to be able to keep the background image and overlay one on top. I potentially even need to animate more images on top of the green line, so I fear the jitter will get even worse.

Here is what I am doing right now:

  • I have one canvas and two images. Both images are children of the canvas and are positioned in the same world space
  • I have disabled costly features like graphics ray-casting, transparency culling etc.
  • I am deploying to iOS but the lag is happening on both my Desktop and iOS devices.
  • The images are only 512 x 512 so they are not super high-res
  • I have even tried splitting both images into two separate canvases and putting one canvas underneath the other in world space. But this has no effect.

Any advice on how to overcome this lag would be appreciated. I find it surprising that something as simple as this would be so taxing as to create stutter.

__

UPDATE:

Okay so I have been profiling this and it looks like the solid line is breaking the batch, causing a second batch to be created. This only occurs in the first GIF when I am overlaying the solid line. So I guess I need to find a way to prevent this batch-breaking.

__

UPDATE 2:

After researching the above I have updated my project to use a sprite atlas, which contains both images. I can confirm after profiling the UI that there is no longer any batch breaking taking place. In fact, the same number of batches are now achieved in both scenarios. Yet I am still seeing the stuttering when I try to overlay the image (first gif).

I thought the sprite atlas would work so I’m now stumped again. Please help?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Is it possible that this lag is due to a simple visual trap? When the green line grows in the dashed line interval, it is not easy for the human eye to distinguish them in an instant, so the brain thinks that the solid line is stuck. Just a guess. \$\endgroup\$ Commented Dec 22, 2022 at 18:24
  • \$\begingroup\$ Mangata - I cannot thank you enough, you are absolutely right! I have been fixating on this for over a week trying to figure out what is wrong, but I just tried animating a solid blue line over a solid red one, and it is smooth. So yes, it is a visual trap! Bravo to you! \$\endgroup\$ Commented Dec 23, 2022 at 20:11

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.