LightMaterialOverride::LightMaterialOverride(const MObject& obj) : MPxSurfaceShadingNodeOverride(obj) { MHWRender::MRenderer* theRenderer = MHWRender::MRenderer::theRenderer(); if (theRenderer) { MHWRender::MFragmentManager* fragmentMgr = theRenderer->getFragmentManager(); if (fragmentMgr) { for (uint i = 0; i < MayaTo::getWorldPtr()->shaderSearchPath.length(); i++) fragmentMgr->addFragmentPath(MayaTo::getWorldPtr()->shaderSearchPath[i]); MString fragment = "CoronaLight"; bool fragAdded = fragmentMgr->hasFragment(fragment); if (!fragAdded) { fragAdded = (fragment == fragmentMgr->addShadeFragmentFromFile(fragment + ".xml", false)); if (fragAdded) { MGlobal::displayInfo(MString("Successfully loaded fragment ") + fragment + ".xml"); } else{ MGlobal::displayInfo(MString("Could not load fragment ") + fragment + ".xml"); } } } } }
CheckerNodeOverride::CheckerNodeOverride(const MObject& obj) : MPxShadingNodeOverride(obj) , fFragmentName("") { // Fragments are defined in separate XML files, add the checker node // directory to the search path and load from the files. static const MString sFragmentName("checkerNodePluginFragment"); static const MString sFragmentOutputName("checkerNodePluginFragmentOutput"); static const MString sFragmentGraphName("checkerNodePluginGraph"); MHWRender::MRenderer* theRenderer = MHWRender::MRenderer::theRenderer(); if (theRenderer) { MHWRender::MFragmentManager* fragmentMgr = theRenderer->getFragmentManager(); if (fragmentMgr) { // Add search path (once only) static bool sAdded = false; if (!sAdded) { MString location; if( ! MGlobal::executeCommand(MString("getModulePath -moduleName \"devkit\""), location, false) ) { location = MString(getenv("MAYA_LOCATION")) + MString("/devkit"); } location += "/plug-ins/checkerShader"; fragmentMgr->addFragmentPath(location); sAdded = true; } // Add fragments if needed bool fragAdded = fragmentMgr->hasFragment(sFragmentName); bool structAdded = fragmentMgr->hasFragment(sFragmentOutputName); bool graphAdded = fragmentMgr->hasFragment(sFragmentGraphName); if (!fragAdded) { fragAdded = (sFragmentName == fragmentMgr->addShadeFragmentFromFile(sFragmentName + ".xml", false)); } if (!structAdded) { structAdded = (sFragmentOutputName == fragmentMgr->addShadeFragmentFromFile(sFragmentOutputName + ".xml", false)); } if (!graphAdded) { graphAdded = (sFragmentGraphName == fragmentMgr->addFragmentGraphFromFile(sFragmentGraphName + ".xml")); } // If we have them all, use the final graph for the override if (fragAdded && structAdded && graphAdded) { fFragmentName = sFragmentGraphName; } } } }