color expression node

102 views
Skip to first unread message

mr.doct...@gmail.com

unread,
Feb 23, 2015, 5:46:53 PM2/23/15
to Natro...@googlegroups.com
i request a color expression node to aid in the creation of gizmo and color tools to expand the community

Alessandro Dalla Fontana

unread,
Feb 25, 2015, 11:15:25 AM2/25/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
+1
Message has been deleted

Gaia

unread,
Feb 26, 2015, 5:40:44 AM2/26/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
+1000 ^^

Alessandro Dalla Fontana

unread,
Mar 16, 2015, 3:18:37 AM3/16/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
In the last snapshot there is a SeExpr for to do it now.

Nicholas Carroll

unread,
Mar 17, 2015, 8:32:44 AM3/17/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
OK here is a use case for a basic expression: 
Let's say I want to make a Day to Night filter. I will have a node with a slider constant to control the blue and a constant to control how much red and green will be reduced in proportion to blue. Pretty crude but definitely better shooting with blue gel. So the expression would be like this:

nightness = Constant1.color
blueness = Constant2.color

outputBlue = inputBlue * nightness
outputRed = inputRed * outputBlue / blueness
outputGreen = inputGreen * outputGreen / blueness

How do I do that with SeExpr?

Nicholas Carroll

unread,
Mar 17, 2015, 8:37:20 AM3/17/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
its going to need luminance in there as well.

Alessandro Dalla Fontana

unread,
Mar 17, 2015, 3:45:52 PM3/17/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
For separe and combine just use a vector array [0,1,2,3]:

colorInput = getPixel(1, frame, x, y);


R=colorInput[0];

G=colorInput[1];

B=colorInput[2];

A=colorInput[3];


colorOutput=[R,G,B,A];

colorOutput


...but seem that you want multiply a float value per vector color for obtain a float value, if it's so seem little strange.

Alessandro Dalla Fontana

unread,
Mar 17, 2015, 7:03:11 PM3/17/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
Humm, I did an error you can not use also the alpha in vector color I think is only 3 channel RGB [0,1,2]

Nicholas Carroll

unread,
Mar 18, 2015, 1:27:38 AM3/18/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
Thanks Alessandro,
That's a help. I see that alpha is another variable. I will try it out.

I just put that use case there to show whatever basic case. Do you now how to reference the values of parameters in other nodes?

Nicholas Carroll

unread,
Mar 18, 2015, 2:26:42 AM3/18/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
OK well SeExpr is not the type of expression node to use for basic manipulation of channel values and across channels. It's a whole new language to learn and while it looks nice and powerful and so for basic expressions like my use case above it doesn't make much sense. Natron uses python expressions for parameters in all the other nodes and what is needed is just a way to do the kind of use case I described above.

I did have a crack at SeExpr and here what I did is here below:

r = Cs [0];

g = Cs [1];

b = Cs [2];

a = As;


output=[r,g,b];

output

Alessandro Dalla Fontana

unread,
Mar 18, 2015, 2:31:35 AM3/18/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
Do you now how to reference the values of parameters in other nodes?

I think is only possible through the expressions, linked to the 10 position/10 scalar/10 color
Message has been deleted

Nicholas Carroll

unread,
Mar 18, 2015, 5:46:11 AM3/18/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
I wanted to raise an ER for a python expression node then I realised that it is not going to work. So I suppose it might be best instead to focus on making the SeExpr node easy to use for basic level users without getting in the way of advanced users. 

So I am trying now to use those parameters like you said. I see now: the way to use other node parameter values in your expression is enable the parameter (scale/position/colour) and then use that in the script.

Just need to figure out now, how to set alpha in the output.

Alexandre

unread,
Mar 18, 2015, 5:51:28 AM3/18/15
to Nicholas Carroll, Natro...@googlegroups.com, mr.doct...@gmail.com
SeExpr can only output 3-dimensional vectors (like a shader would do in a render engine), hence cannot output RGBA data but only RGB.
What you can do though, is use a separate SeExpr for your alpha and in output return the alpha, and then shuffle it back in your comp below, e.g:
 
/ \
 Shuffle(output RGB only)   Shuffle(output alpha only)
          | |
SeExpr (in —> RGB, out—> RGB)   SeExpr(int —> alpha, out—> alpha)
\ /
/
\A /B
Shuffle (A.r,A,g,A.b,B.a)

