Go Back   kirupaForum > Talk > Source/Experiments

Reply
 
Thread Tools Display Modes
Old 01-09-2006, 10:25 AM   #1
Ordinathorreur
[Sensitive Data Removed]
 
Ordinathorreur's Avatar
Lets make some (perlin) noise!

This thread sort of continues from this one but concentrates on some of the funky stuff we can do with the new Flash 8 perlin noise function, like create clouds, wood, water and other cool new things.

Edit: Please experiment and add your creation! You can find a playground .fla a couple of posts down...

Here's a perlin noise generated displacement map warping an image:

ActionScript Code:
import flash.display.BitmapData;
import flash.geom.Point;
import flash.filters.DisplacementMapFilter;
import flash.filters.DropShadowFilter;
Stage.scaleMode="noScale";
// Perlin noise variables, I encourage you to play around with these...
var baseX              :Number = 200;
var baseY              :Number = 200;   
var nOctaves           :Number = 1;
var randomSeed         :Number = Math.random()*10;
var bStitch         :Boolean = false;
var bFractalNoise      :Boolean = true;
var nChannels          :Number = 1;
var bGreyScale      :Boolean= false;
// Offset array for perlin function
var p1 = new Point(45, 34);
var p2 = new Point(50, 60);
perlinOffset = new Array(p1, p2);
// Create the bitmapdata we are going to change with the perinNoise function       
bmp = new flash.display.BitmapData(400,300,true,0x00000000);

onEnterFrame = function (){
    //    change the values in the perlinOffset to animate each perlin layer
    perlinOffset[0].y-=2;
    perlinOffset[0].x-=2;
    perlinOffset[1].x+=1;
    perlinOffset[1].y+=1;
    //    apply perlin noise to our bitmapdata
    bmp.perlinNoise(baseX, baseY, nOctaves, randomSeed, bStitch, bFractalNoise, nChannels, bGreyScale, perlinOffset);
    //
    //    Uncomment the following line to see the generated perlin noise
    //_root.attachBitmap(bmp, 1, "auto", true);
    //
    //    Now use the bitmapdata in bmp as a base for the distortion
    dmf = new DisplacementMapFilter(bmp, new Point(0, 0), 1, 1, 20, 20, "color");
    //    and apply it to our pic (instance name sourcePic)
    sourcePic.filters = [dmf];
}
Attached Files
File Type: swf perlindisplacement.swf (2.5 KB, 1697 views)

__________________
* create a timeline on timetoast * "We dig it!"

Last edited by Ordinathorreur; 01-09-2006 at 04:57 PM.. Reason: Added scalemode for non-beefy computers
Ordinathorreur is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 01-09-2006, 10:32 AM   #2
hybrid101
iAm t3h hybrid
 
hybrid101's Avatar
Location In my House

Posts 6,173
cool effect, distorting that octopus!
hybrid101 is offline   Reply With Quote
Old 01-09-2006, 10:40 AM   #3
Ordinathorreur
[Sensitive Data Removed]
 
Ordinathorreur's Avatar
The octopus is actually the logo of Humanworkshop records. A great up and coming label from holland. www.humanworkshop.com

I can't wait to see what the other members are going to do with perlin noise!

__________________
* create a timeline on timetoast * "We dig it!"
Ordinathorreur is offline   Reply With Quote
Old 01-09-2006, 10:48 AM   #4
boohaha
Unpisteftable!
 
boohaha's Avatar
Location Center Of The World, Athens, Greece

Posts 138
Nice job Ordinathorreur, though you push me (indirectly) to buy some more RAM...
boohaha is offline   Reply With Quote
Old 01-09-2006, 11:01 AM   #5
Ordinathorreur
[Sensitive Data Removed]
 
Ordinathorreur's Avatar
If you want to use this in your own projects, lower the baseX and baseY values to spare ram.

__________________
* create a timeline on timetoast * "We dig it!"
Ordinathorreur is offline   Reply With Quote
Old 01-09-2006, 11:32 AM   #6
Seb Hughes
Registered User
 
Seb Hughes's Avatar
I have 2gb or ram so life is good there, and i have to say, that kicks *** man, nice good, keep it up

__________________


Member #2 of the "I wont critique Timmytot's designs anymore" club.
Seb Hughes is offline   Reply With Quote
Old 01-09-2006, 12:02 PM   #7
icio
looks better in lowercase
 
icio's Avatar
Location Edinburgh, Scotland

Posts 3,689
That's really cool, dude. I'll see if I'm able to do anything with perlin later on. Your idea was that everyone post their (perlin) noise in this thread, right?
icio is offline   Reply With Quote
Old 01-09-2006, 12:30 PM   #8
Pattt
Hm?
 
Pattt's Avatar
Well I post my first texture again, a data chip!


ActionScript Code:



