- Home /
Cutout shaders for 2D IOS game performance
Hello everyone,
I've read elsewhere that shaders that use cutout will degrade performance on IOS devices, because it prevents some GPU optimizations from happening.
However, according to a post by Apple, these optimizations (Tile Based Deferred Rendering) are prevented by blending, alpha tests, and cutout shaders (using discard in fragment code). Therefore, even the Unity default sprite shader would prevent these hardware optimizations, since it necessarily uses blending to layer overlapping sprites.
Here is the post by Apple (See - Use Hidden Surface Removal Effectively): https://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/Performance/Performance.html
I've also done some profiling in Xcode, and as far as I can tell, using the discard operation in a shader does dramatically decrease performance (30FPS in my app with discard, 40FPS without).
I'm pretty new to shaders, any help would be much appreciated!
Sorry I did not state a question clearly there. $$anonymous$$y question is: For a 2D game on IOS mobile devices, do cutout shaders harm performance?
I have read that cutout shaders harm performance, and as I mentioned in my original post, I found the supposed reason for that on Apple's website. Is Tile Based Deferred Rendering being shutoff the reason people say to use alpha blending shaders rather than cutout shaders?
I did a bunch more tests today, and actually found that in a scene with a lot of overdraw, cutout shaders perform $$anonymous$$UCH better. $$anonymous$$y previous tests in the original post were invalid, because I forgot to remove the framerate cap on the app. With cutout shaders (and no alpha blending), this test hit ~45FPS, and with alpha blending shaders the test hit ~17FPS. The shaders were setup to draw the meshes front to back by z position, so that in the cutout shading test almost no pixel would run more than one fragment shader, whereas in the alpha blending test each pixel would run ~12 fragment shaders. Of course the scene arrangement and textures were kept constant, and just shaders were adjusted.
Does anyone have any thoughts on this? Am I missing something?
Here are screen caps of my tests in Xcode instruments: (Cutout)
... (Alpha blending)
P.S.: I am testing on an iPad Air 2; sorry for the long post!
Your answer
Follow this Question
Related Questions
How to manage images in good resolution in Mobile App 0 Answers
Anti Aliasing on Mobile 3 Answers
3D performance on mobile platforms? 1 Answer
Help me to optimize my mobile game 1 Answer
Bloom/Neon effect Mobile 0 Answers