Is there a way to Render target geometry in Maya directly to a texture
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm looking for a solution to output a collection of geometry to texture in Maya. Ideally, this is a way to get real-time flat facial features on a rig similar to those in the Lego movie or the Playmobil films. There is a really good talk here (PlayMobil Face System), that details a method, but I just don't have enough experience with OpenMaya in Python to figure it out effectively.
So far I've been working with OpenMaya API to get a solution. There have been a few solutions that write an image buffer to a file that have been promising, but I can't seem to get them to work as a node that updates to a texture output.
#Import api modules
import maya.api.OpenMaya as api
import maya.api.OpenMayaUI as apiUI
import maya.api.OpenMayaRender as omr
#Grab the last active 3d viewport
view = apiUI.M3dView.active3dView()
#read the color buffer from the view, and save the MImage to disk
image = api.MImage()
texture = omr.MTexture()
#view.readColorBuffer(image, True) #Doesn't work because of viewport2
if view.getRendererName() == view.kViewport2Renderer:
image.create(view.portWidth(), view.portHeight(), 4, api.MImage.kFloat)
view.readColorBuffer(image,True)
#image.convertPixelFormat(api.MImage.kByte)
print "viewPort2"
else:
view.readColorBuffer(image)
print "old viewport !"
image.writeToFile('F:/test.png', 'png')