iDevGames Forums
Water effect - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: Water effect (/thread-8934.html)



Water effect - markhula - May 8, 2011 02:39 AM

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.

Cheers


RE: Water effect - bgulanowski - May 8, 2011 11:17 AM

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).


RE: Water effect - OneSadCookie - May 8, 2011 04:38 PM

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


RE: Water effect - EvolPenguin - May 8, 2011 08:13 PM

Why not ES 2.0? He could be targeting 3Gs devices and later?
Alex


RE: Water effect - markhula - May 8, 2011 11:41 PM

Hey all,

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

Cheers


RE: Water effect - OneSadCookie - May 9, 2011 12:10 AM

I'm sure both remaining 3G users will appreciate the effort Wink


RE: Water effect - markhula - May 9, 2011 12:29 AM

Lol!
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.

cheers


RE: Water effect - EvolPenguin - May 9, 2011 09:45 AM

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!
Alex


RE: Water effect - Zwilnik - May 9, 2011 03:11 PM

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).


RE: Water effect - markhula - May 10, 2011 12:03 AM

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.

Cheers