- Home /
Alternatives for using vertex colors + vertex lighting, IOS
I'm creating a game that involves an array of 6x6x3 semi-transparent cubes, on IOS.
Initially, I had a simple vertex-color shader with transparency, and a single point light in the scene. On iPhone 4S, this performs beautifully, and I get a steady 60fps (or near to). On iPhone 4, however, the best I could manage was around 12 fps.
The reason for using vertex-color shader was that the cubes are all different colors, and this was a way of getting them to batch: by setting the color of the cubes directly via vertex colors.
I've found that the problem with the iPhone 4, with this number of pixel lit cubes, is that the point light (just one) is the killer. When I replace the shader with an unlit transparent vertexcolor, and remove the light, I jump up to 30+ fps, which is at least manageable.
My question is is there any form of light that I can introduce (or some alternate strategy for keeping an array of coloured, semi-transparent cubes on screen batching, to be able to use vertex color lighting) bearing in mind, currently the vertex colors are being used to actually colour the cubes?
Unfortunately, my low poly bevelled cubes just look a million times better with a pixel light and without, look completely flat.
Answer by ScroodgeM · Aug 15, 2012 at 06:23 PM
sol 1
use lightmap if cubes are not moving
sol 2
pre-calculate lighting effect per vertex and compute result color with lighting effect to apply to vertices, recalc it if light moved
sol 3
store lighting power effect (not color) in one of vertex color component (alpha?) and apply it just by muliply to light color instead of normal-calculating
sol 4
objects placed far from point light place to another layer and apply directional light to it instead of point