Setting IBL in Mental Ray using Python

77 views
Skip to first unread message

Mike Oliver

unread,
Apr 7, 2016, 9:32:19 PM4/7/16
to Python Programming for Autodesk Maya
Hi Everyone,
I'm trying to set up some automated Mental Ray scripts for our studio artists.  I'm having some difficulties accessing all the proper variables within Mental Ray.  Specifically setting the Image Based Lighting.
I have created IBLShapes, set their attributes and connected the IBL to 'mentalrayGlobals.imageBasedLighting' yet when I set an HDR map (done manually for the time being) and render, I get no IBL information and a warning:
Warning: (Mayatomr.Nodes) : mentalrayIbl1: IBL ignored. File texture not found, or constant black input color. //

I'm very sure there is an attribute I'm not connecting somewhere, but I cant spot it. 

Tracing Mayas output window I can see the miCreateIbl function (C:/Program Files/Autodesk/mentalrayForMaya2014/scripts/createMentalRayIndirectLightingTab.mel).  I don't believe I missed anything in the Create or Update IBL functions

Does anyone have any suggestions?

Thanks


Enter code here...
import pymel.core as pm
# Load MentalRay Plugin
if not pm.pluginInfo('Mayatomr', q=1, l=1):
    pm.loadPlugin('Mayatomr', qt=1)

#Set MentalRay Options
pm.setAttr('defaultRenderGlobals.ren', 'mentalRay', type='string')
pm.setAttr('miDefaultOptions.globalIllum', 1)
pm.setAttr('miDefaultOptions.globalIllumAccuracy', 500)
pm.setAttr('miDefaultOptions.finalGather', 1)
pm.setAttr('miDefaultOptions.finalGatherRays', 500)
pm.setAttr('miDefaultOptions.finalGatherPresampleDensity', 5)
pm.setAttr('miDefaultOptions.finalGatherPoints', 125)

# Add IBL
if not ibl:
    ibl = pm.shadingNode('mentalrayIblShape', al=1)
    pm.connectAttr(ibl+'.message','mentalrayGlobals.imageBasedLighting')
    pm.xform(ibl, s=[5000,5000,5000])    
    pm.setAttr(ibl+'.primaryVisibility', 0)
    pm.setAttr(ibl+'.visibleInEnvironment', 1)
    pm.setAttr(ibl+'.visibleInReflections', 1)
    pm.setAttr(ibl+'.visibleInRefractions', 1)
    pm.setAttr(ibl+'.visibleInFinalGather', 1)
    #set Image path in UI (done manually for now)


patrick...@gmail.com

unread,
Aug 1, 2016, 10:45:40 PM8/1/16
to Python Programming for Autodesk Maya
Hey Mike

Maybe you could try to explicitly set the image type (texture/imageFile) to image file?

pm.setAttr(ibl+'.type', 1) # to use an image file
pm.setAttr(ibl+'.type', 0) # to use a texture

Maybe you could try and set it to use a texture for now and see if that works.

If that actually works, you could point it to a texture file node and load an image file from there?

Not the most elegant solution, but I believe that'll work.

Let me know if any of it helps :)

Best Regards,
Patrick
Reply all
Reply to author
Forward
0 new messages