iDevGames Forums

Full Version: Water effect
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

My game is a top-down affair and I need a water effect.
Not interested in realisim as wish to keep to 60fps.
Essentially imagine a room filled with water (floor etc. showing through) and the room can be drained so the water level visually sinks.
My first thought was a non textured alpha quad that simply shrinks from the centre and reduce the alpha to fade it out.
Not sure if the alpha alone will kill draw fps; as must function on opengl 1.1 at 60fps :-)
Or perhaps grab the screen as a texture (how do I do that?) draw an alpha quad over the texture and then draw the new texture back to the screen.
Any other methods???; as an aside it would be nice (if possible at 6ofps) to make the 'water' wave i.e. create a slow rippling effect.
Potentially any alpha effect could cover maybe 70% of the screen!!

Any suggestions welcome.

I recommend choosing the simplest solution and then testing performance.

"Top down" could mean a lot, but I imagine you'd have some kind of false perspective?

But I imagine you would just draw the water with alpha inverse to depth of water. I.e. deeper water, more opaque water. Although dark blue/green fog would be better, since then things near the surface would be easy to see and things deeper would be harder to see. In fact, a combination -- the texture for a watery appearance, the fog for water depth.

Hardware-accelerated fog should be plenty fast enough. Just read up on glFog*() (man glFog in terminal on Mac OS X).
Since he's on the iPhone board, he means ES 1.1. That does include fog, though. Not quite sure why anyone's writing 1.1 code any more though Rasp
Why not ES 2.0? He could be targeting 3Gs devices and later?
Hey all,

I wish my app to run on iphone 3g at 60fps hence the opengl 1.1.

I'm sure both remaining 3G users will appreciate the effort Wink
Come on; how many iphone 3g (not 's') exist still in the entire world?
Must be millions (I have 1, so there's one :-) ).
If it runs at 60fps on the basic hardware then it will be obviously fine on any hardware! (can always add visual 'treats' for 3gs etc.).
Just trying to appeal to the widest audience and deliver a console feel at 60fps.

Well, iPhone 3g devices don't support anything past 4.2.1 and have half the ram of the 3gs which has half the ram of the iPhone 4. It's technically discontinued and the 3Gs are so cheap many people may have upgraded. Also, 2 years after they came out (the length of at typical cellphone plan term), the iPhone 4 came out which most people could get subsidized. I can't specifically find the usage numbers by device however, so these are just my thoughts. And as you have an iPhone 3G yourself, doesn't look like there's much of a choice Rasp. Sorry for derailing the thread a bit, good luck with the water!
How is the room itself being drawn? Is it a 3D model with perspective for depth or is it 2D map/sprite based? In terms of its style, is it 'real' perspective or 'dungeometric' (where you draw the floor flat but objects are draw as if they're viewed at an angle from the side with no scaling for depth. The specific method and style of the room drawing pretty much dictates what you can do with your water.

If it's actual 3D with perspective or dungeometric (if you're drawing it orthographic and being sneaky) you can get away with a flat quad (or animating texture on a quad) for the water as its depth will be visible on the walls. For a true flat overhead room style, you're limited to showing the water depth by its transparency and objects in the room appearing as the water goes below their height. That or make it so that all rooms are essentially sloped towards their centre and the water simply shrinks in towards the centre as it lowers (bit of a cheat that one, and somewhat limiting).
Thanks all.
As mentioned I myself have an iphone 3g; so am kind of stuck with that spec; but also I decided if it runs at 60fps on that when ported to Android (with even more variations of spec) then hopefully should be 60fps on that also!! (i.e. min android spec).
The room's are true 2D i.e. tiles; no perspective via opengl.
I guess I am looking at the non-textured alpha quad; but I am certain just the alpha fill-rate will be an issue.

Reference URL's