Thank you very much, Ivan. yours works as expected. Now I have to find out where my mistake is.
THANKS, Vincent 2016-10-28 19:06 GMT+02:00 Ivan Busquets <ivanbusqu...@gmail.com>: > Hey, > > I don't have much time to recompile C44Matrix these days, but as Vincent > points out, the source is available, so if anyone wants to compile it and > contribute it back, I would be grateful for it :) > > This is how I would do depth-to-position using C44Matrix (copy-pasted > nodes below) > > > > > > Step by step, this would be: > 1 - get your pixel X,Y coordinates > 2 - go from pixel coords to NDC (using a C44 Matrix for this, but you > could easily just normalize to a -1 to 1 range) > 3 - project that vector outwards (using the inverse of a projection matrix) > 4 - scale that vector so the Z component is equal to your depth > 5 - add any camera transforms (translations, rotations...) > > > Hope that helps! > > > set cut_paste_input [stack 0] > version 9.0 v8 > Dot { > inputs 0 > name Dot3 > label cam > selected true > xpos -618 > ypos 2313 > } > set N108b1a10 [stack 0] > Dot { > name Dot9 > selected true > xpos -618 > ypos 2414 > } > set Nf803fb0 [stack 0] > Dot { > name Dot8 > selected true > xpos -618 > ypos 2586 > } > push $Nf803fb0 > push $N108b1a10 > push $cut_paste_input > Dot { > name Dot4 > label "input with depth" > selected true > xpos -751 > ypos 2137 > } > Expression { > expr0 x > expr1 y > expr2 1 > expr3 1 > name Expression4 > label "r = x\ng = y\nb = 1\na = 1" > selected true > xpos -785 > ypos 2194 > } > C44Matrix { > inputs 2 > matrixFrom "from camera input" > matrixType format > invert true > name C44Matrix_v01_3 > label "matrix type: format\ninvert = true" > selected true > xpos -785 > ypos 2297 > } > C44Matrix { > inputs 2 > matrixFrom "from camera input" > matrixType projection > invert true > name C44Matrix_v01_4 > label "matrix type: projection\ninvert = true" > selected true > xpos -785 > ypos 2398 > } > Expression { > expr0 "(r * -depth.Z) / b" > expr1 "(g * -depth.Z) / b" > expr2 -depth.Z > expr3 1 > name Expression5 > label "r = (r * -depth.Z) / b\ng = (g * -depth.Z) / b\nb = -depth.Z\na = 1" > selected true > xpos -785 > ypos 2472 > } > C44Matrix { > inputs 2 > matrixFrom "from camera input" > name C44Matrix_v01_5 > label "matrix type: transform" > selected true > xpos -785 > ypos 2576 > } > Dot { > name Dot7 > selected true > xpos -751 > ypos 2673 > } > > On Fri, Oct 28, 2016 at 8:25 AM, Vincent Langer <m...@vincentlanger.com> > wrote: > >> the source code is on nukepedia as well. >> cheers, >> Vincent >> >> 2016-10-28 17:14 GMT+02:00 Erwan Leroy <er...@erwanleroy.com>: >> >>> Ah, got to get my hands on that c44matrix so that I can see the result. >>> Is Ivan still in the mailing list? Any chance to compile a new one? Or >>> is the source code somewhere? >>> It's an interesting challenge. >>> >>> >>> On Friday, October 28, 2016, Vincent Langer <m...@vincentlanger.com> >>> wrote: >>> >>>> Hi Erwan, >>>> >>>> ah I did not know about cx and cy - good to know- BUT the whole thing >>>> is for a deep tool and cx and cy do not work in deep expressions. this also >>>> answers the question I am why not using the DepthToPosition node. >>>> >>>> focal length and aperature size is considered by the c44Matrix node in >>>> projection mode. >>>> >>>> cheers, >>>> Vincent >>>> >>>> 2016-10-28 12:33 GMT+02:00 Erwan Leroy <er...@erwanleroy.com>: >>>> >>>>> Hi >>>>> Maybe you are doing it for the challenge, but is there a reason why >>>>> you would not use the DepthToPosition node built into Nuke? I seems to do >>>>> exactly what you are trying to do (I get a very small error which I >>>>> believe >>>>> is due to rounding). >>>>> For the fun of it I looked into your expressions, but couldn't go all >>>>> the way through because there is no current build for the C44Matrix for >>>>> Nuke 9 on windows. >>>>> I have 2 things that I believe might be affecting your result (but I >>>>> can't verify): >>>>> >>>>> - I don't see you consider the focal length anywhere? That would have >>>>> a big impact. >>>>> >>>>> - Now this might not apply for every renderer, and Nuke's built in >>>>> node ignores that point as well: In your first expression, you generate a >>>>> "default" position point cloud, with X and Y as planar coordinated, while >>>>> possibly using a "curved" Z_Depth for you Z input. In real world (and Vray >>>>> for exemple) the distance a of a card right in front of a camera would not >>>>> have a single value, as the distance on the sides of the frame would be >>>>> greater than right in front of the camera. >>>>> See attached pictures that illustrate this point. >>>>> >>>>> (Also, for that first expression, why not using cx and cy instead of >>>>> that complex expression) >>>>> >>>>> >>>>> Cheers >>>>> >>>>> *Erwan* LEROY >>>>> www.erwanleroy.com >>>>> >>>>> On Fri, Oct 28, 2016 at 4:04 PM, Vincent Langer < >>>>> m...@vincentlanger.com> wrote: >>>>> >>>>>> Hi there, >>>>>> >>>>>> I am trying to get the math right calculating the worldpositions from >>>>>> z information + camera matrices. >>>>>> >>>>>> my result is close to the rendered position pass - but does not line >>>>>> up perfect. >>>>>> >>>>>> Maybe one of the brains out there can tell me what I am missing/doing >>>>>> wrong >>>>>> >>>>>> This is just a proof of concept for the right math and I use the >>>>>> C44Matrix node from Ivan Busquets. >>>>>> >>>>>> cheers, >>>>>> Vincent >>>>>> >>>>>> -- >>>>>> Vincent Langer >>>>>> Uhlandstr. 29 >>>>>> 71634 Ludwigsburg >>>>>> +49 176 965 177 61 >>>>>> www.vincentlanger.com >>>>>> >>>>>> _______________________________________________ >>>>>> Nuke-python mailing list >>>>>> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ >>>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >>>>>> >>>>>> >>>>> >>>>> _______________________________________________ >>>>> Nuke-python mailing list >>>>> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ >>>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >>>>> >>>>> >>>> >>>> >>>> -- >>>> Vincent Langer >>>> Uhlandstr. 29 >>>> 71634 Ludwigsburg >>>> +49 176 965 177 61 >>>> www.vincentlanger.com >>>> >>> >>> >>> -- >>> *Erwan* LEROY >>> www.erwanleroy.com >>> >>> >>> _______________________________________________ >>> Nuke-python mailing list >>> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ >>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >>> >>> >> >> >> -- >> Vincent Langer >> Uhlandstr. 29 >> 71634 Ludwigsburg >> +49 176 965 177 61 >> www.vincentlanger.com >> >> _______________________________________________ >> Nuke-python mailing list >> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >> >> > > _______________________________________________ > Nuke-python mailing list > Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python > > -- Vincent Langer Uhlandstr. 29 71634 Ludwigsburg +49 176 965 177 61 www.vincentlanger.com
_______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python