Welcome, Guest
Username Password: Remember me

TOPIC: Looking for a tool similar to the liquify tool from photoshop

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 6 days ago #226929

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 13109
  • 1 week, 6 days ago
Not as such, but you can plot the motion using keyframes. Check out the effects tutorials in the tutorials section of this website. There is a section there on working with effect keyframes. The tutorials were prepared using the flexible user interface, but the same techniques apply to the fixed interface.

By the way, schrauber, I was wrong about what the Photoshop liquify effect does. Here's what it really does. Note that it doesn't do anything special when the distortion affects the frame edges. It just shows the current default background colour, which in this case was white.

This image is hidden for guests. Please log in or register to see it.
Last Edit: 1 week, 6 days ago by jwrl.

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 6 days ago #226934

  • RWAV
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 6868
  • 1 week, 6 days ago
@schrauber if you haven't already done so - perhaps take a look at the Fusion GridWarp tool. Attached is an extract from a Fusion Tool manual and there are of course YouTube videos


This attachment is hidden for guests. Please log in or register to see it.
BETA System
Microsoft Windows 7 Professional 64BIT
HP Z800 Workstation

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 6 days ago #226936

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 13109
  • 1 week, 6 days ago
The AE warp tool is similar in operation. Unfortunately in Lightworks we can't do grid overlays to set up effects. It's one of the reasons that I didn't immediately rush forward with a solution when the question was first raised.

However because he was unencumbered with the way that others had done it, schrauber has come up with a very simple and elegant way to achieve his result. Instead of using grid displacement he has used a trigonometric offset technique. His method has the advantage of only requiring two reference points to create the warp. It's very hard to distinguish any difference in the result of the two techniques.
Last Edit: 1 week, 6 days ago by jwrl.

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 6 days ago #226937

  • RWAV
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 6868
  • 1 week, 6 days ago
And if it's necessary one can set up Fusion as a LW assistant Application
BETA System
Microsoft Windows 7 Professional 64BIT
HP Z800 Workstation

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 5 days ago #226982

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4620
  • 1 week, 5 days ago
Thanks everyone for your tests and tips.

Here is the second prototype:
This attachment is hidden for guests. Please log in or register to see it.


This image is hidden for guests. Please log in or register to see it.


The technical changes mainly affect the Area slider:

schrauber wrote:
In another test version I had added a slider that should reduce the distortion to the outer area without reducing the distortion near the effect center. In other words, two area sliders, which should control the spatial distribution of the distortion more precisely...

I did without the additional slider. I set a default value in the code for it, which places an S-curve at the edges of the area. This is to make sure that the area has a real limit where the distortion is no longer present (as long as the area slider is not set very high).
In the previous one, even with small area settings, small distortions could still be seen at a long distance from the effect center.

The area slider can be set up to 300%, but above about 100% more the whole image will be shifted in the distortion direction, depending on the other settings.

I have also added a second compensation of the distortion intensity so that the optical distortion intensity remains roughly constant when the area slider is moved (within certain limits). I think this might make it easier to keyframe the area setting.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
Last Edit: 1 week, 5 days ago by schrauber.

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 5 days ago #226984

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4620
  • 1 week, 5 days ago
Oh, now I see in both prototypes, in the mode for Transparenz and black background, that the edge softness is active even if the frame edges have not been moved (the background shimmers through a bit).
Then I seem to have oversimplified the softness calculation when I took this code from my quad screen effect.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
Last Edit: 1 week, 5 days ago by schrauber.

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 5 days ago #226985

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 13109
  • 1 week, 5 days ago
I note that you've picked up on the fact that distance() only returns a float regardless of the values in the argument. For that reason it's also unnecessary to work with float2 values in cos(). You could more easily do this:

float2 distance2 = ((1.0 - cos (distance1 * PI)) * 0.5).xx

That would be a simpler mathematical operation, but yield exactly the same result. Similar optimizations throughout may help you to simplify the code even more.

