Adobe Director Online
 
Sridevi Aishwariya

Viswanath S
Director Developer

Ripple Effect using perlinNoise and Displacement Map

 
Download the source file here.
 


With the addition of Bitmap Filters in Director 11, I’m sure it will open up many possibilities in Image Effects for Director Content. I’d like to discuss one such effect, may be a commonly used one, Ripple Effect.

Doing this is very simple. Displacement map requires two images to do the displacement. So we are taking one image where we want to apply displacement map. The other one is an image on which Perlinnoise is applied. As and when the perlinnoise gets animated, the image on which Displacement map is applied also gets animated.

So, what are we waiting for? Let’s get started…

  1. Before starting this, make sure you have downloaded two png files, land.png and water.png from here.
  2. Launch Director. Import both the png files.
  3. Set the stage size to 300x288. Place the water.png on the stage little above vertically. So in Property Inspector’s sprite tab it would be L:0, T:-12, R:300, B:300. Name the sprite as ‘water’
  4. Place the land.png exactly in the center of the stage. In the Property Inspector’s Sprite tab it would be L:0, T:0, R:300, B:300.
  5. Now, we need one more image to apply the perinNoise on. So let’s create a paint bitmap. Open Paint window, draw a filled rectangle and name it as ‘Bitmap’.
  6. Place the  OUTSIDE the stage and scale it to 300x300 using Property Inspector. We don’t want to see this image in the final content. We want to just use the perlinNoise properties of this image.
  7. Starting with out first code, let’s apply perlinNoise to member(“bitmap”). Open the script window and write the following movie script.

    global perlinOffset

     

    on prepareMovie

      -- Create a list and associate with variable perlineOffset.

      -- This list is required for the perlinNoise.

      perlinOffset = list()

      repeat with i = 1 to 5

        p = point(3,3)

        perlinOffset.append(p)

      end repeat

     

    end

     

    on exitFrame me

      -- change the baseX and baseY values for the size of the perlinNoise

      baseX = 70

      baseY = 70

      numOctaves = 5

      seed = 1

      bStitch = true

      bFractalNoise = true

      bGrayscale = 0

      chanOptions = 7

     

      repeat with i = 1 to numOctaves

        getP = perlinOffset[i]

        -- Change these x and Y values to speedup the perlinNoise

        x = 1

        y = 1

        x = x + getP.locH

        y = y + getP.locV

        tempP = point(x, y)

        setAt perlinOffset, i, tempP

      end repeat

      myImage = member("bitmap").image

      -- Apply the perlineNoise on the image of member("bitmap")

      myImage.perlinNoise(baseX, baseY, numOctaves, seed, bStitch, bFractalNoise, [#channelOptions:chanOptions, #grayscale:bGrayscale, #offsets:perlinOffset])

      member("bitmap").image = myImage

    end


  8. Play the movie and you can see the perlinNoise getting animated on ‘Bitmap’ member.
  9. Now, let’s apply the Displacement map on ‘water’ sprite using the ‘Bitmap’ sprite. Select the ‘water’ sprite, go to filter tab of Property Inspector and choose Displacement Map. Do the following Settings;

    map: member “bitmap”
    Comp X: Green, Comp Y: Red
    Scale X: 20, Scale Y: 20
    Mode: Ignore

  10. You can observe the pixels getting shifted. What we need is it to be continuous. Right-Click the water sprite on the score and choose ‘Script…’ Insert the following script.

    on exitFrame me

      -- on exitFrame, apply the filter continuously.

      sprite("water").filterList[1].map = member("bitmap")

    end


  11. Now, play the movie, sit back and enjoy the ripple :)

Feedback:
If you have any questions or comments concerning this article, please send a message to viswa1999@yahoo.com

 
spacer image
This is not an official site from Adobe. If you need any clarifications, please mail me at info@adobedirectoronline.com