|
I’m a programmer writing a custom shader for Maya. One of the inputs to this shader is a vector that represents the direction of gravity.
What I would like to do is create a nurbs curve object to represent the force of gravity. I would then find the vector of the object that coresponds to its z axis in world space. I’d then multiply this vector by the strength of gravity and connect it to the input gravity attribute on my custom shader.
This sounds like the sort of thing Maya should handle, but I can’t figure out how to do it. Can I do this with the default shader network nodes Maya ships with, or do I have to do some custom programming?
|
|
|
|
Not sure, why you want to use Z vector instead of Y but:
-create vectorProduct node;
-connect your curve worldMatrix attribute to vectorProduct.matrix
-set first inVector to 0,0,1
-set operation to Vector Matrix Product
vectorProduct.output will return desired vector in world space
if you want to get this vector in camera space then you still can do this with nodes (probably it is better to script/code this part). You can use different methods for example dot product or matrix conversion. Lets use the second:
-create pointMatrixMult node
-connect vectorProduct.output to pointMatrixMult.inPoint
-connect your camera.worldInverceMatrix to pointMatrixMult.inMatrix
-now we can normalize this result vector using another vectorProduct node
-connect pointMatrixMult.output to second vectorProduct.input1
-connect camera.worldMatrix to second vectorProduct.matrix
-set operation to Vector Matrix Product
-turn on normalize vector
this one should work in theory, still I think it is better not to do it in graph editor.
|
|
|