(Python is damn slow this has to be C of course)
- Code: Select all
import maya.cmds as cmds
import maya.OpenMaya as om
import maya.OpenMayaRender as omr
resolutionX = 512;
resolutionY = 512;
resultColors = om.MFloatVectorArray();
resultTransparencies = om.MFloatVectorArray();
coordsU = om.MFloatArray();
coordsV = om.MFloatArray();
for v in range(0, resolutionY):
vValue = v * (1.0/(resolutionY-1));
for u in range(0, resolutionX):
index = u+v*resolutionX;
coordsU.insert(u * (1.0/(resolutionX-1)), index);
coordsV.insert(vValue, index);
omr.MRenderUtil.sampleShadingNetwork("surfaceShader1.outColor", resolutionX*resolutionY, False, False, om.MFloatMatrix(), None, coordsU, coordsV, None, None, None, None, None, resultColors, resultTransparencies );
sampledColorArray = [];
for i in range(resultColors.length()):
resultVector = om.MFloatVector(resultColors[i]);
sampledColorArray.append(resultVector.x*255);
sampledColorArray.append(resultVector.y*255);
sampledColorArray.append(resultVector.z*255);
print sampledColorArray;
3D textures are possible too. But they also need a reference geometry.