Hugo,
If I understand correctly, you would like to get the orientation of a card
(X and Y rotation) by sampling a pixel (or a region) of a surface normals
render, right?
You can certainly dig into some of the vector and matrix methods, but I
think it would be easier/faster to use some trig expressions in this case.
See if this example does what you want:
set cut_paste_input [stack 0]
version 6.2 v3
push $cut_paste_input
Card2 {
rotate {{"-degrees(atan2(normal.g, sqrt(normal.r**2 + normal.b**2)))"}
{"degrees(atan2(normal.r, normal.b))"} 0}
uniform_scale 4
control_points {3 3 3 6
1 {-0.5 -0.5 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0.1666666865 0} 0 {0 0
0} 0 {0 0 0}
1 {0 -0.5 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0.1666666865 0}
0 {0 0 0} 0 {0.5 0 0}
1 {0.5 -0.5 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0.1666666865 0} 0 {0 0
0} 0 {1 0 0}
1 {-0.5 0 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0.1666666716 0} 0 {0
-0.1666666716 0} 0 {0 0.5 0}
1 {0 0 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0.1666666716 0} 0
{0 -0.1666666716 0} 0 {0.5 0.5 0}
1 {0.5 0 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0.1666666716 0} 0 {0
-0.1666666716 0} 0 {1 0.5 0}
1 {-0.5 0.5 0} 0 {0.1666666865 0 0} 0 {0 0 0} 0 {0 0 0} 0 {0 -0.1666666865
0} 0 {0 1 0}
1 {0 0.5 0} 0 {0.1666666716 0 0} 0 {-0.1666666716 0 0} 0 {0 0 0} 0 {0
-0.1666666865 0} 0 {0.5 1 0}
1 {0.5 0.5 0} 0 {0 0 0} 0 {-0.1666666865 0 0} 0 {0 0 0} 0 {0 -0.1666666865
0} 0 {1 1 0} }
name Card1
selected true
xpos -200
ypos -36
addUserKnob {20 User}
addUserKnob {18 normal}
normal {0.2846873403 0.1778666228 0.9442855716}
}
On Fri, May 20, 2011 at 8:32 AM, Stephen Newbold <
[email protected]> wrote:
> Doesn't that depend on the normal value at that single pixel being exactly
> the desired value to orientate your card with your rendered object? So
> unless you rendered object was completely flat, surely the normal will be
> facing some other direction to the one you want?
>
>
> Thorsten Kaufmann wrote:
>
> Hey there,
>
> That wouldn't be really easier than using the normal though.
>
> @Hugo: What kind of normals pass do you have ? World or Cameraspace ? If the
> latter than you need to add
> the Camera data to properly derive orientation.
>
> Thorsten Kaufmann
> Technical Director
>
> MACKEVISION
> Medien Design GmbH, Stuttgart
> Forststrasse 7
> 70174 Stuttgart
> Tel: +49 (0) 711-933048-0
> Fax: +49 (0) 711-933048-90
> [email protected]
>
> Geschäftsführer: Armin Pohl, Joachim Lincke
> HRB 243735 Amtsgericht Stuttgart
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]
> <[email protected]>] Im Auftrag von Stephen Newbold
> Gesendet: Freitag, 20. Mai 2011 16:57
> An: Nuke Python discussion
> Betreff: Re: [Nuke-python] Got obj orientation from Normal pass
>
> Can you not just select 2 points from your position pass and work out
> the orientation from that with a bit of trigonometry?
>
> Steve
>
>
> Hugo Léveillé wrote:
>
>
> I have made a quick tab in the Card panel to pick a color from the
> position pass to place the card in the 3d space. Quite easy
>
> But Id like to also orient the object in the scene based on the normal
> pass. Is there a gizmo already made for that? If not, any hint on how
> this could be acheived? Seems like I will have to deal with matric witch
> I have not played with yet :)
>
>
>
>
>
>
>
> --
> Stephen Newbold
> Compositing Lead - Film
> MPC
> 127 Wardour Street
> Soho, London, W1F 0NL
> Main - + 44 (0) 20 7434 3100www.moving-picture.com
>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python