YOUR ACCOUNT

Login or Register to post new topics or replies
David Roberson
Artist
Posts: 404
Filters: 36
A project I was working on recently could have benefitted from this kind of Curve Ops component. It seems like a practical thing to have, and there are lots of times I found myself wanting some way to do a linear interpolation between two curves. I suspect you could even have the interpolation controlled by a map input. I swear, there's something in the back of my mind saying I've seen someone do something like this with existing components, but I can't remember what it was. If I had a clue about curve scripting, I'd try to do this one myself. If someone thinks of a way to do it, I'd love to hear about it!
  Details E-Mail
emme
Posts: 718
Filters: 8
The Blend curve op does a linear interpolation. In a curve script, you can use this:

(1 - factor) * curve1 + factor * curve2

You can use a map input for the factor if needed. The Blend op already has a map input.

curve_lerp_v001.ffxml
  Details E-Mail
David Roberson
Artist
Posts: 404
Filters: 36
Oh. Don't know how I missed it! Thanks, emme!

I had the idea that the Blend Curve Ops was locked in a left-to-right sort of transition. I guess you never stop learning the basics with FF. Thanks for the examples, and someday I'll bug you with my other curve scripting questions. I have not had any luck finding examples to study, and there isn't anything in the scripting APIs for curve scripts. I'd be happy just knowing how to create a Curve Ops style script that controls Start, End, Minimum and Maximum. It'd be handy to pair up with Bezier curves.
  Details E-Mail
emme
Posts: 718
Filters: 8
For me, the x,y and t coordinates made curve scripts confusing at first. Unless you need map inputs for the script, you can ignore the x/y coordinates and simply think of t as the x coordinate. For each position of t you want to return the value (or the height) of the curve. That's pretty much it.

Here's my attempt at the start/end/min/max curve op script.

curve_control_v001.ffxml
  Details E-Mail
David Roberson
Artist
Posts: 404
Filters: 36
Nice!

So, the variable c that's being returned at the end is the modification of the sample curve variable t? Is that the only value you can return for, or is there also the option of returning values for x and y?
  Details E-Mail
David Roberson
Artist
Posts: 404
Filters: 36
I like the way you corrected for the inversion of the Start and End, but it did make me wonder if you also had the option of reversing the curve. There's a Curve Ops for that, so it's really just curiosity that has me wondering how I'd handle that. My mind doesn't want to wrap itself around it at the moment, sadly. smile:p
  Details E-Mail
emme
Posts: 718
Filters: 8
Quote
David Roberson wrote:
Is that the only value you can return for, or is there also the option of returning values for x and y?


A curve is one-dimensional - in the sense that it is described by only one parameter - so there's only one value to return. That being said, the x/y sample coordinates can be used to return different curve values at different points on the image plane.

So basically the x/y refer to the image coordinates, while t refers to the curve coordinate.

Quote
David Roberson wrote:
it did make me wonder if you also had the option of reversing the curve


Sure, to reverse the curve, using 1-t (inverting the curve x-axis) will do the trick.
  Details E-Mail
David Roberson
Artist
Posts: 404
Filters: 36
Quote
A curve is one-dimensional - in the sense that it is described by only one parameter - so there's only one value to return. That being said, the x/y sample coordinates can be used to return different curve values at different points on the image plane.


Okay. That makes sense. What the sample coordinates do, in the get_sample_grayscale() is add to the curve complexity, but it's just a single value as far as the execution of the script is concerned.

On reversing the curve, I can think of a dozen places, now, where I've seen that reversal in use, yet it did not occur to me yesterday. I swear, it's often the simplest things that escape me!

Thanks!
  Details E-Mail
James
James
Posts: 676
Filters: 46
Here is a basic blend/lerp as a curve script:

Code
function prepare()
   balance = get_slider_input(PERCENTAGE)
end;

function get_sample(x, y, t)

   a = get_sample_curve(x, y, t, SOURCE_A)
   b = get_sample_curve(x, y, t, SOURCE_B)

   v = b * balance + a * (1 - balance)

   return v
end;
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,711 Registered Users
+18 new in 30 days!

153,531 Posts
+36 new in 30 days!

15,347 Topics
+72 new in year!

Create an Account

Online Users Last minute:

15 unregistered users.