--
You received this message because you are subscribed to the Google Groups "Natron" group.
To unsubscribe from this group and stop receiving emails from it, send an email to Natron-VFX+...@googlegroups.com.
To post to this group, send email to Natro...@googlegroups.com.
Visit this group at http://groups.google.com/group/Natron-VFX.
To view this discussion on the web visit https://groups.google.com/d/msgid/Natron-VFX/e73ef3d4-be37-4a80-8dbb-c0e5713bb58e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicholas Carroll

unread,
Mar 18, 2015, 6:05:49 AM3/18/15
to Natro...@googlegroups.com, nicholas.mat...@gmail.com, mr.doct...@gmail.com
thanks Mr Kepzie. I can see that there are real constraints 

The use case I put in above I did as follows:

nightness = x1;

blueness = x2;

inputRed = Cs [0];

inputBlue = Cs [1];

inputGreen = Cs [2];


outputBlue = inputBlue * nightness;

outputRed = inputRed * outputBlue / blueness;

outputGreen = inputGreen * outputBlue / blueness;


output = [outputRed,outputBlue,outputGreen];

output


So its usable, but a bit awkward. In the current build it seems to struggle to render.

Alexandre

unread,
Mar 18, 2015, 6:08:59 AM3/18/15
to Nicholas Carroll, Natro...@googlegroups.com, mr.doct...@gmail.com
Your expression could be rewritten like this:

b = Cs[2] * x1;
bDiv = b / x2;
[Cs[0] * bDiv, Cs[1] * bDiv, b]

Nicholas Carroll

unread,
Mar 18, 2015, 6:19:04 AM3/18/15
to Natro...@googlegroups.com, nicholas.mat...@gmail.com, mr.doct...@gmail.com
If I was a maths wizard it could! :-D
well I remade it and its rendering just fine now.
Thanks for your great work. 

Rc Spam

unread,
Mar 22, 2015, 1:33:13 PM3/22/15
to Natro...@googlegroups.com, mr.doct...@gmail.com
What type of expression node to use for basic manipulation of channel values and across channels ?
Thanks

Alexandre

unread,
Mar 22, 2015, 2:53:23 PM3/22/15
to Rc Spam, Natro...@googlegroups.com, mr.doct...@gmail.com
Read the documentation in the help button or on the SeExpr website, it should be enough to write simple expressions.

-- 
You received this message because you are subscribed to the Google Groups "Natron" group.
To unsubscribe from this group and stop receiving emails from it, send an email to Natron-VFX+...@googlegroups.com.
To post to this group, send email to Natro...@googlegroups.com.
Visit this group at http://groups.google.com/group/Natron-VFX.

Rc Spam

unread,
Mar 22, 2015, 3:24:17 PM3/22/15
to Natro...@googlegroups.com, rcs...@gmail.com, mr.doct...@gmail.com
I don't understand how to manipulate the output alpha-channel, because apparently "color Output" take only 3 coordinates ?

Alexandre

unread,
Mar 22, 2015, 3:29:50 PM3/22/15
to Rc Spam, Natro...@googlegroups.com, mr.doct...@gmail.com
You have to do it in a separate expression and use a shuffle node

Rc Spam

unread,
Mar 22, 2015, 6:09:13 PM3/22/15
to Natro...@googlegroups.com, rcs...@gmail.com, mr.doct...@gmail.com
I was trying to reproduce a node like ChannelMerge in Nuke to manipulate channels with math operations.

So no node like this one is planned ?

Alessandro Dalla Fontana

unread,
Mar 23, 2015, 5:00:38 AM3/23/15
to Natro...@googlegroups.com, rcs...@gmail.com, mr.doct...@gmail.com
#Technicolor Three Strips

R = Cs[0] - (Cs[1]/2.0) + (Cs[2]/2.0);
G = Cs[1] - (Cs[0]/2.0) + (Cs[2]/2.0);
B = Cs[2] - (Cs[0]/2.0) + (Cs[1]/2.0);

output=[R,G,B];

output

If you mean something like this, just connet a SeExpr: Cs is a default first input, you can separe channel in Cs[0,1,2].

Rc Spam

unread,
Mar 23, 2015, 7:44:44 AM3/23/15
to Natro...@googlegroups.com, rcs...@gmail.com, mr.doct...@gmail.com

Yes, but what about Alpha channel because Cs are limited to RGB.
I want to make something like 'union' (A+B+AB) or other operations  only on the alpha channels from the input A and B alpha channel source.

