Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Using the shader efficiently

A topic by balmut created Jun 09, 2023 Views: 160 Replies: 2
Viewing posts 1 to 3

Hi Pixelated Pope! Sorry to bother you, I was wondering if you had any advice on how best to use this with multiple things efficiently. 

I'm making a top down game where it's (currently) possible to change the walls and floors of the Buildings you've made using your shader, but it seems to cause some slowdown on weak GPU's when there's more than a few uses of the shader happening at once.


I've tried changing to draw things in batches with setting the palette before hand, but it didn't have any effect on reducing the Vertex Batch count (I'm assuming that's what the second number in the Debug Overlay is).

Next I was going to try breaking up your shader so that the [shader_set_uniform_f] only get set at the start of each batch, but I thought I may as wall ask beforehand.


Thanks for your time, and for all the amazing work you do!

Developer(+1)

Haven't ran into too many issues myself performance wise. Typically shader performance is "gated" by how often you are calling shader_set and shader_reset more than just about anything else.  Vertex batch count isn't usually a good measure of how "performant" anything is. I've had something running at 60fps with my batch count in the thousands.
Other issues can be your application surface size.  Your art may be low res, but if you've upscaled your app surface size to get sub pixels, you are doing more work. You could be swapping 4 to 16 times the number of pixels than you really need to. Other concerns are palette sizes. If your palette has tons of colors, then that's more colors the shader needs to search through to find a match (or it ends up going through all of them when there is nothing to match)

There are lots of ways to improve performance, but it's all going to be very, very specific to your project. I'd recommend asking on the GM Discord server when you have time to sit down and work on it. Lots of people there that can help you figure out exactly what is slowing you down and how to improve it.  Best case scenario would be you working on said "lower end" machine, or setting up a use case where you are experiencing the performance issues yourself.

Ahh ok, I thought it was setting the uniforms that was the heavy part. My palettes are pretty small, only a 3-4 colours per row, and maybe 6 columns max.
If Vertex batche isn't a good measure then I think my issue might just be the tablet I tested it on was super weak. I've not checked what the spec is, but I can't imagine an old MS Surface is very powerful! (it did crash trying to play Sonic Mania lol)
Thanks for your help!