Creating Attributes that can be riven by textures

43 views
Skip to first unread message

Dylan Smith

unread,
Oct 30, 2016, 7:32:46 AM10/30/16
to Python Programming for Autodesk Maya
Hi everyone,
What would be the best way to go about creating an attribute that can be driven by a texture?
After a bit of playing around with node networks in Maya, I've found that 'texture' attributes (such as 'outColor' from a ramp node) are recognised as regular float3 attributes instead of float3 array attributes (which is what I assume they should be). I'm not sure if this is a simple case of the Node Editor just telling me the wrong thing, or if its supposed to be some special data type. Because of this, I'm not entirely sure how to proceed with creating a texture attribute. For context, I want to create a simple displacement deformer that can have the intensity of the displacement controlled by a texture (be it a file or a built in generated texture). Any ideas for what I can do?

Joe Weidenbach

unread,
Oct 30, 2016, 3:23:45 PM10/30/16
to Python Programming for Autodesk Maya
Heya,

Texture nodes as you described are more about sampling than the entire texture. The idea is that you pass your coordinates into u and v, and then the node returns the colour value at that point. One important distinction, it's not a specific pixel usually. It finds the pixels surrounding those uv values and averages them.

Hope that helps!
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a4f325b3-efbf-4be1-a2ff-40715c464523%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cedric Bazillou

unread,
Oct 30, 2016, 4:27:50 PM10/30/16
to Python Programming for Autodesk Maya
In maya bible: Complete maya programming 1 and 2 there is a sample project doing just that.
As joe point out you can start looking to MImage class ( readFromTextureNode  / readFromFile )

the other 2 class you are after are 
  • MRenderUtil::sampleShadingNetwork ()
  • MDynamicsUtil::evalDynamics2dTexture()

otherwise you can also have a mix approach have and have maya arrayMapper sample your image for you and let you node displace you float array attribute. ( look at MPxParticleAttributeMapperNode if you are interested  on its mechanics ).

Reply all
Reply to author
Forward
0 new messages