We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › weather effects on an image
Page Index Toggle Pages: 1
weather effects on an image (Read 1339 times)
weather effects on an image
Sep 22nd, 2005, 12:07pm
 
Hi,

Sorry if this is a bit of a newbie question. Are there any tutorials or examples out there for applying weather-like effects to an image i.e. rain, snow, water ripples?

Cheeers,
Gary
Re: weather effects on an image
Reply #1 - Sep 22nd, 2005, 12:55pm
 
Toxi had a nice raindrop effect running under alpha, but I can't find the link at the moment.

His site is well worth looking at anyway

www.toxi.co.uk/p5/
Re: weather effects on an image
Reply #2 - Sep 22nd, 2005, 3:37pm
 
Thanks for that, he has some very nice examples there. I particularly like the cloud effect. But I don't seem to be able to get them to run in my environment. Is it possible this is a Processing version issue?
Re: weather effects on an image
Reply #3 - Sep 22nd, 2005, 4:50pm
 
Try this.
Code:

// animated perlin clouds
// use random start position in the 3d noise space
// once initialised, perlin noise has defined fixed values at every coordinate
// so by moving through the space, we can create animations
float yoff=random(1000);
float xoff=random(1000);
float zoff=0;
float xyScale=0.01f;
// constants for the cloud filter
float CLOUD_COVER = 0.55f;
float CLOUD_SHARPNESS = 0.93f;
void setup() {
size(200,200,P3D);
loadPixels();
noiseDetail(8);
}
void draw() {
// move slowly through the noise space
// use mouse to steer
xoff+=((width/2)-mouseX)*0.001;
yoff+=((height/2)-mouseY)*0.001;
// always move forward
zoff+=0.05;
// var to store noise value
int nV;
// reset index in pixel buffer
int index=0;
// used for speed optimisation
float currYOff;
for(int y=0; y<height; y++) {
// noise Y offset only needs to be changed for each scanline
currYOff=yoff+y*xyScale;
for(int x=0; x<width; x++) {
// filter and scale noise to 0..255
nV=(int)(cloudfilter(noise(xoff+x*xyScale, currYOff, zoff))*255);
// set pixel value
// added to gradient background
pixels[index++]=min(nV+0x90-y/4,0xff)<<16 | min(nV+0xe0-y/2,0xff)<<8 | 0xff;
}
}
}
float cloudfilter(float val) {
return (1-pow(CLOUD_SHARPNESS,max(val-CLOUD_COVER,0)*255));
}

You need to change occurences of loop() to draw() in Beta and any reference to pixels[] must be preceeded with loadPixels() or updatePixels depending on the circumstance. Although where exactly they should crop up in old code will take some experimentation.
Re: weather effects on an image
Reply #4 - Sep 22nd, 2005, 5:07pm
 
Ok thanks, I'd just figured out that was one of the differences. Seems I also need P3D on the size() statement too.

Thanks very much
Re: weather effects on an image
Reply #5 - Jan 17th, 2006, 10:29pm
 
I found this to be pretty helpful.  I had a couple other links but I seemed to have misplaced them, it's been a while Undecided

http://freespace.virgin.net/hugo.elias/graphics/x_water.htm
Page Index Toggle Pages: 1