Rc Spam

unread,
Mar 23, 2015, 7:47:11 AM3/23/15
to Natro...@googlegroups.com
Sorry union = a+b-ab

Alessandro Dalla Fontana

unread,
Mar 23, 2015, 8:47:35 AM3/23/15
to Natro...@googlegroups.com

the problem is the output that have max 3 channel, in input you can have alpha, the default one is As and is the alpha of the first footage connected,
in my simple test I have multiply Color x alpha:

color=Cs*As;
color

If you want "a" like alpha just write  a=As;
In your expression I don't know what is "ab".

Rc Spam

unread,
Mar 23, 2015, 12:31:24 PM3/23/15
to Natro...@googlegroups.com
If i want work on alpha to have a correct alpha channel output for this image, i need to merge the red canal in a screen merge node.(4 node in Natron, 1 in Nuke)
'Screen' in Merge Node corresponds to operation :a+b-ab and it is that i want.


This image has a non acceptable alpha for me

here is its alpha channel

So i need 3 shuffles nodes + 1 merge node (screen)

So i don't know how to simplify this 4 nodes to one.

This the reason i thought that the SeExpr could help me to simplify the nodegraph.

That's why a node like the Nuke ShuffleMerge Node might be a cool enhancement, or a math operations node or something like that, might do the trick as well.

I don't know to do that with the SeExpr Node... :(


Alessandro Dalla Fontana

unread,
Mar 23, 2015, 1:11:28 PM3/23/15
to Natro...@googlegroups.com
screen is: 1-(1-A)*(1-B):  http://en.wikipedia.org/wiki/Blend_modes#Screen

# for merge screen 2 input A-B
screen=1-(1-Cs)*(1-Cs2);
screen


# for merge screen 2 channel R-G
screen=1-(1-Cs[0])*(1-Cs[1]);
screen

Alexandre

unread,
Mar 23, 2015, 2:03:16 PM3/23/15
to Alessandro Dalla Fontana, Natro...@googlegroups.com
I’ve added the possibility to the SeExpr node to output RGBA or Alpha only.
When outputting alpha/RGBA a separate script has to be used.
The default is RGB only

-- 
You received this message because you are subscribed to the Google Groups "Natron" group.
To unsubscribe from this group and stop receiving emails from it, send an email to Natron-VFX+...@googlegroups.com.
To post to this group, send email to Natro...@googlegroups.com.
Visit this group at http://groups.google.com/group/Natron-VFX.

Alessandro Dalla Fontana

unread,
Mar 23, 2015, 2:37:05 PM3/23/15
to Natro...@googlegroups.com, alessandro....@gmail.com
well done!

anyway Rc Spam (I saw your screenshot only now):

connect your footage to SeExpr, copy and paste this:

screen=1-(1-Cs[0])*(1-Cs[0]);#screen merge R channel

screen


and use 1 channel of output for mask on the merge node for blend the smoke with background.

Rc Spam

unread,
Mar 23, 2015, 3:37:28 PM3/23/15
to Natro...@googlegroups.com, alessandro....@gmail.com
@MrKepzie, Thank you ;)

@Alessandro Dalla Fontana,
It is not the expected results:

I have replace your function with

screen=(2*Cs[0])-(Cs[0]^2);

but same result.

I will wait for last snapshot

Thanx Alessandro

Rc Spam

unread,
Mar 23, 2015, 3:40:33 PM3/23/15
to Natro...@googlegroups.com, alessandro....@gmail.com
I'm not sure last snapshot is the good one, so i ll wait next snapshot :)

Alessandro Dalla Fontana

unread,
Mar 23, 2015, 4:20:07 PM3/23/15
to Natro...@googlegroups.com, alessandro....@gmail.com

But are you simply looking for this one? Or is more complex the result that you want?

Alessandro Dalla Fontana

unread,
Mar 23, 2015, 4:48:13 PM3/23/15
to Natro...@googlegroups.com, alessandro....@gmail.com

and this one is an example to do the same with 1 node SeExpr. With x1 is possible control the alpha gamma:

R_alpha=1-(1-Cs[0])*(1-Cs[0]); #screen merge R channel of input 1

color= Cs+Cs2*gamma(invert(R_alpha), x1); #merge over 2 input - controll gamma with x1

color

Frédéric Devernay

