• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Surface limit?

Hello!
Does anyone know the if there is any limits on surfaces?
I'm working on a top-down survival game. When the player crafts items they can be crafted out of any combination of materials. (Eg: copper,gold and wood)
Currently i'm using surfaces to draw the item sprites recoloured (using a shader) to match the materials it is made of.
The inventory could have between 20-40 slots as well as other gui slots such as crafting slots, chests etc. I am using a surface for every slot in the game as well as the actual items worn/held by the player.
In total there could potentially be up to 100 surfaces. Each are no more than 16x16 in size.
Each surface only gets updated when it needs too (when the slot changes) so it doesn't cause lag on my gaming laptop.
However I'm concerned that using this many surfaces is going to be an issue for people with less powerful pc's with less RAM. Anyone know if having 100 16x16 surfaces is a bad idea and if so, do you have any ideas as to how I can recolour each item in my inventory as required?
I'm getting about 40-50 texture swaps at the moment with my inventory half full.
Thanks!
 

TheouAegis

Member
It depends on the system. Some systems won't even handle 2 surfaces. Id your surfaces are small enough, it should be ok in general. As you can see already, you are increasing the Draw event's workload.

How are you drawing them recolored? Personally I think having multiple sprites would be better. It's better to have 4 large texture pages than it is to have a 100 small ones.
 
It depends on the system. Some systems won't even handle 2 surfaces. Id your surfaces are small enough, it should be ok in general. As you can see already, you are increasing the Draw event's workload.

How are you drawing them recolored? Personally I think having multiple sprites would be better. It's better to have 4 large texture pages than it is to have a 100 small ones.
Thanks for you reply. I am using a shader to recolour the items because each item has up to 3 materials which can be combined in any order. So a pickaxe of copper, wood and iron looks different to a pickaxe of iron, copper and wood. Basically there's going to be way to many combinations to draw all those sprites.
Also to many different materials to use the shader with different uniforms (shader noob i think thats the right term) on every draw event, thats why I'm saving it to surfaces.
Thinking now I could use one single surface that is the size of the gui layer and draw my inventory to that. It just means that if any of the slots change or is hovered over by the mouse then the entire gui needs to update so probably worse performance because of all those recolours happening on 1 step.

take a breath...

Also another thing is that the game has base building which works the same - each placed block,structure, etc has up to 3 materials and will need to be recoloured accordingly. So my initial estimate of up to 100 surfaces...hmm could be potentially hundreds :-( definitely not good.
Any ideas on how I can recolour all items and structures/blocks on screen at once? Or with reliable performance?

Sorry for the confusingness...
Appreciate your help and ideas!
 
Ok so I'm thinking maybe I could avoid using surfaces for recoloring enturely by just setting my shader at the draw begin event and then drawing everything that needs recoloring. My question is now:
Does shader_set_uniform cause a texture swap? Every sprite has a different set of colors to be changed to so i would need to set the uniform before each sprite draws.
 
Top