"colorAtPoint" as utility-node?


#1

Hello everyone,

I’m wondering if there is a way to get the same functionality of the MEL-Command “colorAtPoint” through the use of nodes in the hypershade? So that I can sample a color of a texture at a specified UV-coord?
I’m using the colorAtPoint command in expressions now, but expressions are pretty slow :frowning:

Many thanks


#2

I’ve dream of that too, but I don’t think it’s possible, too bad.


#3

colorAtPoint is just a relatively expensive command…even though it is built into maya, it requires an evaluation of the shader graph for that point…so it is like a partial rendering of that point for each call…you could write a c++ node that uses a similar method available in the api…it would also work with in-house textures (which the colorAtPoint will not.)


#4

Many thanks for the answers!
too bad, so I just have to learn C++ and the Maya API.
Ok, I will post again to this thread in a year when I’ve finished the plugin…hehe


#5

Hello,

I had some free time and did a node around the API command, mainly to practice my python skills.

At the moment it should work for 2d and 3d textures only.
I still need to find how to connect a shadingGroup to make it work with these too.

There are a lot of attributes, but only some of them are usefull for 2d/3d textures:

inColor: connect your 2d/3d texture output in there

for 3d textures only:
inPoint: this is the XYZ coords of the point to be sampled
refPoint: this is the XYZ coords of reference point (like a texture reference object)

for 2d textures only:
inUCoord/inVCoord: UV coords to be sampled

The result is sent to: [i]outColorR,outColorG,outColorB

[/i]Other attributes are for shadingGroup evalution and don’t work at the moment…

This is a python plugin, to use it, just copy it in one of your plug-in directory and load it as any other plugin. Or use use the “browse” button in the plugin manager to locate the file and load it.

Once loaded (hopefully without error messages :)) you can either source the included mel script this will create a simple test scene (a locator position driver by a ramp).
or just type “createNode pypl_colorAtPointNode” to create a new node…

Now for the bad side, I don’t know if it will be faster than the colorAtPoint MEL command… But well, this is a new toy to play with :slight_smile:

Feel free to comment or suggest new things, I will upload new versions here too.

Pascal.

PS: this hasn’t been tested very much and could break at any moment, you’ve been warned! :smiley:


#6

very nice pascal…will play with it tomorrow

great

cheers


#7

hi pascal,

that’s absolutely amazing what you did!
Sorry, that I’ve replied so late, I saw the post very late.
That’s exactly what I was looking for and it seems to work great!
Having this command as a node brings so much more flexibility.
The next thing I will be trying to do with you plugin is to write a mel script that will create many of these nodes, based on the selection of some objects and then wire a paramter of each single object to the closest uv of one large texture.

Many thanks for your efforts!!

and very cool that it is written in python so others (like me) can learn from it!

Greetings


#8

Hello again,

I finally had some time to come back to this thing.
Only to find out that I have left some huge bug in it!
It wouldn’t refresh correctly, especially if there are many nodes of this type in the scene.

Took some time to find the reason but it is now working.
I have added a time attribute so it can update when the time changes (usefull mainly for shadingGroups).
Many other fixes (ie: Now you can also find the node in the hypershade,…)

I think it is now working properly, I have included a script to create sample scenes using 2d/3d textures and shading groups…

I have also changed it’s name as in the docs they seems to prefix their “Scripted Plugins” with “SP”… This and some other things make it uncompatible with previous versions.

Read the readme.txt for more infos.

Cheers,
Pascal.


#9

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.