dimanche 24 janvier 2016

Convert Normal Pass Between World and Camera



http://www.nukepedia.com/gizmos/3d/cfakepathconvert_normal

Let's talk about Normals !

Normals are vectors that indicate a face direction compared to a original vector (the camera or the world)

To change this origin from the camera to the world or the other way arround. We have to use an rotation matrice.

For that, the node "color matrix" used with the three first column of the Camera World Matrix does the work pretty well !

But there is one thing, this method doesn't compute the focal length !
So here is my trick :

I use three cameras with three different orientations : X, Y and Z :


This three cameras are shooting a sphere (parented to cam) to get the reference normals for every axis. This way, the reference takes the focal length in consideration.

Then, for each axis, I do a scalar product with a merge expression between the original normal passe and the reference normal passe I got shooting the sphere.


I copy the 3 result in a new passe, and I got the converted normals.

For the facing ratio, it's the Z (or the blue) of the camera normals. :)

Aucun commentaire:

Enregistrer un commentaire