Search Unity

Transparent textures cause MAJOR lag spikes for me

Discussion in 'Editor & General Support' started by unfungmz, Aug 20, 2018.

  1. unfungmz

    unfungmz

    Joined:
    Jul 29, 2017
    Posts:
    162
    Note: I posted this on the XB1 development forum because this is happening on the XB1 and not really on PC, but that's probably because the XB1's CPU is so much slower than my PC's CPU. So I believe this would be a universal issue if I was on a lower end PC. I just wanted to see if I could get some thoughts from anyone that might be an expert on these issues thanks!

    --------------------------------

    So this weekend I dissected my scene piece by piece to get an idea of what could be causing major lag spikes (despite frame rate claiming consistency) and it looks like it's transparent textures. I'm working on a horizontal shmup and my background are billboards (mountains, valleys) but the foreground is all 3D objects. I have water plane. Was trying to use Aquas but it's way too much of a performance hit, so I just created a couple of transparent planes.

    But here's the thing: I don't see a poor frame rate from these textures. In fact, I'm getting 120 fps at 4K on the X dev kit. But there are major lag spikes that happen for 2-3 seconds. My assumption is that it's being caused by the textures in the background scrolling in from the right and being drawn slowly for some reason - I guess due to having to cut out the textures and draw them on top of each other?

    I just wonder how I could speed it up. If I just have the background in my scene I get 175 fps and no spikes, but that doesn't really mean it's not happening. It just means I'm not seeing it, because I'm on a 60 hz TV. So as long as it can maintain 60 fps I won't see a drop. But when my frame rate hovers in the 120-130 range, I see massive drops, so I can assume these lag spikes are hitting me for 100+ FPS.

    Any thoughts on how I could fix this? My first inkling is to reduce and combine some of the background layers, but I wonder if there's a more "scientific" way I could speed up transparency rendering without having to sacrifice my scene