Author Topic: water displacement effect  (Read 1762 times)

zadvornykh

  • Active Member
  • ***
  • Posts: 205
  • Karma: +1/-0
    • View Profile
water displacement effect
« on: Tue, Jun 14, 2011 »
Part of my game consists of a deep sea fish swimming under water. To make this somewhat realistic, I want to create a perlin-noise powered water displacement effect (like http://www.derschmale.com/demo/rippler/Ripple.html) inside a lit sphere (so only a small part of the level is visible).

I know the basics for such effects (displacementMapFilter) but I have never tried to implement it in Flixel (or any larger project for that matter).

Has anyone tried something similar in Flixel? If so, should I be worried about performance? My game is pretty huge already, and I am weary of piling on more things.

vonWolfehaus

  • Active Member
  • ***
  • Posts: 247
  • Karma: +0/-0
    • View Profile
    • Cold Constructs
Re: water displacement effect
« Reply #1 on: Tue, Jun 14, 2011 »
The only way to find out is to try it. Running that effect in Flixel is the same as anything else, unless you're scaling your game up, in which case it wouldn't be as much of a hit (50% at 2x zoom etc).

But I've found that features that aren't necessary--or if there's a fast way to fake them--then forget them and move on.
Meet Obama every day at #flixel on irc.freenode.net.
Use your favorite IRC client or  http://webchat.freenode.net/

cai

  • Contributor
  • ****
  • Posts: 465
  • Karma: +0/-0
  • the illest of villains
    • View Profile
    • Brandon Cash
Re: water displacement effect
« Reply #2 on: Tue, Jun 14, 2011 »
I've done this in my WIP game Eden Island.  It generates perlin noise and then uses a DisplacementMapFilter to do the rippling.  If you want to make it follow the mouse and such, that'll be significantly harder, but certainly not impossible.

Check out the code I used to achieve the effect.  It's from an old version of flixel, but it's mostly custom stuff anyway.

You should also check out the Flixel Showcase: Displacement Effects.
« Last Edit: Tue, Jun 14, 2011 by cai »
Follow me on Twitter | Come join us at #flixel on irc.freenode.net!

zadvornykh

  • Active Member
  • ***
  • Posts: 205
  • Karma: +1/-0
    • View Profile
Re: water displacement effect
« Reply #3 on: Tue, Jun 14, 2011 »
Thanks for the resources, it's a big help :).

nineraser

  • Member
  • **
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: water displacement effect
« Reply #4 on: Wed, Jun 15, 2011 »