// =========================================================================== // Copyright 2018 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. // =========================================================================== //================================================================== // MayaHardware Renderer Tab //================================================================== // Description: Utility procedure used by other procedures in this file. // Must be used to account for multiple instances of the same tab. // global proc setParentToHardwareTab() { // First set the parent to the correct tab layout. // Account for the special "all renderers" master layer layout // when we are using render layers global string $gMasterLayerRendererName; string $renderer = isDisplayingAllRendererTabs() ? $gMasterLayerRendererName : `currentRenderer`; string $tabLayout = rendererTabLayoutName($renderer); setParent $tabLayout; // Now set the parent to the correct column layout setParent hardwareTabColumn; } // Description: // This procedure is called to build the "Render Option" frame // in the "Hardware" tab for the Maya hardware renderer in // the unified render globals. // proc createHardwareRenderOptionsFrame (string $parent) { setUITemplate -pushTemplate attributeEditorTemplate; setParentToHardwareTab(); setParent $parent; columnLayout -adjustableColumn true; // Global culling override attrControlGrp -attribute "hardwareRenderGlobals.culling"; separator; // Small object culling attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kSmallObjectCullingThreshold")) -attribute "hardwareRenderGlobals.smallObjectCulling" -cc "updateMayaHardwareObjectCulling"; attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kImageSizePercent")) -attribute "hardwareRenderGlobals.cullingThreshold" -enable (`getAttr "hardwareRenderGlobals.smallObjectCulling"`) mayaHardwareCullingThreshold; separator; // Hardware geometry caching // attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kHardwareGeometryCache")) -attribute "hardwareRenderGlobals.graphicsHardwareGeometryCachingData" mayaHardwareGeometryCachingData; attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kMaximumCacheSize")) -attribute "hardwareRenderGlobals.maximumGeometryCacheSize" mayaHardwareMaxGeometryCacheSize; // Hardware environment map lookup attrControlGrp -attribute "hardwareRenderGlobals.hardwareEnvironmentLookup"; separator; // Motion Blur // attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kMotionBlur")) -attribute "hardwareRenderGlobals.enableMotionBlur" -cc "updateMayaHardwareMotionBlur"; attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kMotionBlurByFrame")) -attribute "hardwareRenderGlobals.motionBlurByFrame" -enable `getAttr "hardwareRenderGlobals.enableMotionBlur"` mayaHardwareMotionBlurByFrame; attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kNumberOfExposures")) -attribute "hardwareRenderGlobals.numberOfExposures" -enable `getAttr "hardwareRenderGlobals.enableMotionBlur"` mayaHardwareNumberOfExposures; separator; attrControlGrp -attribute "hardwareRenderGlobals.enableGeometryMask"; attrControlGrp -attribute "hardwareRenderGlobals.blendSpecularWithAlpha"; separator; optionMenuGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kShadowLinking")) hwrShadowLinkingMenu; optionMenuGrp -edit -cc updateLightAndShadowLinking hwrShadowLinkingMenu; menuItem -label (uiRes("m_createMayaHardwareGlobalsTab.kObeyShadowLinking")) hwrShadowsObeyShadowLinking; menuItem -label (uiRes("m_createMayaHardwareGlobalsTab.kObeyLinkingLinking")) hwrShadowsObeyLightLinking; menuItem -label (uiRes("m_createMayaHardwareGlobalsTab.kIgnoreShadowLinking")) hwrAllLightsShadow; if (`getAttr hardwareRenderGlobals.shadowsObeyShadowLinking`) { optionMenuGrp -edit -select 1 hwrShadowLinkingMenu; } else if (`getAttr hardwareRenderGlobals.shadowsObeyLightLinking`) { optionMenuGrp -edit -select 2 hwrShadowLinkingMenu; } else { optionMenuGrp -edit -select 3 hwrShadowLinkingMenu; } setParent ..; setUITemplate -popTemplate; } global proc updateLightAndShadowLinking () { int $shadowLinkType = `optionMenuGrp -query -select hwrShadowLinkingMenu`; if ($shadowLinkType == 1) { setAttr "hardwareRenderGlobals.shadowsObeyShadowLinking" true; setAttr "hardwareRenderGlobals.shadowsObeyLightLinking" false; } else if ($shadowLinkType == 2) { setAttr "hardwareRenderGlobals.shadowsObeyShadowLinking" false; setAttr "hardwareRenderGlobals.shadowsObeyLightLinking" true; } else { setAttr "hardwareRenderGlobals.shadowsObeyShadowLinking" false; setAttr "hardwareRenderGlobals.shadowsObeyLightLinking" false; } } // Description: // This procedure is called to create the "Hardware" globals tab // in the unified render globals for the maya hardware renderer. // global proc createMayaHardwareGlobalsTab() { string $parentForm = `setParent -query`; scrollLayout -horizontalScrollBarThickness 0 scrollLayout; columnLayout -adjustableColumn true hardwareTabColumn; setUITemplate -pushTemplate attributeEditorTemplate; // Hardware Render Quality // frameLayout -label (uiRes("m_createMayaHardwareGlobalsTab.kQuality")) -collapsable true -collapse false hwQualityFrame; createHardwareRenderQuality ("hwQualityFrame"); setParent ..; // Hardware Render Options // frameLayout -label (uiRes("m_createMayaHardwareGlobalsTab.kRenderOptions")) -collapsable true -collapse false hwRenderOptionsFrame; createHardwareRenderOptionsFrame ("hwRenderOptionsFrame"); setParent ..; setUITemplate -popTemplate; setParent ..; setParent ..; setParent ..; setParent ..; formLayout -edit -af scrollLayout "top" 0 -af scrollLayout "bottom" 0 -af scrollLayout "left" 0 -af scrollLayout "right" 0 $parentForm; updateHardwareQualityPresetMenu(); } // Description: // Update the "Culling Threshold" enabling based // on "Small Object Cullling" toggle // global proc updateMayaHardwareObjectCulling() { string $oldParent = `setParent -query`; setParentToHardwareTab(); attrControlGrp -edit -enable `getAttr "hardwareRenderGlobals.smallObjectCulling"` mayaHardwareCullingThreshold; setParent $oldParent; } // Description: // This procedure is called to update the "Motion Blur" frame. // in the "Hardware" tab in the unified render globals window. // global proc updateMayaHardwareMotionBlur() { string $oldParent = `setParent -query`; setParentToHardwareTab(); attrControlGrp -edit -enable `getAttr "hardwareRenderGlobals.enableMotionBlur"` mayaHardwareMotionBlurByFrame; attrControlGrp -edit -enable `getAttr "hardwareRenderGlobals.enableMotionBlur"` mayaHardwareNumberOfExposures; setParent $oldParent; } // Description: // This procedure is called to create the "Render Quality" // frame in the "Hardware" tab in the unified render globals window. // global proc createHardwareRenderQuality (string $parent) { setUITemplate -pushTemplate attributeEditorTemplate; setParentToHardwareTab(); setParent $parent; columnLayout -adjustableColumn true; createHardwareQualityPresetMenu(); // High Quality Lighting // attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kHighQualityLighting")) -attribute "hardwareRenderGlobals.enableHighQualityLighting" -cc " updateHardwareQualityPresetMenu"; // Accelerated multi-sampling (for hardware anti-aliasing) // attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kAcceleratedMultiSampling")) -attribute "hardwareRenderGlobals.enableAcceleratedMultiSampling" -cc " updateHardwareQualityPresetMenu"; attrControlGrp -attribute "hardwareRenderGlobals.numberOfSamples" -cc "updateHardwareQualityPresetMenu"; // hardwareNumberOfSamples; separator; // Frame buffer Quality attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kFrameBufferFormat")) -attribute "hardwareRenderGlobals.frameBufferFormat" -cc "updateHardwareQualityPresetMenu"; // Transparency Quality // attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kTransparentShadowMaps")) -attribute "hardwareRenderGlobals.transparentShadowCasting"; rowLayout -numberOfColumns 2; text -label (uiRes("m_createMayaHardwareGlobalsTab.kTransparenySorting")) hardwareTransparencySortingLabel; optionMenu -cc "hardwareTransparencySortingMenuChanged" hardwareTransparencySortingMenu; menuItem -label (uiRes("m_createMayaHardwareGlobalsTab.kPerObject")) -data 0; menuItem -label (uiRes("m_createMayaHardwareGlobalsTab.kPerPolygon")) -data 1; // connect the label, so we can change its color connectControl hardwareTransparencySortingLabel hardwareRenderGlobals.transparencySorting; // connect the menu, so it will always match the attribute connectControl hardwareTransparencySortingMenu hardwareRenderGlobals.transparencySorting; updateHardwareTransparencySortingMenu(); scriptJob -p hardwareTransparencySortingMenu -ac "hardwareRenderGlobals.transparencySorting" updateHardwareTransparencySortingMenu; setParent ..; // from rowLayout separator; // Texture Quality // attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kColorResolution")) -attribute "hardwareRenderGlobals.colorTextureResolution" -cc "updateHardwareQualityPresetMenu"; attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kBumpResolution")) -attribute "hardwareRenderGlobals.bumpTextureResolution" -cc "updateHardwareQualityPresetMenu"; attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kTextureCompression")) -attribute "hardwareRenderGlobals.textureCompression"; attrControlGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kNonPowerOfTwoTexture")) -attribute "hardwareRenderGlobals.enableNonPowerOfTwoTexture"; setParent ..; setUITemplate -popTemplate; } global proc updateHardwareTransparencySortingMenu() { string $oldParent = `setParent -query`; setParentToHardwareTab(); int $sorting = `getAttr hardwareRenderGlobals.transparencySorting`; $sorting++; optionMenu -edit -select $sorting hardwareTransparencySortingMenu; updateHardwareQualityPresetMenu; setParent $oldParent; } global proc hardwareTransparencySortingMenuChanged() { string $oldParent = `setParent -query`; setParentToHardwareTab(); int $sorting = `optionMenu -query -select hardwareTransparencySortingMenu`; $sorting--; setAttr hardwareRenderGlobals.transparencySorting $sorting; setParent $oldParent; } // Description: // Update procedure that is called whenever renderer is changed or // different layer is selected. // Must update any controls whose state may have changed // through another instance of the tab. // global proc updateMayaHardwareGlobalsTab() { updateMayaHardwareObjectCulling(); updateMayaHardwareMotionBlur(); updateHardwareQualityPresetMenu(); } // Description: // This procedure is called to create the "Quality Preset" menu in // the "Hardware" tab in the unified render globals window. // global proc createHardwareQualityPresetMenu() { optionMenuGrp -label (uiRes("m_createMayaHardwareGlobalsTab.kPresets")) hardwareQualityPresetMenu; optionMenuGrp -edit -cc hardwareSetDefaultQuality hardwareQualityPresetMenu; menuItem -label (uiRes("m_createMayaHardwareGlobalsTab.kCustom")) hardwareCustomQuality; menuItem -label (uiRes("m_createMayaHardwareGlobalsTab.kPreviewQuality")) hardwarePreviewQuality; menuItem -label (uiRes("m_createMayaHardwareGlobalsTab.kIntermediateQuality")) hardwareIntermediateQuality; menuItem -label (uiRes("m_createMayaHardwareGlobalsTab.kProductionQuality")) hardwareProductionQuality; menuItem -label (uiRes("m_createMayaHardwareGlobalsTab.kProductionQualityWithTransparency")) hardwareProdWithTransparency; } // Description: This procedure is called when a particular // quality preset is chosen in the render quality frame. // It sets some attributes according to the chosen quality preset. // global proc hardwareSetDefaultQuality () { string $oldParent = `setParent -query`; setParentToHardwareTab(); string $renderer = "mayaHardware"; string $globalsNodes[] = `renderer -query -globalsNodes $renderer`; string $curr = `optionMenuGrp -q -v hardwareQualityPresetMenu`; if ($curr == (uiRes("m_createMayaHardwareGlobalsTab.kPreviewQuality")) ) { setAttr ($globalsNodes[0] + ".enableHighQualityLighting") off; setAttr ($globalsNodes[0] + ".enableAcceleratedMultiSampling") off; setAttr ($globalsNodes[0] + ".enableEdgeAntiAliasing") off; // M6 to be removed setAttr ($globalsNodes[0] + ".numberOfSamples") 1; setAttr ($globalsNodes[0] + ".colorTextureResolution") 128; setAttr ($globalsNodes[0] + ".bumpTextureResolution") 256; setAttr ($globalsNodes[0] + ".transparencySorting") 0; } else if ($curr == (uiRes("m_createMayaHardwareGlobalsTab.kIntermediateQuality")) ) { setAttr ($globalsNodes[0] + ".enableHighQualityLighting") on; setAttr ($globalsNodes[0] + ".enableAcceleratedMultiSampling") on; setAttr ($globalsNodes[0] + ".enableEdgeAntiAliasing") on; // M6 to be removed setAttr ($globalsNodes[0] + ".numberOfSamples") 1; setAttr ($globalsNodes[0] + ".colorTextureResolution") 256; setAttr ($globalsNodes[0] + ".bumpTextureResolution") 512; setAttr ($globalsNodes[0] + ".transparencySorting") 0; } else if ($curr == (uiRes("m_createMayaHardwareGlobalsTab.kProductionQuality")) ) { setAttr ($globalsNodes[0] + ".enableHighQualityLighting") on; setAttr ($globalsNodes[0] + ".enableAcceleratedMultiSampling") on; setAttr ($globalsNodes[0] + ".enableEdgeAntiAliasing") on; // M6 to be removed setAttr ($globalsNodes[0] + ".numberOfSamples") 9; setAttr ($globalsNodes[0] + ".colorTextureResolution") 512; setAttr ($globalsNodes[0] + ".bumpTextureResolution") 1024; setAttr ($globalsNodes[0] + ".transparencySorting") 0; } else if ($curr == (uiRes("m_createMayaHardwareGlobalsTab.kProductionQualityWithTransparency")) ) { setAttr ($globalsNodes[0] + ".enableHighQualityLighting") on; setAttr ($globalsNodes[0] + ".enableAcceleratedMultiSampling") on; setAttr ($globalsNodes[0] + ".enableEdgeAntiAliasing") on; // M6 to be removed setAttr ($globalsNodes[0] + ".numberOfSamples") 9; setAttr ($globalsNodes[0] + ".colorTextureResolution") 512; setAttr ($globalsNodes[0] + ".bumpTextureResolution") 1024; setAttr ($globalsNodes[0] + ".transparencySorting") 1; } else // Custom Quality { // WAITING for a bug fix for "enable" to work for attrControlGrp // for enum controls. // // attrControlGrp -edit -enable true hardwareNumberOfSamples; } // updateHardwareRenderQuality () setParent $oldParent; } // Description: This procedure is called to update the // "Quality Preset" menu in the "Hardware" tab in // the unified render globals window. // global proc updateHardwareQualityPresetMenu() { string $oldParent = `setParent -query`; setParentToHardwareTab(); string $renderer = "mayaHardware"; string $globalsNodes[] = `renderer -query -globalsNodes $renderer`; int $enableHighQualityLighting = `getAttr ($globalsNodes[0] + ".enableHighQualityLighting")`; int $enableAcceleratedMultiSampling= `getAttr ($globalsNodes[0] + ".enableAcceleratedMultiSampling")`; int $numberOfSamples = `getAttr ($globalsNodes[0] + ".numberOfSamples")`; int $colorTextureResolution = `getAttr ($globalsNodes[0] + ".colorTextureResolution")`; int $bumpTextureResolution = `getAttr ($globalsNodes[0] + ".bumpTextureResolution")`; int $transparencySorting = `getAttr ($globalsNodes[0] + ".transparencySorting")`; // See if the current settings of the 5 attributes we just queried // match any preset settings, and set the Presets menu state // accordingly // if ($enableHighQualityLighting == off && $enableAcceleratedMultiSampling == off && $numberOfSamples == 1 && $colorTextureResolution == 128 && $bumpTextureResolution == 256 && $transparencySorting == 0 ) { optionMenuGrp -edit -sl 2 hardwareQualityPresetMenu; // Preview Quality } else if ($enableHighQualityLighting == on && $enableAcceleratedMultiSampling == on && $numberOfSamples == 1 && $colorTextureResolution == 256 && $bumpTextureResolution == 512 && $transparencySorting == 0 ) { optionMenuGrp -edit -sl 3 hardwareQualityPresetMenu; // Intermediate Quality } else if ($enableHighQualityLighting == on && $enableAcceleratedMultiSampling == on && $numberOfSamples == 9 && $colorTextureResolution == 512 && $bumpTextureResolution == 1024 && $transparencySorting == 0 ) { optionMenuGrp -edit -sl 4 hardwareQualityPresetMenu; // Production Quality } else if ($enableHighQualityLighting == on && $enableAcceleratedMultiSampling == on && $numberOfSamples == 9 && $colorTextureResolution == 512 && $bumpTextureResolution == 1024 && $transparencySorting == 1 ) { optionMenuGrp -edit -sl 5 hardwareQualityPresetMenu; // Production Quality with Transparency } else { optionMenuGrp -edit -sl 1 hardwareQualityPresetMenu; // Custom } setParent $oldParent; }