Force load textures in viewport, batch playblast

I’m trying to batch playblast a lot of maya scenes, but it does not wait for textures to load.

Is there a way to force Maya’s VP2.0 to load textures before proceeding with the script?

I could just use render instead of playblast, but I would really not like to go down that road.

I saw this thread: Wait for textures to load before executing script in maya but there’s an incomplete answer.

In case anyone’s interested, this hacky way seems to do the trick:

cmds.modelEditor(panel, e=True, dtx=False)
cmds.modelEditor(panel, e=True, dtx=True)
for i in range(0, 10):
    log.debug("Refresh", i)

Turns texture display off then on, and refreshes the viewport a few times. I tried just once - did not work. 10 might be too much, seems like 2-5 times is enough.

Still hope to find a better way.

Hi Nix!

Instead of playblasting you can render your scene(s) with the “Hardware 2.0” renderer (which is just the viewport renderer). So you can make all your desired Render settings and kick of a “Batch render”. This might fix your texture issues.
Hope that helps a little bit. :slight_smile:


Hi, Fasbue, thanks for reply!

Yes, I thought about it, but it’s just much easier to run a playblast, which can also include viewport HUD information which may sometimes be needed, as well as whichever Background is set in viewport.

Adding those manually would take more script development time and render time in the end, which is crucial when you need to playblast 100+ files now and then.

Everything is solved much easier and more elegant…
Maya provides a command for this purpose:

Command (Python): displayPref

displayPref( [materialLoadingMode = string] )

string = “immediate” or “deferred” or “parallel”.

Flag: materialLoadingMode(mld)

“create” or “query” mode

Sets the material loading mode when loading the scene.
Possible values for the string argument are:
“immediate”, “deferred” and “parallel”.

Create mode:

import maya.cmds as cmds
cmds.displayPref(materialLoadingMode = "immediate")

Query mode:

import maya.cmds as cmds
displayPrefMaterialLoadingMode = cmds.displayPref(q = 1, materialLoadingMode = 1)


Well, better 3 years later than never I guess! :smiley:

Thanks, works perfectly.