hey Matt, thanks a lot for the detailed explanation and examples! that's
exactly what I neeed.
much appreciated.
2014-08-28 18:48 GMT-03:00 Matt Lind ml...@carbinestudios.com:
Updated version:
Vector_state à vector-Vector à Vector_Coordinate_Converter à
Vector-Scalar à Gradientà Surface
(normal) (negate) (Vector, to Camera)(Dot
against -1,0,0)(scalar input,[-1…1])
This works in similar fashion to the method I submitted previously. The
main difference being the normal vector is dotted against the camera’s –X
axis to provide the directional information.
If the viewed normal aligns with the camera’s –X axis, the dot product
will return -1 (red).
If the viewed normal vector aligns with the camera (points to the camera),
the dot product will return 0 (cyan).
If the viewed normal vector aligns with the camera’s local X axis, the dot
product will return 1 (yellow).
The output of the dot product drives the gradient. Just make sure to use
Processing Mixers Gradient and not Texture Gradient. If you want to
make the output more accurate, zero out the Y component of the normal
vector after it’s converted to camera space, but before doing the dot
product. Then normalize. That will eliminate the vertical component.
You want to avoid using expressions in render trees as it can slow down
performance and cause other unwanted side effects. Mental ray does all
computations in ‘internal space’ which is largely undefined. Softimage did
it’s best to ensure that for lights and cameras, internal space is
equivalent to world space. So when the ‘vector_coordinate_converter’ node
is used above to convert the normal to camera space, what it’s doing is
converting the normal from world space to the local coordinate space of the
camera. However, it should not be assumed that internal space always maps
to world space, because it doesn’t.
Matt
*From:* Matt Lind
*Sent:* Thursday, August 28, 2014 11:35 AM
*To:* softimage@listproc.autodesk.com
*Subject:* RE: Dot Product on Rendertree?
You cannot get your desired result with only a dot product because in
order to differentiate between facing left and facing right, you need
directional information. A dot product only gives the cosine of the angle
between the vectors, not direction.
Based on your description, I’m assuming you want to drive color based on
the surface normal relative to the camera. To do that is fairly simple.
1) Get a vector_state node and set it to ‘normal_vector’. This is the
surface normal at the intersection point.
2) Get a vector_vector node and plug the previous node into
vector_input1. Set the operation to ‘negate’. This will flip the normal
to point away from the camera (assuming it’s a front facing surface).
3) plug the result into a vector_coordinate_converter node, and set ‘type’
to ‘vector’, then set ‘transform’ to ‘to Camera’. This will treat the
normal as an orientation vector and re-describe it in the camera’s
coordinate space. We do this to isolate the normal vector’s X-axis to make
it easy to determine if it’s facing left or right relative to the frame.
4) Plug the output of the vector_coordinate_conversion node into a
‘vector_to_scalars’ node. This will give us access to the normal vector’s
X, Y, and Z components.
5) Plug the ‘X’ output of the vector_to_scalars node into the ‘input’ port
of a gradient node. In the gradient shader, go to the ‘input’ tab and set
active range to [-1…1] and set input type to ‘scalar input’. Finally,
adjust the color gradient markers so the left end is yellow, the middle is
cyan, and the right side is red – the opposite of the default arrangement.
If you do not want to futz with the color markers, then invert the ‘active
range’ on the input to be [1…-1]. I don’t recommend inverting as it’s
non-standard math and while it’s perfectly fine for this simple prototype,
it’ll cause headaches in a production pipeline as it’ll be a source of hard
to find bugs from stupid logic.
Matt
*From:* softimage-boun...@listproc.autodesk.com [
mailto:softimage-boun...@listproc.autodesk.com
softimage-boun...@listproc.autodesk.com] *On Behalf Of *Fabricio Chamon
*Sent:* Thursday, August 28, 2014 8:20 AM
*To:* softimage@listproc.autodesk.com
*Subject:* Dot Product on Rendertree?
Hello fellow survivors!
I'm trying to gradient shade a simple grid, using the dot product of
surface normal vs. camera position:
basic idea is:
grid facing camera cyan
grid facing left red
grid facing right yellow
the above setup is not working... any suggestions ?
thanks