View Full Version : colorAtPoint for Luminance

10 October 2006, 09:20 PM
Getting wierd results. When I try to use the colorAtPoint command to retrieve the luminance value at a specified UV location, I get the v value I am passing as the result. Meaning, if I say colorAtPoint -o RGB -u .3 -v .7 texture ... the return is .7, or whatever the -v is.. I don't get it.

My setup is loading a 2D texture (this case a file), sending it through an rgbToLuminance node, which then goes into a ramp from black-to-white ... Thus giving me the Black and White/Luminance equivalent.

I am using this new ramp as my texture, but it returns the wrong result. If I do the colorAtPoint on the actual colored texture I loaded, it returns the proper result! Help?


10 October 2006, 12:26 AM

I dont have a solution for you current problem but i may have a possible work around.
Rather than piping the output from the ColorAtPoint command into those nodes can you
not just directly convert the RGB value to a Luminace value using the following formula
in your mel script??

RGB to Luminance value = (0.3 * R + 0.59 * G + 0.11 * B)

Below is a quick example:

string $texture = `createNode checker`;
setAttr ($texture+".color1") -type double3 0.1 0.45 0.95 ;
setAttr ($texture+".color2") -type double3 1.0 0.79 0.39 ;

float $rgb[] = `colorAtPoint -o RGB -u .1 -v .1 checker1`;

//RGB to Luminance value = 0.3 * R + 0.59 * G + 0.11 * B
float $luminance = (0.3 * $rgb[0]) + (0.59 * $rgb[1]) + (0.11 * $rgb[2]);

print ("\nRGB = ("+$rgb[0]+","+$rgb[1]+","+$rgb[2]+")");
print ("\nLuminance = " + $luminance );

Hope that helps.


CGTalk Moderation
10 October 2006, 12:26 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.