Advertisement

Tips for increasing fps?

Started by March 05, 2022 06:01 PM
12 comments, last by LtFutt 2 years, 7 months ago

Hi. I'm having a lot of fun programming a “flying” in wormholes game.. The goal is to fly as long as possible with constantly increasing speed in randomly generated “wormholes/tunnels”. I had really good fps when i was just generating one “tunnel”, but when i added more tunnels, fps dropped a lot. I have tried with glQueries to avoid rendering tunnels i dont see. But it doesn't work fast enough when speed is increasing. My question is. Are Queries still a smart/correct way to do it (with opengl), and im just doing it wrong. -Or could there mayebee be some other methods which could be faster/better?

The way i do it now is to split the world in to regions, and then run queries for each region in front of “camera/player”.

LtFutt said:
My question is. Are Queries still a smart/correct way to do it (with opengl),

I would say it never was a really good way. It's brute force, it requires expensive sync across GPU and CPU within a single frame.
With Vulkan you could probably do all on GPU, including conditional draws, but even then i don't think it's a great solution.

What's pretty common these days is reprojecting previous frame, make hierarchical Z pyramid, use that for cluster culling, all on GPU. (Some recent UE5 Nanite Talk with Brian Karis is on YouTube and has all the details.)

Though - Are your tunnels static? Then precomputing a Potentially Visible Set would be the ideal solution for you i think. Assuming you're always inside some tunnel, you could partition your tunnels, and calculate which parts are visible from the current part.

Advertisement

@JoeJ Thanks for helping me! I will scrap queries for now, and check out your recommended methods!

Out of curiosity, when you write “really good fps” and “dropped a lot”, what numbers are you seeing?

Dude you do realize in 20 minutes of playing, speed could be too hard to follow?

@frob Maybe not the best way to “phrase” it. But i had stable 60fps before. Now it's more unstable and can drop to 30fps.

Advertisement

LtFutt said:
Maybe not the best way to “phrase” it. But i had stable 60fps before. Now it's more unstable and can drop to 30fps.

You could post a screenshot of a demanding section if you can, and also give HW specs.
Then we could estimate if a fps drop from scene complexity makes sense. Maybe other reasons are more likely the true cause, like too many state switches, draw calls, etc.
Hidden surface removal always is a lot of work, no matter how. So i'd try to make sure it's really necessary before.

@JoeJ Its just very simple. Behind what you see in this picture there are many more tunnels. They are generated in spereate thread so it doesent steal fps. But they are still rendered as i dont have a good way to exclude whats not in “view”. Please dont judge to hard. This is just “learing” and having fun for me!!

LtFutt said:
Please dont judge to hard. This is just “learing” and having fun for me!!

Don't worry - I didn't expect AAA visuals. It's nice ; )
But i would add some constant fog or a simple atmospheric scattering model, to improve depth perception, so one can instantly see what is far away.

LtFutt said:
They are generated in spereate thread so it doesent steal fps.

I assume you generate a volume of density procedurally. This rules out a PVS, which would make sense only for levels generated offline. So you need a realtime solution, like that UE5 stuff i have mentioned.
But first - do you render only the surface? Or do you render ALL dense cubes of the volume (which would explain it becomes slow)?

Btw, if you want i can give you a code snippet to project the vertices to the smooth surface, so it does not look blocky but smooth.

@JoeJ I would like that “code snippet” yes. But i'm probably to noob to implement it at the moment =) ;P. Its generated procedurally yes. I enter a seed in the beginning and the tunnels generates as i move in to new regions. Regions are16 x16x48(48 is max height) I Only render the surfaces that have “air” next to them. I also compile the regions so that in the next frame i can just call a compile list. The problem is that i dont know how the world is going to look. Im currently looking in to what you previously mentiond “hierarchical Z pyramid”. Do you still think that could be a good way to do it after seeing the picture?

This topic is closed to new replies.

Advertisement