View Full Version : Function Curve Math...
altruizine 02-21-2006, 08:37 PM is there any way to perform x & y lookups on a shake lookup node per curve? For example, can I write a function that creates a new curve based on the curve in a different node?
specifically, here's what I need to do:
I have a lookup curve that affects all colors of an input. I need to create another look up that does the exact opposite transformation. So, technically what I need to be able to do is take each curve, rotate it 45deg clockwise, invert it on the y axis, then rotate it back -45deg to create it's mirror image. I'd like to do this as a function and not simply w/ each key placed on a curve. So, that as the original lookup is adjusted, the mirrored Lookup reflects those results...
I think I could perform this if I could access the discreet x&y locations of the function curve, but as far as I can tell, I can only apply transformations to both at the same time or based on another curve..
Please let me know if there is a better solution for this...
Thanks!
-JF
|
|
pixel mixer
02-23-2006, 11:04 AM
is there any way to perform x & y lookups on a shake lookup node per curve? For example, can I write a function that creates a new curve based on the curve in a different node?
specifically, here's what I need to do:
I have a lookup curve that affects all colors of an input. I need to create another look up that does the exact opposite transformation. So, technically what I need to be able to do is take each curve, rotate it 45deg clockwise, invert it on the y axis, then rotate it back -45deg to create it's mirror image. I'd like to do this as a function and not simply w/ each key placed on a curve. So, that as the original lookup is adjusted, the mirrored Lookup reflects those results...
I think I could perform this if I could access the discreet x&y locations of the function curve, but as far as I can tell, I can only apply transformations to both at the same time or based on another curve..
-JF
actually the curves that you have in a lookup node are expression based. that means that you can create variables on a lookup node that can drive the color curve-expression. through this you can then call these variables from another node.
unfortunatelly the lookup node does not work with color expressions from another node, it just read the end point of the "curve-based-expression". the manual states that it should not be used inside a macro. even if you link paste a lookup node it will not work.
but, if you create variables on both nodes you can drive the lookup curves through them. however, it is tricky to get it work right.
pgraham
02-23-2006, 07:33 PM
You cannot evaluate a lookup node in an expression. You can fake it by copying the lookup function into a local variable and making it time-based by replacing x with time. Then you can lookup into the local variable with variable@@time
you cannot find the inverse of an arbitrary color function, because the inverse may not be a true function (there may be more than one x value for any given y value, as in the solarize function). A color lookup must generate only one output value for each input value. You cannot perform a y lookup for the same reason, there may be more than one corresponding x value.
If you want the inverse of a function, you have to do the math on paper and just enter it into the lookup expression. Shake help should tell you the math for most color functions.
pixel mixer
02-23-2006, 09:42 PM
If you want the inverse of a function, you have to do the math on paper and just enter it into the lookup expression. Shake help should tell you the math for most color functions.
lookup is different from the rest of color functions in shake through the use of curves to control colors. this way you can localize effects - very diferent for the rest of color ops where the color change is kind of global. however keep in mind that if you break the concatenation of the color nodes you will end up with a different result from what you were expecting. if you are working in float you might get away with a lot of tricks but 8 bit is not enough.
use 2 brightness nodes on a color wheel for example. first brightness value is 2 the second one is 0.5. since both concatenates they just cancell each other. if you break the concatenation using another node the result is not what you expected since the result is clamped to the bit depth by the first brightness node. however if you put a bytes node to force the tree to float things act very different. if you inverse the 2 brightness nodes you will not need to go to float since you did not clamped to colors to bit depth. if you try the same with 2 gamma ops one with 2.2 and the other with .4545 (1/2.2) the result is identical no matter bit depth and concatenation since gamma does not modify the scale just the 0-1 values. so things act differently if you go over the bit clamping.
the only way i could invert a lookup was like this:
IN > LOOKUP > INVERT > MIRRORED LOOKUP > INVERT
if you try:
IN > LOOKUP > MIRRORED LOOKUP it will not work.
Always use a plot scanline to check the color transformations you did on your image.
i think that what you're looking for might be doable for very simple curves if you overcome the curve expressions inside the loop node using local variables but for more complex curves it will be very very tricky. i frankly would try to work around this with a different compositing approach.
if i were you i would buzz support on this. they are really good!
i hope this helps you
pgraham
02-24-2006, 06:08 AM
Paying attention to bit depth is a very good point, especially when using multiple color operations. I always put a bytes at the beginning of macros, to make sure I'm always using float.
the only way i could invert a lookup was like this:
IN > LOOKUP > INVERT > MIRRORED LOOKUP > INVERT
if you try:
IN > LOOKUP > MIRRORED LOOKUP it will not work.
The impression I got from the original post was the "inverse" of a color operation, not the "invert" operation. An inverse is a function which will return an image back to its un-altered state after a color operation. It is the operation where IN>LOOKUP>INVERSE LOOKUP gives you the original image. If you plot a scanline, the "inverse" will look like the lookup scanline mirrored across the 45 degree axis. The "invert" will look like the function mirrored horizontally, across the vertical axis.
some color functions don't have an inverse function (like solarize), which is why there's no automatic way of getting the inverse of a function in Shake.
pixel mixer
02-24-2006, 09:29 AM
i meant to reverse the lookup not to invert it. sorry for the confusion.
i attached a script with 2 ways of achieving the same reverse lookup (simple curves). one is using two inverts the other one do not. the result is almost the same. i put an IsubA node to check the differences between the results but the one that uses the inverts is easier to manage. checking the results with a plot scanline viewer script will tell the difference.
pgraham
02-24-2006, 06:56 PM
i meant to reverse the lookup not to invert it. sorry for the confusion.Okay, we're talking about the same thing :) I wasn't sure. Yes, you're doing an inverse in your script. It's easy to do it with a linear function, just swap the coordinates at each key point (0.5@0.8 becomes 0.8@0.5). However, if you make a function that goes up and then down, then you can't make a complete inverse lookup.
altruizine
02-24-2006, 09:42 PM
Reversing my x & y plot points is eventually what we settled on here. For the nodes we'll be reversing, it's going to be all s shaped correction curves, nothing drastic or that would invert illegally.
w/ enough points on the curve the reversal can be nearly perfect. I've implemented the x/y reversing in an applescript. You copy your lookup node, choose the applescript from the system scripting menu, the script grabs the node info from the clipboard, performs the reversal and places that information back to the clipboard. You can then simply hit command V in shake and get the reversed node.
I can post it up here if anyone else wants it after I clean up the code a bit.
Thanks for everybody's donated brain power on this one. For me it was one of those problems that seemed solvable w/ a function at first, but there are just too many issues...
-JF
pgraham
02-27-2006, 11:44 PM
yeah I'd like to see that script.
altruizine
03-06-2006, 09:20 PM
Here you go, it should be attached to this reply - instructions are in the comments. It's a bit of a hack in how it's done, but it does work...
After you've got your Hue Curves set pretty well, you should shift-click in some more control points in order to get as much accuracy out of the reversal as possible. Also, avoid illegal operations, the script doesn't check for those and I'm not sure what would happen.
-JF
CGTalk Moderation
03-06-2006, 09:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.