Hello everyone!
I’m programming a tool that helps me playblast files in standalone.
It queries the cams in the scene, prompts the user for settings, etc…
Everything works except for the background. It renders black. I tried to use cmds.displayRGBColor() to change the colour of the background but it didn’t work. The weird thing is that if i use cmds.displayPref(dgr=1) which usually sets the background to have a gradient, it works and is no longer black. That being said i don’t want the maya gradient but the dark grey default so i don’t know what to do…
the hotkey to change BG color in a viewport is Alt+B
with echo all commands on in the script editor, we see it calls the MEL cycleBackgroundColor;
using mel whatIs("cycleBackgroundColor") we see it points to C:/Program Files/Autodesk/Maya2022/scripts/others/cycleBackgroundColor.mel
opening that, we see the mel code that changes the BG color:
// ===========================================================================
// Copyright 2021 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
// ===========================================================================
// Description:
// Cycles the background color of viewports, and then to gradient display
//
// Return Value:
// None.
//
global proc cycleBackgroundColor(){
// query bg color
float $rgb[3] = `displayRGBColor -query background`;
int $gradOn = `displayPref -q -displayGradient`;
if ($gradOn)
{
displayRGBColor background 0 0 0;
displayPref -displayGradient 0;
}
else
{
if ($rgb[0] == 0)
{
displayRGBColor background 0.36 0.36 0.36;//default color
}
else if ($rgb[0] < 0.5)
{
displayRGBColor background 0.631 0.631 0.631;
}
else
{
displayPref -displayGradient 1;
}
}
optionVar -intValue "displayViewportGradient" `displayPref -query -displayGradient`;
}
the mel call that sets default grey is
displayRGBColor background 0.36 0.36 0.36;//default color
so add that line to your tool
disclaimer: I do not know if this works in standalone
Hey there!
I had already tried this. It doesn’t work, same as setting the attribute .backgroundColor of the camera shape.
I think this issue has to do with the fact that there is no real viewport since it is in standalone mode, causing the issue. I still don’t really know how to fix it.