PDA

View Full Version : Displacement mapping (for water effect)


lilive
10th October 2009, 12:12
Hello,

I can't find any plugin to do "displacement mapping" (like Photoshop or Gimp filters). I join the images to explain.

Before :
http://forum.doom9.org/attachment.php?attachmentid=10370&stc=1&d=1255169118

Map image :
http://forum.doom9.org/attachment.php?attachmentid=10371&stc=1&d=1255169130

After :
http://forum.doom9.org/attachment.php?attachmentid=10372&stc=1&d=1255169140

I want to distort a video with an other one (a water surface), to obtain a "liquid effect".
I know that it's possible with EffectWater (http://avisynth.org/vcmohan/EffectsMany/EffectWater.html), but I'm looking for something more "natural".

Thanks for any help.

Zarxrax
10th October 2009, 19:00
I don't think you can do this with avisynth. Why don't you just do it with photoshop or gimp?

MadRat
12th October 2009, 06:57
I'd say it's more like, "I don't think you can do this with avisynth... yet." ;)
(And no that's not a hint I'm writing a plug-in for it.)

shoopdabloop
13th October 2009, 01:09
The problem is, Avisynth isn't really used for fancy distortion effects..a NLE like After Effects or Vegas is more suited for your needs.

Leak
13th October 2009, 09:54
The problem is, Avisynth isn't really used for fancy distortion effects..a NLE like After Effects or Vegas is more suited for your needs.
ITYM "nobody has implemented a general-use bump mapping filter yet"...

I think the latest aWarpSharp rewrite (http://forum.doom9.org/showthread.php?t=147285) allows you to specify a bumpmap, but I'm not sure if it supports a big enough radius to get the above results...

Mug Funky
16th October 2009, 06:38
it's possible that mvtools can be abused to do this - get vectors from a displace clip, and apply compensation on the target clip.

the trick would be getting a good representation of the original bump map, rather than a wacky derivative of it.

JohannesL
17th October 2009, 23:56
Maybe the EffectsMany plugin can do this.
edit: didn't see you already knew that

lilive
25th October 2009, 15:57
Hi,
Thanks for your replies ! I haven't set my default subscription mode so I just see your messages, and that's why I'm late.

I don't think you can do this with avisynth. Why don't you just do it with photoshop or gimp?

I want to do it with 2 videos, frame by frame. One for the image source, one for the map. I don't think it's possible with photoshop or the gimp (without convert videos to images sequences), but I have to verify it.

The problem is, Avisynth isn't really used for fancy distortion effects..a NLE like After Effects or Vegas is more suited for your needs.

I've got After Effect at job. I just try some basic stuff I've already done with AviSynth, and AviSynth is really faster. And I usualy use avisynth. But if I can't, I will try again.


I think the latest aWarpSharp rewrite (http://forum.doom9.org/showthread.php?t=147285) allows you to specify a bumpmap, but I'm not sure if it supports a big enough radius to get the above results...

The documentation is really light. I don't see how to do...

it's possible that mvtools can be abused to do this - get vectors from a displace clip, and apply compensation on the target clip.

the trick would be getting a good representation of the original bump map, rather than a wacky derivative of it.

I tried a bit. But I'm not sure how to do it. I think I must use the water video luma as displacement vectors, but how ?

Here's my test, with a single image as original video :

LoadPlugin("C:\Program Files\AviSynth 2.5\others-plugins\mvtools-v2.5.8\mvtools2.dll")

ImageSource("image.jpg", end=1000)
ConvertToYV12()
src = last
srcSuper = MSuper(src)

AviSource("water.avi", audio=false)
BicubicResize(src.width, src.height)
MSuper(last)
vectors = MAnalyse(isb =false)

MCompensate(src, srcSuper, vectors)

This isn't good. The video result is distorted, but it doesn't look like an underwater picture.

shoopdabloop
25th October 2009, 19:33
I think MFlow is what you're looking for, and also doesn't MAnalyse require a super clip to be specified?

lilive
25th October 2009, 22:03
I think MFlow is what you're looking for, and also doesn't MAnalyse require a super clip to be specified?
Thanks for that. The result is smoother, but it's not what I'm looking for.
Here's some tests :
displacement video (http://perso.numericable.fr/olivier.tarasse/test/map.avi)
motion vectors video (http://perso.numericable.fr/olivier.tarasse/test/vectors.avi)
result with MCompensate (http://perso.numericable.fr/olivier.tarasse/test/mcompensate.avi)
result with MFlow (http://perso.numericable.fr/olivier.tarasse/test/mflow.avi)

The code is :

LoadPlugin("C:\Program Files\AviSynth 2.5\others-plugins\mvtools-v2.5.8\mvtools2.dll")
loadPlugin("C:\Program Files\AviSynth 2.5\others-plugins\EffectsMany\EffectsMany.dll")

ImageSource("Apples.jpg", end=100)
ConvertToYV12()
src = last
srcSuper = MSuper(src)

BlankClip(src, color=$888888)
EffectBalloon(last, 0,99, 30,$888888, 100, 1)
MSuper(last)
vectors = MAnalyse(last, isb =false)

MCompensate(src, srcSuper, vectors)
#~ Or
#~ MFlow(src, srcSuper, vectors)


The problem is that I don't want to displace the pixels with the motion vectors of my displacement video, but with its pixels luma values (like the photoshop and gimp filters).

Gavino
25th October 2009, 23:03
The problem is that I don't want to displace the pixels with the motion vectors of my displacement video, but with its pixels luma values (like the photoshop and gimp filters).
How do those filters actually work then?
How do you get a (2-D) vector out of a scalar quantity like luma?
Perhaps luma determines the magnitude of the vector, while the direction varies in some uniform way across the image?

shoopdabloop
25th October 2009, 23:21
I think maybe you could have an animated video of the blurry blobs starting small and getting bigger, and then using some vectors from that to distort the text.

But this would be for a still image.

lilive
26th October 2009, 09:49
How do those filters actually work then?
How do you get a (2-D) vector out of a scalar quantity like luma?
Perhaps luma determines the magnitude of the vector, while the direction varies in some uniform way across the image?

I think the simplest form of this kind of filter is luma determines the magnitude of the vector (like you said) and the direction is fixed for the entire image.
Here's a flash exemple (http://www.webwasp.co.uk/tutorials/221/index.php) : logo and text move in the left top direction, according to the scrolling background luma.
An other form is to use 2 images for displacement. One give X displacement, the other Y displacement. The gimp use such a method (http://www.linuxtopia.org/online_books/graphics_tools/gimp_user_manual/en/plug-in-displace.html).
Or we can imagine that a channel give X displacement, and an other channel give the Y displacement.

I think this isn't very complicated to implement, but I never program an avisynth filter, I know nothing about how to do, and I even have no C development tool installed.

I think maybe you could have an animated video of the blurry blobs starting small and getting bigger, and then using some vectors from that to distort the text.

But this would be for a still image.

I'm not sure... The previous method always return something flickering, even with slow displacement video. Or perhaps I misunderstand you ?

Zarxrax
27th October 2009, 16:49
Hi,

I want to do it with 2 videos, frame by frame. One for the image source, one for the map. I don't think it's possible with photoshop or the gimp (without convert videos to images sequences), but I have to verify it.


Recent versions of photoshop let you import videos, but I don't know how that works. Converting them to an image sequence is pretty trivial, and you can set up an action to automatically apply the displacement map over all the frames. Then you can just load the resulting image sequence into AviSynth, and you have video again.