sample images for RGB data?

sample images for RGB data?

bmagner888
Enthusiast Enthusiast
250 Views
5 Replies
Message 1 of 6

sample images for RGB data?

bmagner888
Enthusiast
Enthusiast

I need to query a point on a mesh, convert the point to UV coordinates, and then sample the image to determine what color corresponds to that point on the mesh (and then do something if the color = some rgb values).   

I'm close to solving the point-on-mesh to UV space, but I've found nothing for sampling images.  I could use pillow to extract pixel information, but then I have re-map it for UV space (I think pillow origin is upper left, while maya UV origin is lower left)  

Maya does this image sampling already for displacement maps, emitting particles from a surface (emitter1.textureRate), and in various other ways.  But I can't find any documentation on how to do it programmatically.   

There are probably ways to do it in BiFrost, but I'd rather do it with python so it can be integrated into existing python tool sets (plus I hate node-based programming.  Just a personal dislike--it's fine if that's your thing but I find it annoying. )

Use cases:  telling meshes (trees/grass/bushes) where to be instanced, or pulling the red lines of a USGS topography map to create height displacement.

any help is appreciated.
thanks

0 Likes
Accepted solutions (1)
251 Views
5 Replies
Replies (5)
Message 2 of 6

FirespriteNate
Advocate
Advocate
Accepted solution

check out cmds.colorAtPoint()

0 Likes
Message 3 of 6

sepu6
Advisor
Advisor

There are probably ways to do it in BiFrost

Im just gonna answer to this part. Yes there is and its pretty straight forward, you would be done already in BF and it would be a lot faster than doing it Python, if you have a bunch of data. I get your point of nodes and code. 


0 Likes
Message 4 of 6

bmagner888
Enthusiast
Enthusiast

just a follow up question, can you build BiFrost networks with python?  Can you get the best of both worlds and access BiFrost from other custom tools so that, as a TD, you can provide artists with tools where the artists don't have to know BiFrost?  The artist clicks a button, and the graphs are build automatically so they get the benefits without needing specialized training?

0 Likes
Message 5 of 6

FirespriteNate
Advocate
Advocate

I'm no expert with Bifrost, but I don't think you can construct the graphs purely from Python (at least not last time I looked), but you are maybe thinking about this the wrong way. Your users are not Python coders either, but you still write the python, distribute it to them and get them to run it some how. The same is true with Bifrost. Think of each Bifrost graph you make and save as a python-like module. You make the Bifrost graphs and save them out as files and you distribute these to your end users in the same way you do python files. They don't necessarily need to know how they work, or interact with them. I'm pretty sure you can do the loading, connecting, and execution of the distributed graphs via Python.

0 Likes
Message 6 of 6

sepu6
Advisor
Advisor

Correct as FirespriteNate you can't just create graph with pure python, there is def certain thing that you can do with python to make your life easier, like to automate connecting lots of inputs/outputs, building rigs depending on Bifrost graph and various other tedious tasks.

https://help.autodesk.com/view/BIFROST/ENU/?guid=__CommandsPython_index_html

You can do stuff like this for example 
https://github.com/evanatherton/jotun_bifrost_utils

But what would you be doing in the graph is just a compound that can be publish and share studio wise and the artist can use, with whatever parameters you promote to the top level. 

Then they can manipulate stuff through the AE like this. You get the idea. 

 

maya_0MlAl6ZnMC.gif

0 Likes