Any sort of filters for opengl?

I implemented a time stop powerup in my game and I was wondering if there was some way to apply a filter to make everything black and white. I don't want to have to include knowledge of this in all my various rendering code because its very specific to this item. Any thoughts? Maybe some trick about drawing a transparent grey rectangle on top of everything at the very end?

Right, no shaders on current versions of iPhone. I suppose you could render your scene to a texture, then desaturate it, then redraw it as a single texture. I don't know what kind of performance you'd get, but it may be worth a try.

Ill try a transparent rectangle first. That's the easiest. I don't need it to be 100% black and white, I just want to put a noticable tint of some kind on the screen to make it obvious that something happened

You can do this without shaders on the iPhone - in fact, I use this effect in Ancient Frog for the action replay mode.

The key is that dot3 blending sums the three colour channels, having done some other stuff to them. The trick is to first do the inverse of that other stuff so you're left with just the combined channel values.

You need to first render your scene to a texture. Then, in texture unit 0, you interpolate your screen texture towards mid-grey, and in texture unit 1 you perform a dot3 between that and a colour which defines how the channels are to be mixed. (I use #c0c080ff because it makes the vegetation look a bit like it's been shot with slightly IR-sensitive film, but you can use #aaaaaaff if you want a flat response.)

I'll post code if you need it, but it's more fun to fiddle around and see how it works. (Also I'd need to actually write the code - in Ancient Frog, all of the materials are defined in script files using my own format, so there isn't a conveniently copy-and-pasteable example.)

kendric Wrote:That would then require all the rendering code to know to switch to using the new texture at the right time. There are no shaders right? So there is no post processing of the entire image in iphone?

Greyscale conversion is entirely doable on the iPhone:
1) render scene to texture
2) interpolate scene from [0..1] to [0.5..1] on first texture unit
3) dot product result with weights (average or perceptual) on second unit

You'll have to render to texture to do it, which means additional fillrate overhead. That's the same situation you'd have even if you had shaders, though.

If anybody happens to be confused about why it seems like arekkusu is echoing AncientMoose's post, it's because AncientMoose's post had to wait to be approved. This post approval thing for new members can be confusing at times. Well anyway, welcome to iDevGames AncientMoose!