Webcam Water Ripples revisited



this is a revisit of this project:

while back then the framerate was 10-20 fps at 640x480 pixels(the video back then was actually kind of prerendered), this new version still runs at 60 fps at a resolution of 1024x768(DAMN THAT IS FAST).

The huge speed imrpovement is because I portet the whole thing to GLSL using texture lookups which makes things alot faster. The funny thing is that there is still alot to improve in terms of my FBO handling. Anyways it’s fast allready!

Also the ripples could maybe need some extra smoothing.

VIDEO OF THE GLSL VERSION:
http://vimeo.com/3375772

Hey moka
this is really awesome. How do you implement those GLSL-Shader-stuff? Mind to share some code? especially the backlight programm is very beautiful.
greetings ascorbin

Hi Ascorbin,

There is allready an addon to handle Shaders. I only extended it a little bit to pass different kinds of Uniform Variables to my shaders. I might pose a simple shader example Soon.
I can also recommend the Orange Book which helped me incredibly much to understand how shaders work.

You find the addon if you use the forum search!

Glad you like it :slight_smile:

hi moka

what book i need for make this caind for examples, can obtain the contour, i mmake efects for each pornt of a contour, but this caind of effect like water is my Weakness, o need a book for make visual effects.

of you can helpme with the book, or examplainme onl the water effect…

thx
take care
john

Hi Johnavilla,

basically i use exactly the technique described in this useful article:
http://freespace.virgin.net/hugo.elias/-…–water.htm

I only did it using GLSL, as I said the orange book is areally good start for learning GLSL!

Cheers

wow thx alot moka… i need this so much :smiley: :slight_smile:

Hi moka,
well, it would still be very helpful to see how you did the shader.
How did you access the video-frame in the shader or did you do the math in your program and not inside the shader?
Thanks in advance

I still don’t get a working version of those water ripples with shader.
My main problem is to write the results of the shader into a FBO to use it as a starting point in the next pass.
moka to the rescue :wink:

Gekko:

  
  
fbo1.begin();  
ofClear(0);  
shader1.begin();  
shader1.setUniformTexture("fbo2", fbo2.getTextureReference(), 0);  
  
// Rendering canvas frame in order to make it cleaner to read.  
ofSetColor(255,255,255,255);  
glBegin(GL_QUADS);  
glTexCoord2f(0, 0); glVertex3f(0, 0, 0);  
glTexCoord2f(width, 0); glVertex3f(width, 0, 0);  
glTexCoord2f(width, height); glVertex3f(width, height, 0);  
glTexCoord2f(0,height);  glVertex3f(0,height, 0);  
glEnd();  
  
shader1.end();  
fbo1.end();  
  
fbo2.begin();  
ofClear(0);  
shader2.begin();  
shader2.setUniformTexture("fbo1", fbo1.getTextureReference(), 0);  
  
// Rendering canvas frame in order to make it cleaner to read.  
ofSetColor(255,255,255,255);  
glBegin(GL_QUADS);  
glTexCoord2f(0, 0); glVertex3f(0, 0, 0);  
glTexCoord2f(width, 0); glVertex3f(width, 0, 0);  
glTexCoord2f(width, height); glVertex3f(width, height, 0);  
glTexCoord2f(0,height);  glVertex3f(0,height, 0);  
glEnd();  
  
shader2.end();  
fbo2.end();  

Thanks Patricio,

I found out that that was not the problem.
I made other different mistakes, that depended on each other.
Don’t like my job, when it makes me feel so stupid :wink:

Hello Gekko! don´t feel bad… working with shaders and FBO´s it´s always a little bit frustrating because it´s so hard tu debug and mistakes usually are just details.

Some tips to be careful about shaders:

1- oF works with version 120 only and with ARB Rect… that means that a lot of commands are not available or apply different.
2- openGL shaders don´t cast! that means that “float f = 1;” will not work! you have write “float f = 1.0” With this you have to be extra-careful I always make stupid mistakes like this.

I will be uploading differents GLSL effects on FX addon ( http://github.com/patriciogonzalezvivo/ofxFX ) there you can find a working class of Water Rippler.

I hope you found it useful

1 Like

I thought I should share my results.
The code’s not pretty at all.

http://dl.dropbox.com/u/14657716/waterShaderCam.zip

Oh, should read the last reply first.
Thanks again, Patricio

Hello Gekko, good work! I´m going to try your implementation. I see you use vertex shaders… I was wondering why… so I´m going to take a look. Thanks for sharing!

I don´t know why my response it´s not visible. I´m going to copy&paste it at the bottom.

Hello Gekko! don´t feel bad… working with shaders and FBO´s it´s always a little bit frustrating because it´s so hard tu debug and mistakes usually are just details.

Some tips to be careful about shaders:

1- oF works with version 120 only and with ARB Rect… that means that a lot of commands are not available or apply different.
2- openGL shaders don´t cast! that means that “float f = 1;” will not work! you have write “float f = 1.0” With this you have to be extra-careful I always make stupid mistakes like this.

I will be uploading differents GLSL effects on FX addon ( http://github.com/patriciogonzalezvivo/ofxFX-) there you can find a working class of Water Rippler.

I hope you found it useful

I’m sorry, I don’t use vertex shaders :frowning:
They’re just passing coordinates without doing anything.

hello,your demo was very cool,but the link (http://dl.dropbox.com/u/14657716/waterShaderCam.zip20)is broken,I can not download it,Can you send it to my email(715705486@qq.com),I am chinese,thank you very much…