Expression for extracting individual channels from a map in Xgen

Expression for extracting individual channels from a map in Xgen

josh_halford2
Observer Observer
207 Views
0 Replies
Message 1 of 1

Expression for extracting individual channels from a map in Xgen

josh_halford2
Observer
Observer

Hi

 

i am trying to create an expression in Xgen to drive the direction of the primitives based off of a normal map. the method is based off the example "grow in an exact direction" at the bottom of this page

 

https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2020/ENU/Maya-Cha...

 

i have everything working but for the life of me i cannot extract the individual channel data from the normal map. I would like to use the red channel for the X vector and the green channel for the Y. In the Xgen reference the syntax is stated as follows:

map( "mapname" [,s, t] [, channel] )

 

however my scripting knowledge isn't amazing I keep getting a syntax error, right now i have converted the red and green channels from my normal map into 2 grayscale images with Photoshop and loaded them in individually, it works fine but it is a bit messy. So far my expression is as follows but i would like to just use one RGB map and just extract the channels into my vectors if possible

 

$r=map('${DESC}/paintmaps/custom_vector_dir');#3dpaint,100.0
$g=map('${DESC}/paintmaps/custom_vector_dir2');#3dpaint,100.0
$vector_multiplier = 0.1000; #0.00,1
$randomness = 0.0500; #0.00,1
$randvalue = rand(($randomness * -1), $randomness);
$x=($r - 0.5) * ($vector_multiplier + $randvalue);
$y=($g - 0.5) * -1 * ($vector_multiplier + $randvalue);
norm([$x, $y, 1])

 

if someone could show me how to get the channels from the RGB normal map that would be greatly appreciated, thank you

0 Likes
208 Views
0 Replies
Replies (0)