Get color at uv?

Hi,

I used to do a setup in Maya that relied on getting the color of a surface at a given UV, but forgot how to do it completely…

Does anyone know how? It needs to be done with a node and not a command.

Thanks

If the surface is textured, then just connect your input u,v to the file texture node’s input .uvCoord attribute, and the ftn’s outColour will give you want you need.

Thanks Paul! I just found my old setup and this is about what I did :slight_smile:

Paul, could you please explain in details how this trick works.

I’m trying to do the same thing with picking color at specific point. Basically I want that a color at specific UV coordinates could influence other objects’ properties.

Let’s say, we have an animated texture (or rather let’s take a simple ramp for now) and we want to use the color data to drive something else in our scene—for example translateY attribute of a single sphere (we could duplicate it with input connections later). The brighter the texture, the higher goes the sphere.

All right, I’ve created a plane with a ramp, a sphere with two custom attributes named “UU” and “VV” which go from 0 to 1 (simple driven keys help a lot). As the name suggests, these attributes will pinpoint the UV-coordinates.

But to complete the test rig I need to find out how to get the color value at specific UV and how to plug it to something else.

If we could solve the problem, than we would be able to use ramps and animated textures to create all kinds of “massive” effects: matrix of monitor, waves of different kinds, piano that plays by itself and so on.

Thanks an advance.

P. S. I’m not very advanced user, but I learn and use my imagination.

Hi Scorpy,

Sorry about not getting back sooner.

Duplicate the shader (with it’s ramp) that you applied to the plane, and apply this new shader to the sphere.

Now connect your two set driven key UV attributes from the sphere to the uCoord and vCoord attributes of the place2DTexture node that is connected to your copied ramp texture. This will in effect turn the colour output of ramp into a UV sample point.

Hopefully, if you move the sphere around, it’ll change colour as if it’s sampling the plane below, though only when the node’s been evaluated.

Hope this helps

Paul

Thank you very much, Paul! It really works! A color drives the animation. Of course, this simple setup is used for test purposes, but theoretically it can be used for all kinds of things—self playing piano, waves of crowd, dancing lights, wild transition effects.

You are right by the way—there are some issues with update. But it is just a delay and test render looks fine. Great possibilities! I really appreciate your help.

Does this setup allows to query one “U” value at a time per ramp node?

Is it possible to query several values from a single ramp node?

Im thinking on using this setup to drive constraints weights on a sticky lips setup, but by reading this i imagine you can only read one “u value” (the one on your UU attribute) at a time from a ramp node