Making a 2D game for iPhone/iPad and need better performance?

Source: Internet
Author: User
I'm using unity and spritemanager 2 to make a 2D game for the iPhone/iPad. using the shader has ded with SM2 and/or the mobile vertex colored shaders has ded with unity left me extremely GPU/fillrate bound on the iPad in particle. I was seeing anywhere from 50-90 ms per frame for "CPU-waits-GPU" from the internal profiler running on the iPad. I wrote my own shaders and dropped this to an average of 10 ms per frame. I 've still got a few Optimizations to go on my game but I figured I 'd share the shaders I wrote in case anyone else out there might find them useful.

The best use for these shaders is if you are making a Sprite-based game where you layer the sprites and use Alpha to create a more traditional 2D looking game. these shaders do not support scene lighting at all but they do support Vertex coloring. basically if you just want your textures to look pixel perfect and unaltered when rendered in game then these might help.

Also, be sure to edit your appcontroller. mm to disable OpenGL ES 2.0 or your framerate is going to suffer tremendously. Line 70 of your appcontroller. MM shocould read:

# Define use_opengles20_if_available 0

Here is the shader that supports Alpha transparency and Vertex coloring:

Shader "unencrypted transparent vertex colored "{
Properties {
_ Maintex ("base (RGB) trans (a)", 2d) = "white "{}
}

CATEGORY {
Tags {"queue" = "Transparent" "ignoreprojector" = "true" "rendertype" = "Transparent "}
Zwrite off
Alphatest greater 0
Blend srcalpha oneminussrcalpha
Subshader {
Pass {
Bindchannels {
Bind "vertex", Vertex
Bind "texcoord", texcoord
Bind "color", color
}

Fog {mode off}
Lighting off
Settexture [_ maintex] {
Combine texture * Primary, texture * Primary
}
}
}
}
}

Here is a shader that just renders your texture without any lighting or alpha transparency:
Shader "unregister "{
Properties {
_ Maintex ("base (RGB)", 2d) = "white "{}
}

Subshader {
Pass {
Settexture [_ maintex] {
Combine texture
}
}
}

}


//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //

Http://forum.unity3d.com/threads/68402-Making-a-2D-game-for-iPhone-iPad-and-need-better-performance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.