[Maya] ogsRender - hardware render settings

I have a script that renders out a thumbnail image from a scene. Previously I was using the “render” command:

tmpFileName = cmds.render(myCamera, x=128, y=128)

But now, the objects in the scene are using dx11shaders. So the objects are showing up bright green in the rendered image.

I discovered that I could use the “ogsRender” command to make the shaders work:

tmpFileName = cmds.ogsRender(camera=myCamera, w=128, h=128)

The problem is that the image is aliased. I tried using some of the command flags to set multisampling, but they only work in edit mode, and it didn’t work.

cmds.ogsRender(e=True, enableMultisample=True, activeMultisampleType=8)
print cmds.ogsRender(q=True, enableMultisample=True)   # prints False
tmpFileName = cmds.ogsRender(camera=myCamera, w=128, h=128)

Does anyone know how I can set render options for this “ogsRender”?

I think I figured it out. I can set attributes on the “hardwareRenderingGlobals” node. (Not to be confused with the “hardwareRenderGlobals” node.)

cmds.setAttr("hardwareRenderingGlobals.multiSampleEnable", 1)
cmds.setAttr("hardwareRenderingGlobals.multiSampleCount", 8)

Other settings require setting stuff on a different node. For example, the output image format:

cmds.setAttr( "defaultRenderGlobals.imageFormat", 20)	#bmp=20; jpg=8; TARGA=19

Important note. Be sure to set the settings back to the original values when the render is done, because these settings also affect what is seen in the viewport (assuming the user is using Viewport 2.0).