unread,
Mar 24, 2015, 2:31:10 AM3/24/15
to Alessandro Dalla Fontana, Natro...@googlegroups.com
Hi,

we will probably add another expression for the Alpha channel only. The default value of this expression will be "As", and it will not be evaluated if it's unchanged, thus there will be no performance hit.

fred

--
You received this message because you are subscribed to the Google Groups "Natron" group.
To unsubscribe from this group and stop receiving emails from it, send an email to Natron-VFX+...@googlegroups.com.
To post to this group, send email to Natro...@googlegroups.com.
Visit this group at http://groups.google.com/group/Natron-VFX.

Rc Spam

unread,
Mar 24, 2015, 4:33:01 AM3/24/15
to Natro...@googlegroups.com, alessandro....@gmail.com
No, it's the result expected !
No improve compared to precedent operation !
Thank you for your tries

Rc Spam

unread,
Mar 24, 2015, 4:56:44 AM3/24/15
to Natro...@googlegroups.com, alessandro....@gmail.com, MrKepzie/Natron
You mean: "output=[ r, g, b, a];"  ? 
See it in next Snapshot ?

Alexandre

unread,
Mar 24, 2015, 5:00:53 AM3/24/15
to Rc Spam, Natro...@googlegroups.com, alessandro....@gmail.com, MrKepzie/Natron
No, there will be 2 separate expressions because SeExpr does not allow to output more than a 3-dimensional vector.

So there will be a RGB expression and a separate alpha expression. The latest should only output the alpha component, will the former should output the RGB (as usual), so it would be:


RGB expr:  

color = [r, g, b]
color

alpha expr:

alpha = As
alpha

Rc Spam

unread,
Mar 24, 2015, 5:16:19 AM3/24/15
to Natro...@googlegroups.com, rcs...@gmail.com, alessandro....@gmail.com, reply+0098ec12c012923f4e96305abe5f990bf4ae3b7...@reply.github.com
In this case how to apply an expr to As, i mean for example, as i ask before, redirect color channels to alpha channel etc...
Sorry for my misunderstanding here.

Alessandro Dalla Fontana

unread,
Mar 24, 2015, 12:38:59 PM3/24/15
to Natro...@googlegroups.com, alessandro....@gmail.com, frederic...@inria.fr
Works well. Thanks for this this big improvement.
Screenshot from 2015-03-24 17:32:43.jpg

Rc Spam

unread,
Mar 25, 2015, 7:23:23 AM3/25/15
to Natro...@googlegroups.com, alessandro....@gmail.com, frederic...@inria.fr
I can't test, some nodes (including read) are broken in the last snapshot

Alexandre

unread,
Mar 25, 2015, 7:24:31 AM3/25/15
to Rc Spam, Natro...@googlegroups.com
Rc spam: They are not, this is your installation that is broken. Please re-install correctly from https://sourceforge.net/projects/natron/files/snapshots/linux64/repo/Natron_Linux_bundle_snapshot_x86-64bit.tgz/download

Rc Spam

unread,
Mar 25, 2015, 8:02:04 AM3/25/15
to Natro...@googlegroups.com, rcs...@gmail.com
I have do that 2 or 3 times, from this bundle_snapshot link, from the online_snapshot link, and o course i have remove before all old snapshot intall...

I have this error with libssl:

[0][12:50][rapha:Natron]$ ./Natron -debug
Natron
Version: 2.0.0
Copyright (C) 2015 the Natron developers
>>>Use the --help or -h option to print usage.<<<

couldn't open library /home/rapha/Natron/Plugins/IO.ofx.bundle/Contents/Linux-x86-64/IO.ofx because libssl.so.10: Ne peut ouvrir le fichier d'objet partagé: Aucun fichier ou dossier de ce type

Should IO.ofx not be seeking libssl.so.1.0 or something like that ?

Rc Spam

unread,
Mar 25, 2015, 8:43:50 AM3/25/15
to Natro...@googlegroups.com, rcs...@gmail.com

This is the message popup



On Wednesday, March 25, 2015 at 12:24:31 PM UTC+1, MrKepzie wrote:

Alexandre

unread,
Mar 25, 2015, 9:23:12 AM3/25/15
to Rc Spam, Natro...@googlegroups.com
There seem to be a dependency to openSSL by OIIO. I have removed it, try again a fresh installation with the snapshots in 1h

Rc Spam

unread,
Mar 25, 2015, 11:52:15 AM3/25/15
to Natro...@googlegroups.com, rcs...@gmail.com
Ok It's work.
Thanx

