2
$\begingroup$

My current node setup is I'm sampling the float curve node based on the spline factor and storing it as an attribute. I wish to find the inverse as well, that is, the factor that maps to the current factor. Is this possible?

$\endgroup$

1 Answer 1

3
$\begingroup$

In the image below, there are three curves:

  • Left: original curve, from where I'm taking the "spline factor"
  • Middle: a replica of the float curve (x = original factor, y = float curve result), so, this is an y(x) function.
  • Right: another replica of the float curve, but now we're sampling with the y factor, making it an x(y) function.

(Notice the float curve need's to be an invertible function, meaning: can't have ups AND downs... it's all up or all down)

Results

Details explained in the nodes:

  • Captured X: So, considering the original factor as X, we capture it so we can keep it independent of changes in the curve.
  • Float curve y(x): here, we make a curve that has the exact shape of the float curve (x is the original factor, y is the float curve output). The offset is just for visualization.
  • Straight vertical: here the magic happens. We zero the X position of this curve so it becomes a strictly vertical curve (but the Y spacings are kept) - This makes the "factor" from this curve become Y exactly (because X doesn't count to length here)
  • Float curve y(x): now we redraw the float curve again (just to prove the method works), but taking the factor of the vertical curve as Y, and the original captured X as result (so you can sample the vertical curve by factor to get the original X)

Nodes

Usage:

  • Using any curve you like, store the float curve result (let's call it "attribute")
  • Make a replica of the float curve as above
  • Make the straight vertical as above
  • When you want the inverse transform, "sample curve" (the vertical curve) using the "attribute" plugged into "factor" and using the captured X plugged into "value"
$\endgroup$
14
  • $\begingroup$ This works, brilliant solution! Thanks so much. $\endgroup$ Commented Nov 14 at 2:37
  • $\begingroup$ Quick followup, how can I store the inverse value into a named attribute? Wouldn't connecting the "store named attribute" node after the sample curve just store based on its current factor and not the captured factor? $\endgroup$ Commented Nov 14 at 3:28
  • $\begingroup$ @ZeroG, that wouldn't make sense, the inverse value is the original factor itself. $\endgroup$ Commented Nov 14 at 3:48
  • $\begingroup$ But "Capture Attribute" and "Store Named Attribute" are nodes that do exactly the same thing (but one has a name). So maybe you want to replace the capture with a store? $\endgroup$ Commented Nov 14 at 3:52
  • $\begingroup$ I'm on my phone, so I didn't test and could be missing something... Ignoring the presentation purposes, i.e. if we remove join geo, first set pos sets x which is immediately nullified in next set pos without any capturing in between. So you could just set x=0 in the 1st set pos and dissolve the 2nd. Moreover, in 3rd set pos you're using factor to read the y pos inside float curve node but you're assuming it starts with 0 and ends with 1, as that's the factor range. You'd support other curves if you used y pos instead. And while calculating factor yourself would be slightly busier... $\endgroup$ Commented Nov 14 at 8:50

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.