import flash.display.BitmapData;
var bmp:BitmapData = new BitmapData(300, 300, false, 0x000000);
this.attachBitmap(bmp, 1);
// - - - - - - - - - - - - -
bmp.perlinNoise(10, 10, 5, 10, false, false, 1, true);






__________________
[ veclock.deviantart.com ]
Pattt is offline   Reply With Quote
Old 01-09-2006, 12:59 PM   #9
Ordinathorreur
[Sensitive Data Removed]
 
Ordinathorreur's Avatar
Patt, do you think you could post a .swf for those who don't have Flash 8?

And Icio, post away!

Here's a .fla for those of you who want to learn a bit more about what each variable does.
I replaced the octopus with a creation of my own and added a quick hack so if you click the pic you can see the perlinnoise you generate too. This one also has 2 octaves instead of one.

Edit: Some cool suggestions:
Change baseX or baseY to 0 for a flag/banner effect.
Change the perlinOffset[0] or [1] x and y values to a higher number for a faster animation.
Set bFractalNoise to false
Attached Files
File Type: fla perlindisplacementplayground.fla (73.5 KB, 501 views)
File Type: swf perlindisplacementplayground.swf (20.6 KB, 677 views)

__________________
* create a timeline on timetoast * "We dig it!"

Last edited by Ordinathorreur; 01-09-2006 at 05:07 PM.. Reason: Updated .fla
Ordinathorreur is offline   Reply With Quote
Old 01-09-2006, 01:23 PM   #10
Pattt
Hm?
 
Pattt's Avatar
sure!
Attached Files
File Type: swf chip.swf (182 Bytes, 555 views)

__________________
[ veclock.deviantart.com ]
Pattt is offline   Reply With Quote
Old 01-09-2006, 02:32 PM   #11
treatkor
relax
 
treatkor's Avatar
kirupa goes scuba diving

displacement map with transparent png.
i thought about adding a second, slower and softer displacement map for the background, which i think would be a cool effect, but since this is processor intensive, i didn't.
Attached Files
File Type: swf kirupascuba.swf (34.6 KB, 650 views)
File Type: zip kirupascuba.fla.zip (50.3 KB, 243 views)

__________________
treatkor is offline   Reply With Quote
Old 01-09-2006, 03:12 PM   #12
Seb Hughes
Registered User
 
Seb Hughes's Avatar
^^^^Nifty

__________________


Member #2 of the "I wont critique Timmytot's designs anymore" club.
Seb Hughes is offline   Reply With Quote
Old 01-09-2006, 05:01 PM   #13
icio
looks better in lowercase
 
icio's Avatar
Location Edinburgh, Scotland

Posts 3,689
Here's how to use perlinNoise with offsets to create a cloud-scrolling effect:

ActionScript Code:
Stage.scaleMode = "noScale";

import flash.display.BitmapData;
import flash.geom.Point;

var xpos:Number = Math.floor(Math.random()*100);
var ypos:Number = Math.floor(Math.random()*100);
var seed:Number = Math.floor(Math.random()*10);

var p:Point = new Point(xpos, ypos);
var offsetArray:Array = [p, p, p, p, p];

var bitmap:BitmapData = new BitmapData(300, 300, false, 0); _root.attachBitmap(bitmap, _root.getNextHighestDepth());
bitmap.perlinNoise(bitmap.width, bitmap.height, 5, seed, true, true, 8, true, offsetArray);

function onEnterFrame() {
    xpos += Math.floor((_xmouse-Stage.width/2)/2);
    ypos += Math.floor((_ymouse-Stage.height/2)/2);
   
    var p:Point = new Point(xpos, ypos);
    offsetArray = [p, p, p, p, p];
   
    bitmap.fillRect(bitmap.rectangle, 0);
    bitmap.perlinNoise(bitmap.width, bitmap.height, 5, seed, true, true, 8, true, offsetArray);
}
Attached Files
File Type: fla clouds.fla (42.0 KB, 239 views)
File Type: swf clouds.swf (462 Bytes, 644 views)
icio is offline   Reply With Quote
Old 01-09-2006, 05:13 PM   #14
Ordinathorreur
[Sensitive Data Removed]
 
Ordinathorreur's Avatar
Sweet!

__________________
* create a timeline on timetoast * "We dig it!"
Ordinathorreur is offline   Reply With Quote
Old 01-09-2006, 05:21 PM   #15
icio
looks better in lowercase
 
icio's Avatar
Location Edinburgh, Scotland

Posts 3,689
Thanks, I really like the displacement stuff that you've done
icio is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make my PC QUIETER!!! ya3 Computers & Games/Tech 23 02-04-2005 10:12 PM
Very Confused how to make a submit e-mail button bongorific Flash MX 2 04-24-2003 01:22 AM
make Favorites and make homepage script wakasmir Flash MX 2 04-18-2003 05:12 PM
Submission Tips Phil Jayhan Best of Kirupa.com 1 06-07-2002 07:54 PM


All times are GMT -4. The time now is 06:03 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com