Rc Spam

unread,
Mar 25, 2015, 12:02:28 PM3/25/15
to Natro...@googlegroups.com, alessandro....@gmail.com, frederic...@inria.fr
Ok works very well too here.



On Tuesday, March 24, 2015 at 5:38:59 PM UTC+1, Alessandro Dalla Fontana wrote:

Nicholas Carroll

unread,
Apr 4, 2015, 2:47:16 AM4/4/15
to Natro...@googlegroups.com, alessandro....@gmail.com, frederic...@inria.fr
Guys good work with SeExpr I had a look at your latest version. Looks like performance is an issue. I suppose
at Disney they will aim to improve that soon. I saw a job ad on a forum by Disney looking for a dev who wants to 
improve SeExpr so it compiles better. 
Unlike Alessandro  I am the kind of user that will probably never want the capability offered by SeExpr (BTW Alessandro it does support loops.)
. Instead, I like to have convenience and I have written one that works that way. 

  Functionally it is complete but the code needs refactoring and I would need a C++ developer to help me do that.
If people think it is worthwhile. I think it is good to have a basic and an advanced node for expressions. GNU GPL.
Here is a demo on Resolve: https://youtu.be/q2IGatCUa20
 I used this library:
Mathematical operators (+, -, *, /, %, ^)
Functions (min, max, avg, sum, abs, ceil, floor, round, roundn, exp, log, log10, logn, root, sqrt, clamp, inrange, swap)
Trigonometry (sin, cos, tan, acos, asin, atan, atan2, cosh, cot, csc, sec, sinh, tanh, d2r, r2d, d2g, g2d, hyp)
Equalities, Inequalities(=, ==, <>, !=, <, <=, >, >=)
Assignment (:=, +=, -=, *=, /=, %=)
Boolean logic (and, mand, mor, nand, nor, not, or, xor, xnor)
Control Structures (if-then-else, ternary conditional, switch case)
Loop Structures (while loop, for loop, repeat until loop, break, continue)
Optimization of expressions (constant folding, strength reduction, operator coupling and special functions)
String operations (equalities, inequalities, boolean logic, concatenation and ranges)
Multiple and custom variable support
Expression local variables, vectors and strings
User defined variables, vectors, strings, constants and function support
Multivariate function composition

I benchmarked it and it is not slow but not fast :-D. 

Nicholas Carroll

unread,
Apr 4, 2015, 2:48:32 AM4/4/15
to Natro...@googlegroups.com, alessandro....@gmail.com, frederic...@inria.fr
/BTW Alessandro it does support loops/
I meant, my plugin does, not SeExpr.

Nicholas Carroll

unread,
Apr 4, 2015, 2:50:59 AM4/4/15
to Natro...@googlegroups.com, alessandro....@gmail.com, frederic...@inria.fr
and it does not support alot of other stuff like fetching frame number, size, value of pixel at x,y.
So really its just for basics.

haigp...@gmail.com

unread,
Sep 24, 2015, 2:51:13 PM9/24/15
to Natron, alessandro....@gmail.com, frederic...@inria.fr
I'm trying to experiment with this node, but all I get after inputing a valid script is: 'SeExr error: Render failed: Unknown failure reason'

There's nothing, no feedback in the command line to suggest anything.

Even a simple Cs or:

color = Cs;

color

produces this error.

Any ideas?


Thanks!

Alexandre

unread,
Sep 25, 2015, 6:15:54 AM9/25/15
to haigp...@gmail.com, Natron, alessandro....@gmail.com, frederic...@inria.fr
Last few snapshots had a bug. This has been fixed since
> --
> You received this message because you are subscribed to the Google Groups "Natron" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to Natron-VFX+...@googlegroups.com.
> To post to this group, send email to Natro...@googlegroups.com.
> Visit this group at http://groups.google.com/group/Natron-VFX.
> To view this discussion on the web visit https://groups.google.com/d/msgid/Natron-VFX/f4456664-e5eb-4519-95e5-1a5cc5d9172b%40googlegroups.com.

H Petrus

unread,
Sep 25, 2015, 7:10:12 AM9/25/15
to Alexandre, Natron, alessandro....@gmail.com, frederic...@inria.fr
I can confirm that it is now fixed in the latest Linux snapshot.


Thank you.
Reply all
Reply to author
Forward
0 new messages