But I suspect that at this stage of development you haven't looked at code clean up, so I'll shut up.


[EDIT] I hadn't noticed that edge artefact when no distortion is applied. How important do you think that it is? Given that this effect is only likely to be used for reasonably extreme distortions, perhaps it's an acceptable trade off?

Also, I like the fact that you now show area and strength as percentage values. That's nice.
Last Edit: 1 week, 5 days ago by jwrl.

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 4 days ago #227064

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4620
  • 1 week, 4 days ago
Thanks for the tip.

jwrl wrote:
.. edge artefact when no distortion is applied. How important do you think that it is? Given that this effect is only likely to be used for reasonably extreme distortions, perhaps it's an acceptable trade off?
I myself need unchanged edges. I want to use the effect for fast distortions within the frame (Show action scenes exaggerated).

I think I solved it by calculating the edge distances of the output texels in addition to the edge distances of the sampler positions.
On this occasion I deleted a line of code from the function, whose calculation seemed to be irrelevant.

You will surely be surprised about the three small macros named "D", "L1", and "P" in the code. For example, macro D(divided,divisor) only performs a safe division. What always bothered me was that my formula often contained "max ( 1e-9 ...", which distracted my eyes from the central functionality of the code. However, I also have to get used to this unusual macro look.

Here the third prototype:
This attachment is hidden for guests. Please log in or register to see it.


I have changed the characteristic curve of the "Strength" slider so that it is now easier to set very strong distortions. You can even tear a distortion hole anywhere in the frame, which can be seen through in transparent mode. In case of small-scale strong distortions with narrow edge radii, the edge interpolation becomes inaccurate.

In this prototype I added a slider for the edge softness for experimentation, because it is only a readjustment of the already included interpolation. If it is not needed in practice, we can remove it again.

This image is hidden for guests. Please log in or register to see it.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 4 days ago #227066

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 13109
  • 1 week, 4 days ago
schrauber wrote:
You will surely be surprised about the three small macros named "D", "L1", and "P" in the code.

I'm not surprised at all - as you know, this is an area where we differ. I don't like macros in this sort of role, because they can actually obscure what is taking place. At the expense of apparently simplifying the code they can actually lead to greater program complexity and subsequent debug confusion. It's all too easy to regard a macro as a value rather than an expression.

In another user's code here when I had to sort out some cross platform issues it ended being simpler to just rewrite the effect because it was so obscured by over-use of macros. As I recall, they had even nested maths operations that cancelled each other out when the macros were expanded. Multiplying then dividing by exactly the same value achieves little!

An example from your own code: you have the following code fragment.

   float2 area = P( AREA - distance2 * AREA2);

That expands to:

   float2 area = max (0.0, (Area.xx / 2.0.xx) - (distance2 * 0.5));

As it stands, the first argument in max() is a float, the second is a float2. That will work on windows, but I don't think that it will work on Linux or OS-X. According to the Cg reference manual, the following are the legal float arguments and return values for that function.

   float max (float a, float b);
   float1 max (float1 a, float1 b);
   float2 max (float2 a, float2 b);
   float3 max (float3 a, float3 b);
   float4 max (float4 a, float4 b);

Rewriting that (and at the same time removing a redundant division) would give this, which doesn't suffer from the illegal construct that was hidden by the macro.

   float2 area = max (0.0.xx, Area.xx - distance2) * 0.5;

That is the clearest demonstration that I can give of the reason that I'm not a huge fan of macros in programming.
Last Edit: 1 week, 4 days ago by jwrl.

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 4 days ago #227074

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 13109
  • 1 week, 4 days ago
I've had a chance to play with version 3, and I like the softness control. There's a weird thing that happens when you adjust it though: the area outside the edge of the frame inverts when in transparent mode.

This image is hidden for guests. Please log in or register to see it.

