The colorAtPointcommand is used to query textures or ocean shaders at passed in uv coordinates. (For ocean shaders uv is x and z in worldspace ). The return value is a floating point array whose size is determined by either the number of input uv arguments passed in and the the queried value. One can query alpha only, rgb only, or rgba values. The returned array is only single indexed, so if rgb is specified then the index for red values would be index * 3. Blue is index * 3 + 1, and green is index * 3 + 2. For rgba use a multiple of 4 instead of 3. For alpha only one can simply use the index. There are two basic argument formats that may be used: colorAtPoint -u 0 -v 0 -u .2 -v .1 etc.. for all points or colorAtPoint -mu 0 -mv 0 -xu 1 -xv 1 -su 10 -sv 10 // samples 100 points If one is sampling several points and they are all in a regular grid formation it is more efficient to call this routine with the latter method, which uses a min/max uv and number of samples, rather than a long argument list of uv coords. return values (-o A or RGB or RGBA)individual UV coordinates to sample (-u float -v float)(numbers of calls to -u and -v must match)uniform grid of points to sample (-su int -sv int)(may not use this in combination with -u or -v)bounds for sample grid (-mu float -mv float -xu float -xv float)
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
coordU (u) | float | ||
|
|||
coordV (v) | float | ||
|
|||
maxU (xu) | float | ||
|
|||
maxV (xv) | float | ||
|
|||
minU (mu) | float | ||
|
|||
minV (mv) | float | ||
|
|||
output (o) | unicode | ||
|
|||
samplesU (su) | int | ||
|
|||
samplesV (sv) | int | ||
DEFAULT 1 The number of points to sample in the V dimension.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list. |
Derived from mel command maya.cmds.colorAtPoint
Example:
import pymel.core as pm
import maya.cmds as cmds
# The return value is the array of values determined by the number of
# coord flag uses or samplesU * samplesV. The default return value is alpha.
# If instead the return value is RGB there will be 3 times as many values returned,
# and if it is RGBA there will be 4 times as many values.
pm.createNode( 'checker' )
# Result: nt.Checker(u'checker1') #
pm.colorAtPoint( 'checker1' )
# Result: [0.5] #
# returns the alpha value at uv (0.0,0.0) for texture checker1
# The return array will have one entry corresponding to this alpha.
pm.colorAtPoint( 'checker1', u=.5, v=.5 )
# Result: [0.5] #
# returns the alpha value at uv (0.5,0.5) for texture checker1
# The return array will have one entry corresponding to this alpha.
pm.colorAtPoint( 'checker1', o='RGB', u=(.5, 0.0), v=(.5, 0.1) )
# Result: [0.5, 0.5, 0.5, 0.5, 0.5, 0.5] #
# returns the colors at uv (0.5,0.5) and (0.0, 0.01) for texture checker1
# The return array will have 6 values in the following order: RGBRGB
pm.colorAtPoint( 'checker1', o='A', su=11, sv=6 )
# Result: [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 1.0, 0.0, 0.0, 0.5, 0.5, 1.0, 1.0, 0.0, 0.0, 0.5, 0.5, 1.0, 1.0, 0.0, 0.0, 0.5, 0.5, 1.0, 1.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5] #
# returns the alpha for 50 points in a uniform 11 by 6 grid mapped across
# uv (0.0, 0.0) to uv (1.0, 1.0) The 12th point would be the first point
# in the second row of samples where uv = (0.0, 0.2)
pm.colorAtPoint( 'checker1', o='A', su=3, sv=3, mu=0.3, mv=0.3, xu=0.4, xv=0.4 )
# Result: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] #
# returns the alpha for 9 points in a uniform 3 by 3 grid mapped across
# uv (0.3, 0.3) to uv (0.4, 0.4) The 4th point would be the first point
# in the second row of samples where uv = (0.35, 0.3).