set cut_paste_input [stack 0]
push $cut_paste_input
Group {
name Tonemap_PiecewiseHyperbolic
label "Piecewise Hyperbolic\n Decoupled White Pivoted Toe + Surround"
addUserKnob {20 Tonemap}
addUserKnob {78 g l grey t "input -> output grey" n 2}
g {0.18 0.1}
addUserKnob {78 w l white t "input -> output white" n 2}
w {16 1}
addUserKnob {7 p l contrast R 0.8 2}
p 1.2
addUserKnob {7 ps l surround t "surround compensation: un-pivoted power function" R 0.8 1.2}
ps 1
addUserKnob {7 t0 l toe R 0 0.1}
addUserKnob {78 s l scale n 2}
s {{pow(g.1,1/p)/g.0} {(s.0*pow(w.0-g.0,2)*pow(g.0*s.0-pow(w.1,1/p),2))/pow(s.0*w.0-pow(w.1,1/p),2)}}
addUserKnob {4 direction M {forward inverse}}
addUserKnob {26 "" +STARTLINE}
addUserKnob {26 plot_label l " " T "desmos plot"}
}
Input {
inputs 0
name Input
xpos -40
ypos -40
}
set Nace3c80 [stack 0]
Expression {
expr0 w.1*pow(r/w.1,1/ps)
expr1 w.1*pow(g/w.1,1/ps)
expr2 w.1*pow(b/w.1,1/ps)
name InvSurround
xpos 70
ypos 21
}
Expression {
temp_name0 st
temp_expr0 (w.1+t0)/w.1
expr0 (r+sqrt(r*(4*st*t0+r)))/(2*st)
expr1 (g+sqrt(g*(4*st*t0+g)))/(2*st)
expr2 (b+sqrt(b*(4*st*t0+b)))/(2*st)
name InvToe
xpos 70
ypos 51
}
Expression {
temp_name0 h0
temp_expr0 g.0-sqrt(s.1/s.0)
temp_name1 h1
temp_expr1 s.0*g.0+sqrt(s.0*s.1)
expr0 r>g.1?h0-s.1/(pow(r,1/p)-h1):pow(r,1/p)/s.0
expr1 g>g.1?h0-s.1/(pow(g,1/p)-h1):pow(g,1/p)/s.0
expr2 b>g.1?h0-s.1/(pow(b,1/p)-h1):pow(b,1/p)/s.0
name InvCompress
xpos 70
ypos 81
}
push $Nace3c80
Expression {
temp_name0 h0
temp_expr0 g.0-sqrt(s.1/s.0)
temp_name1 h1
temp_expr1 s.0*g.0+sqrt(s.0*s.1)
expr0 r>g.0?pow(h1-s.1/(r-h0),p):pow(s.0*r,p)
expr1 g>g.0?pow(h1-s.1/(g-h0),p):pow(s.0*g,p)
expr2 b>g.0?pow(h1-s.1/(b-h0),p):pow(s.0*b,p)
name Compress
xpos -150
ypos 21
}
Expression {
temp_name0 st
temp_expr0 (w.1+t0)/w.1
expr0 (st*r*r)/(r+t0)
expr1 (st*g*g)/(g+t0)
expr2 (st*b*b)/(b+t0)
name Toe
xpos -150
ypos 51
}
Expression {
expr0 w.1*pow(r/w.1,ps)
expr1 w.1*pow(g/w.1,ps)
expr2 w.1*pow(b/w.1,ps)
name Surround
xpos -150
ypos 81
}
Switch {
inputs 2
which {{parent.direction}}
name SwitchDirection
xpos -40
ypos 141
}
Output {
name Output
xpos -40
ypos 200
}
end_group