This image is hidden for guests. Please log in or register to see it.

That can be corrected if you do this in fn_tex2D() (line 154).

   retval.a *= saturate (min (soft.x, soft.y));

Here's the result of the fix with exactly the same liquify and blend settings.

This image is hidden for guests. Please log in or register to see it.

I also wonder though whether strength might not be too extreme now. The useful range of the adjustment is pretty much all at the bottom end.
Last Edit: 1 week, 4 days ago by jwrl.

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 4 days ago #227085

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4620
  • 1 week, 4 days ago
jwrl wrote:
..As it stands, the first argument in max() is a float, the second is a float2. That will work on windows, but I don't think that it will work on Linux or OS-X.

Thank you. I thought this restriction did not concern numbers, but now I remember that I had such compatibility problems with numbers in a function in the quad screen effect.

jwrl wrote:
.. the area outside the edge of the frame inverts when in transparent mode..

Oh, I had tested with 8-bit GPU precision. Now when I change to float GPU setting, I see it too.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 1 day ago #227323

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4620
  • 1 week, 1 day ago
Here is the fourth prototype:

This attachment is hidden for guests. Please log in or register to see it.


jwrl wrote:
I don't like macros in this sort of role, because they can actually obscure what is taking place.


I tried something new:
I automatically transferred the remaining macros in my code back into the shader and function code using an online compiler. This of course also transferred simple number definitions into the shader etc. Comments were also removed.

I left the redundant division in the code for me to be able to see what the parameter AREA2 was, what its purpose is and how I can change it in case of potential later changes or further use of the code.The value 0.5 was chosen a bit randomly as average value for testing with a slider in a large tolerance range.
The GPU load is probably slightly higher (if the compiler in Lightworks doesn't do any optimizations?), but the difference disappears within my measurement tolerances.

If you like, you can of course make optimizations for an official release in the library.

I have attached my original source code disabled in the effect code.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)

Re: Looking for a tool similar to the liquify tool from photoshop 1 week, 1 day ago #227329

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 13109
  • 1 week, 1 day ago
schrauber wrote:
If you like, you can of course make optimizations for an official release in the library.

I'll have a look, but unless you've radically changed things I don't think that there would be much to do. I'll post it once I've done some screen grabs and written some text explaining what it does.

Re: Looking for a tool similar to the liquify tool from photoshop 1 week ago #227382

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 13109
  • 1 week ago
Well, I took you at your word, but I got carried away. I started out just intending to simplify some of the usage of float2 values where floats would do just as well. That then led me to looking at some of the mathematics which could be simplified as a result, then that led me further, and further and further.

So attached is what I now have, but I will not post it in the library unless you approve it. When I started it was not my intention to go as far as I did, and I'm embarrassed by what I have done.

Liquify.zip.
Last Edit: 1 week ago by jwrl.

Re: Looking for a tool similar to the liquify tool from photoshop 1 week ago #227393

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4620
  • 1 week ago
I agree.

I had already assumed that I had made far too many aspect ratio adjustments.

My separate "mirror" shader should minimally increase performance in this mode, but your solution makes code maintenance easier and maybe compilation faster.

Just out of interest in what these optimizations do, I made some test exports with different numbers of duplicated effects, export settings, and export order.
With 5 effects and QFHD my Intel GPU is not permanently fully utilized, so the CPU load of the export encoding is still too high.
With 20 effects, the GPU load clearly outweighs.
However, a setup with 20 identical effects serially in the routing is unusual, which might be a reason for some unexpected time relations:
Attachments:
  • Attachment This image is hidden for guests. Please log in or register to see it.
  • Attachment This image is hidden for guests. Please log in or register to see it.
  • Attachment This image is hidden for guests. Please log in or register to see it.
  • Attachment This image is hidden for guests. Please log in or register to see it.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
Last Edit: 1 week ago by schrauber.
Time to create page: 0.79 seconds
Scroll To Top