Saturday, May 20, 2017

Maya Tricks - Maya Pivot

If you want to know everything about pivot points in maya you should check this video:




Maya Tricks - Measure rgba value range

Let's say we have a file texture and we want to adjust the color of that. We have plenty of options to do that. I think the most sophisticated is the ColorRemap node which is similar to Photoshop's or GIMP's Curves tool or Nuke's ColorLookup node however Maya's ColorRemap is less user friendly I think.


Maya has an option to make a node graph to recolor the picture based on its luminance. We can create the node graph simply just clicking to the Color Remap button below the file node's effects rollout.


The node graph is going to look like this.


The ramp node has a default black to white gradient. We can change the black to blue for eg. and it will change the darkest colors on the picture to blue. Picture like this:


 with a ramp like this:


going to result a picture as we can see below:



The simpliest and obvious solution to change colors is to use the file node's built-in Color Balance options.


These options have limited capabilities of course. We can use textures on Color Offset or Color Gain for eg. Color Gain multiplies the texture file's color and Color Offset adds to or substracts from the input color. Maya has nodes for the basic mathematical operations: multiplyDivied and the plusMinusAverage.

But when we adjust the color of the original texture especially when we use Color Gain (multiplication) or Color Offset (addition) we modify the color range of the picture. As far as I know maya has no tool to measure color range of a picture. It would be useful when we use the modified map to emit fluid for example. Especially true when we use animated maps. We have setRange node but there should be an option to copy the current range values to the oldMin and oldMax fields.
There might be a python (pyMel or API) trick to achieve that. Let me know if there is a method to query the color range of a (texture) node output.

I found an easy solution to visualize the color range of a picture using the SOuP plug-in. It provides the textureToArray node. With that we can sample a texture and plug into the SOuP's peak deformer. So basically we can create a displace modifier. Unfortunately the (new) textureDeformer has limited options to acieve that effect. HightField has the same weakness.

To display our colorRange with SOuP nodes we can use a polyPlane as a base geometry. We have to setup a following network:


It is important to check the accurateSampling option on textureToArray node. That will ensure to sample trough to whole network.


In this case I use a luminace sampling using the luminance node and the output in this case the alpha channel. So the peak deformer is using the luminance values to offset the vertices.
If we apply the color as a surfaceShader to the plane the result will look like this.




Of course the measure of the peak is adjustable on the peak derormer.



This setup helps to visualize the RGBA or this case the luminance values. Since we use color management in maya. We can sample in maya viewport (or everywhere else) the real (not only 0-1) color value. So this setup give us a hint which areas have the highest or lowest values.


We can get further if we query the list of y value of the vertices and get the color of the lowest and highest value by the colorAtPoint MEL (or python command).