MBXLite hueshift approximations?

I’m looking for a way to approximate a hueshift on an animated sprite, without using a pixel shader (since MBXLite doesn’t have them)

It’s a bit of a pickle, because you either lose a lot of performance, or need way too much memory.

The only method I’ve currently come up with is altering the pixels of the graphics resource itself on the fly. This works well enough, but it’s either very slow, or consumed a lot of memory. Here’s the two methods I’ve used:


Method 1:

Store the original pixel data in a Color[ ] (using Texture2D.GetPixels()) and apply a HSV transformation on these pixels at runtime.

Pro: Can shift to any hue you want
Con: Scales very poorly with texture size.

I currently have a 1024x512 texture, so doing over half a million HSV transformations at runtime is not a viable option.


Method 2:

Same as Method 1, but store specific hueShift values in separate Color[ ]'s, and apply those to the texture at runtime.

Pro: Much faster, scales fine with larger textures (in speed)
Con: Takes a lot of memory.

Since I need 5 colors (original, 4 shifts), I consumed 6 times the original texture. For a 1025x512 texture at Fullcolor RGBA, this means any MBXLite device will go out of memory almost immediately.


I’m wondering if anybody has anything that can approximate a hueShift, or knows of any smart tricks to do something like this much faster or using far less memory. If not, I doubt our game will support anything below OpenGL ES 2.

It may just be worth using seperate sprites for separate parts that need a hue shift and then rendering them white for vertex colour hue shift on the mesh.

You could also render the pixels you wanted to hue shift in advance to separate textures as white then vertex colour the quad that texture is on too.

another idea is this shader: http://www.unifycommunity.com/wiki/index.php?title=Masked_Tint

It would be fairly fast if you were doing 2D operations in memory and dumping to texture data in xcode though, but in unity it is going to be pretty tough to work around. Are you certain supporting MBXLite is good business sense particularly as apple stopped making them over a year ago, and no longer support them in ios?

Its a dead device.

The masked tint is probably the best alternative, since it allows me to mask areas where all three channels (RGB) are equal, to avoid incorrectly tinting things that are white.

We’re considering dropping the older devices if this doesn’t pan out, but if it’s a simple addition then it’s always best to aim as low as possible. I know plenty of people that still have them (even though they are sort of deteriorating, lol… the devices, not the people :P)

Yep everyone knows plenty of people who still have them (I have one too), but the majority of people have 3gs or above, the % of people who still have them vs the world is really really tiny, presumably because a lot of people are on contract or whatever.