Z-testing to speed up 2D

BlitzMax Forums/BlitzMax Programming/Z-testing to speed up 2D

ImaginaryHuman(Posted 2012) [#1]
Just a thought.. I'm not sure if Blitz does this or not (guessing not) but if you switch on the Z buffer (e.g. ask for a depth buffer when you open the Graphics), and you switch on z buffer writes and z testing (presume you gotta do this in OpenGL) ... then if you have a lot of overdraw in your scene you can get massively increased performance.

I know that I did one test in Unity where I was drawing a particular shader without z testing, lots of overdraw, thousands of objects, and when I switched z testing on it multiplied the performance like 10x or something because there was a lot of overdraw.

Could be worth switching it on in Blitz via OpenGL or whatever and seeing if it helps busy scenes.

Last edited 2012


GW(Posted 2012) [#2]
I once modified GLmax2d to draw with vertex3f to add a z component. It works and you get depth sorting for free, but it also screws up the alpha blending pretty badly.
I eventually abandoned it and went back to manual z sorting.


ImaginaryHuman(Posted 2012) [#3]
Sure, alphablend needs a depth sort.