A request and question to the script writer
I am ( and for sure many others too) missing desperately the RGB curve node in Cycles shader . No I try a huge workaround, because I need this node really to have the result I want.
I thought some mathematics could replace more or less this node till we have it in real in Poser. The bad thing, with this workaround you have to put manually the value inside the math node composition , which could be very time consuming.
The idea was to replace the curve by three line , which means two point on a plane 0/1 by 0/1.
Would it be possible to make a script of this when I give you the mathematical formula and a detailed explanation of the formula?I upload here as screen shot a part of the formula so you can see what I am talking about.
Rather than the 'if' function you could use the maximum of your three expressions. From the looks of it these functions could be approximated by simple linear expressions defined over the whole input range.
This would bring it well within the grasp of the material room.
@Ladonna before I leap into the fray, it would be really helpful to understand what the parametric curves represent (no doubt @bagginsbill could shed light here). Is this some kind of RGB separated gamma correction? What is the source of the formulas, so I can do more research?
Is the RGB curve node something which is available in Blender cycles that has not yet made its way into SuperFly's implementation of cycles? Rather than a Firefly node, which would still be available for use in SuperFly?
@fverbaas The two other lines are for now just a test for the factor. ( Should keep the diagram clean) It was just a test to understand how the factor works.
@anomalaus No, this is not a Gamma correction,it is a RGB separate .
Formulas are simple line equations (those with power is an attempt to get the factor of correction which need still a bit work) just forget the colored curves the job is done by the 3 lines (for factor = 1)
But it is still in work and not finish. As soon I got the formula full done, I upload it . :)
Cycles in Blender has it already inside. https://docs.blender.org/manual/en/dev/compositing/types/color/rgb_curves.html
It can be more or less precise done with FF ColorRamp. Or stitching of the necessary number or the ColorRamps. (First for 0<x<0.1, second for 0.1<x<0.2 and so on... ) At least I think so.
@phdubrov In principle yes, but the discretization of the curve would give some odd results . You would not have a smoth curve, you would have more like if a stair. It will be not smooth.
@Ladonna And not to forget, Posers FF ColorRamp has only 4 value. The Blender Cycles has the wheel which in this case could replace the RGB curve, but not the FF colorRamp.
@Ladonna that's why I write about stitching ColorRamps.
And why steps? Saw - maybe, but not steps, as far as I understand, FF ColorRamp is linear, not constant.
@phdubrov I try already with plug in , or connect it with a gradient. But there was no proper control about the values. There you got a saw. But how do you get a slope on your saw? There is no continuity . What you get as result is one extreme to the next one.
So, I need a bit for some time for detailed explanation ( Language issue)
As the RGB Curve node from Cycle is missing in Superfly, I tought it is possible to replace it by some work around.
The task appear to be more complex than I expect initially.
As I had the need for a shader, my assumption was simple :
1) The curve begin at (0,0) and end at (1,1) so I assum two fix points
2) Each curve can be approximated by some number of lines (it calls discretisation) in my case three is enopugh
3) So the problem is simple, a plane (x,y) where x is the input, y the output
four points A (fixed at 0,0) C1, C2 and B (fixed at 1,1) so the curve is splitted in three lines
(See the approximation error on the diagram for sample pts M1 and M2)
4) As the RGB curve node uses color input, and the maths node do not, this must be process trough RGB separate and RGB combine nodes
each channel is treated the same way (It is also possible to process each channel separately like the RGB Curve node do as well)
In detail of the approximative RGB curve treatment 1) The situation is the following : Channel by channel use node "Separate RGB" a) On channel R, from 0 to C1 (input, x values) apply the correction given by the line [a] - Filter the input (channel R value from the color input) by a math node "less than" C1 x coordinate, the result is 1 (white) all over the gray value is less than C1 and 0 (black) anywhere else. - Multiply the Channel R by this filter (all values between 0 and C1) anywhere else 0 (black) - Apply the line function [a] b) From C1 to C2 (input, x values) apply the correction given by the line [b] - Filter the input channel R by a math node "less than" C2 x coordinate ... - Substract the first filter done in a) to remove the values which are less than C1 (use clamp to keep values within range 0,1) - Multiply the channel R by this filter - Apply the line function [b] - Filter again the result by multiply to remove the values under 0 if any c) From C2 to 1 (input, x values) apply the correction given by the line [c] - Filter the input channel R by math node "greater than" C2 x coordinate, the result is 1 (white) all over the gray value is greater than C2 and 0 (black) anywhere else. (It is supposed to be the invert value from the filter use at first in b)) - Multiply the channel R by this filter - Apply the line function [c] - Filter again by multiplying to remove negative values if any Finally add these three results by two maths nodes "add" 2) Use the same procedure for Channel G and B 3) Recombine the channels by using a "Combine RGB" node This work not that bad as long I compare it to the original "RGB curve" node in Blender and that node use as factor 1. But it becomes very tricky while changing the factor. I'm still trying to figure out what is the mathematic under the so called "fac" parameter. From what I could see, this factor morph or stretch or squeeze ... the curve in some way. It is not a gamma correction, nor a brightness, contrast, saturation, value ... or whatever I could used from existing color nodes. While experimenting, it seems that a power function is the closest results I could get for small values but it diverge widely by larger values. My idea is that original values C1 and C2 y coordinates are spreading away from their original position relatively to a let's say neutral line (y=x) Here I am for now.
@Ladonna Sorry for this messy post, looks like I mess up with my copy and paste from the notepad.
I have been doing arbitrary piecewise-linear interpolations as Poser nodes since 2006. I published the tool that makes them (and a billion other things) going from formula to Poser nodes. Most of you know what it is -- matmatic.
The matmatic method that does what you're trying to do above is called Interpolate.
It has been there since the very first release and it can also do various useful curves between the control points, not just straight lines.
I admit it isn't visual but you could make a visual front-end for it and use that to get the values to pass to the Interpolate method, which would then generate nodes for you.
Some stuff from the matmatic documentation:
Using matmatic, I created a node setup that does the exact formula that Ladonna asks for above.
On the right are nodes for the three inputs (c1, c2, and a place to plug your input). The green box is the 3-piece linear interpolation that passes through the points Ladonna has in the graph.
The script I wrote to create this node setup is this:
x = PM(0, "Input") c1 = PM(.4, "c1") c2 = PM(.6, "c2") f = Interpolate(x, [0, 'd', .25, c1, 'd', .5, c2, 1])
@Ladonna thanks, I see now this is cubic spline interpolation, which you'd like to approximate with discrete linear segments. More segments giving a better approximation and less obvious discontinuities.
The last time I dealt with cubic splines was prior to Poser supporting the UnaffectedValue() parameter method in Python and my attempt to interpolate valueOpKey outputs. At the time I had to resort to importing the SciPy module and upgrading the Poser supplied NumPy to a version which was compatible with the available SciPy. Not for the faint of heart! In this case, though, I've never tried to integrate Python callbacks with material room nodes, and I'm utterly certain it would be way too slow to incorporate into render pipelines, so that's out.
I assume you're working through something similar to Cubic Spline Interpolation for your formulas.
Here's a ridiculously simplified node structure, where each colour has only one power node representing each colour separation's response curve. If the exponents are unitary (1) you get the same output as input, so it appears what you are developing would replace each of the single power nodes for red, green and blue separations, I think.
Ha ha, I see @bagginsbill has stepped in to save me embarrassing myself, while I was experimenting and composing this reply, but I'm going to post this anyway, to teach myself a lesson, ha ha!
Please ignore my drivel and pay attention to the master, @bagginsbill . :-)
Thank you so much @bagginsbill and @anomalaus . You are awesome.
Now this gives me some food for thought and place for experiments.
@bagginsbill , is this node setup already in MatMatic? Or did I have to put this values inside? I have to admit that since a while I did not use Matmatic. In Poser 11 I thought I does not work with Cycles properly. Will now install it on Poser 11 and experiment with it.
@anomalaus , looks good to me you simplified node setup. Will test it now because sometimes simple does the job too. :)
Anomalous showed how to separate RGB, apply functions to each channel, and then recombine them. This does not demonstrate how to get those functions to follow an arbitrary series of control points, and while a useful technique in its own right, is not the problem given in the original post.
The problem given in the original post is this:
SuperFly is missing a Cycles node - this node lets you create arbitrary function approximations by assembling control points and interpolating between those points.
So while "sometimes simple does the job too" in this case it's simply not applicable.
"is this node setup already in MatMatic?"
I'm unclear what you mean. As I said, the Interpolate function is already in matmatic and has been for 11 years.
I USED the Interpolate method to make "this node setup". Or any of an infinite number of other node setups. All node setups in the universe are "already in matmatic".
The script I wrote to create this node setup is this:
x = PM(0, "Input")
c1 = PM(.4, "c1")
c2 = PM(.6, "c2")
f = Interpolate(x, [0, 'd', .25, c1, 'd', .5, c2, 1])