本文整理汇总了C++中mhwrender::MRenderer::getFragmentManager方法的典型用法代码示例。如果您正苦于以下问题:C++ MRenderer::getFragmentManager方法的具体用法?C++ MRenderer::getFragmentManager怎么用?C++ MRenderer::getFragmentManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mhwrender::MRenderer
的用法示例。
在下文中一共展示了MRenderer::getFragmentManager方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MPxSurfaceShadingNodeOverride
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");
}
}
}
}
}
示例2: MPxShadingNodeOverride
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;
}
}
}
}
示例3: MPxSurfaceShadingNodeOverride
//.........这里部分代码省略.........
" </source>"
" <vertex_source><![CDATA["
"float idepthShaderPluginInterpolantFragment(float3 Pm, float4x4 worldViewProj) \n"
"{ \n"
" float4 pCamera = mul(float4(Pm, 1.0f), worldViewProj); \n"
" return (pCamera.z - pCamera.w*2.0f); \n"
"} \n]]>"
" </vertex_source>"
" </implementation>"
" <implementation render=\"OGSRenderer\" language=\"GLSL\" lang_version=\"3.0\">"
" <function_name val=\"depthShaderPluginInterpolantFragment\" />"
" <source><![CDATA["
"float depthShaderPluginInterpolantFragment(float depthValue) \n"
"{ \n"
" return depthValue; \n"
"} \n]]>"
" </source>"
" <vertex_source><![CDATA["
"float idepthShaderPluginInterpolantFragment(vec3 Pm, mat4 worldViewProj) \n"
"{ \n"
" vec4 pCamera = worldViewProj * vec4(Pm, 1.0f); \n"
" return (pCamera.z - pCamera.w*2.0f); \n"
"} \n]]>"
" </vertex_source>"
" </implementation>"
" </implementation>"
"</fragment>";
static const MString sFragmentGraphName("depthShaderPluginGraph");
static const char* sFragmentGraphBody =
"<fragment_graph name=\"depthShaderPluginGraph\" ref=\"depthShaderPluginGraph\" class=\"FragmentGraph\" version=\"1.0\">"
" <fragments>"
" <fragment_ref name=\"depthShaderPluginFragment\" ref=\"depthShaderPluginFragment\" />"
" <fragment_ref name=\"depthShaderPluginInterpolantFragment\" ref=\"depthShaderPluginInterpolantFragment\" />"
" </fragments>"
" <connections>"
" <connect from=\"depthShaderPluginInterpolantFragment.outDepthValue\" to=\"depthShaderPluginFragment.depthValue\" />"
" </connections>"
" <properties>"
" <float3 name=\"Pm\" ref=\"depthShaderPluginInterpolantFragment.Pm\" semantic=\"Pm\" flags=\"varyingInputParam\" />"
" <float4x4 name=\"worldViewProj\" ref=\"depthShaderPluginInterpolantFragment.worldViewProj\" semantic=\"worldviewprojection\" />"
" <float3 name=\"color\" ref=\"depthShaderPluginFragment.color\" />"
" <float3 name=\"colorFar\" ref=\"depthShaderPluginFragment.colorFar\" />"
" <float name=\"near\" ref=\"depthShaderPluginFragment.near\" />"
" <float name=\"far\" ref=\"depthShaderPluginFragment.far\" />"
" </properties>"
" <values>"
" <float3 name=\"color\" value=\"0.0,1.0,0.0\" />"
" <float3 name=\"colorFar\" value=\"0.0,0.0,1.0\" />"
" <float name=\"near\" value=\"0.0\" />"
" <float name=\"far\" value=\"2.0\" />"
" </values>"
" <outputs>"
" <float3 name=\"outColor\" ref=\"depthShaderPluginFragment.outColor\" />"
" </outputs>"
"</fragment_graph>";
// Register fragments with the manager if needed
MHWRender::MRenderer* theRenderer = MHWRender::MRenderer::theRenderer();
if (theRenderer)
{
MHWRender::MFragmentManager* fragmentMgr =
theRenderer->getFragmentManager();
if (fragmentMgr)
{
// Add fragments if needed
bool fragAdded = fragmentMgr->hasFragment(sFragmentName);
bool vertFragAdded = fragmentMgr->hasFragment(sVertexFragmentName);
bool graphAdded = fragmentMgr->hasFragment(sFragmentGraphName);
if (!fragAdded)
{
fragAdded = (sFragmentName == fragmentMgr->addShadeFragmentFromBuffer(sFragmentBody, false));
}
if (!vertFragAdded)
{
// In DirectX, need to specify a semantic for the output of the vertex shader
MString vertBody;
if (theRenderer->drawAPI() == MHWRender::kDirectX11)
{
vertBody.format(MString(sVertexFragmentBody), MString("semantic=\"extraDepth\" "));
}
else
{
vertBody.format(MString(sVertexFragmentBody), MString(" "));
}
vertFragAdded = (sVertexFragmentName == fragmentMgr->addShadeFragmentFromBuffer(vertBody.asChar(), false));
}
if (!graphAdded)
{
graphAdded = (sFragmentGraphName == fragmentMgr->addFragmentGraphFromBuffer(sFragmentGraphBody));
}
// If we have them all, use the final graph for the override
if (fragAdded && vertFragAdded && graphAdded)
{
fFragmentName = sFragmentGraphName;
}
}
}
}
示例4: MPxShadingNodeOverride
GammaOverride::GammaOverride(const MObject& obj)
: MPxShadingNodeOverride(obj)
, fFragmentName("")
{
// Define fragments needed for VP2 version of shader, this could also be
// defined in a separate XML file
//
// Define the input and output parameter names to match the input and
// output attribute names so that the values are automatically populated
// on the shader.
static const MString sFragmentName("gammaShaderPluginFragment");
static const char* sFragmentBody =
"<fragment uiName=\"gammaShaderPluginFragment\" name=\"gammaShaderPluginFragment\" type=\"plumbing\" class=\"ShadeFragment\" version=\"1.0\">"
" <description><![CDATA[Gamma utility fragment]]></description>"
" <properties>"
" <float3 name=\"color\" />"
" <float3 name=\"gamma\" />"
" </properties>"
" <values>"
" <float3 name=\"color\" value=\"0.5,0.5,0.5\" />"
" <float3 name=\"gamma\" value=\"1.0,1.0,1.0\" />"
" </values>"
" <outputs>"
" <float3 name=\"outColor\" />"
" </outputs>"
" <implementation>"
" <implementation render=\"OGSRenderer\" language=\"Cg\" lang_version=\"2.1\">"
" <function_name val=\"gammaShaderPluginFragment\" />"
" <source><![CDATA["
"float3 gammaShaderPluginFragment(float3 icol, float3 igam) \n"
"{ \n"
" float3 result; \n"
" result.r = pow(icol.r, 1.0f/igam.r); \n"
" result.g = pow(icol.g, 1.0f/igam.g); \n"
" result.b = pow(icol.b, 1.0f/igam.b); \n"
" return result; \n"
"} \n]]>"
" </source>"
" </implementation>"
" <implementation render=\"OGSRenderer\" language=\"HLSL\" lang_version=\"11.0\">"
" <function_name val=\"gammaShaderPluginFragment\" />"
" <source><![CDATA["
"float3 gammaShaderPluginFragment(float3 icol, float3 igam) \n"
"{ \n"
" float3 result; \n"
" result.r = pow(icol.r, 1.0f/igam.r); \n"
" result.g = pow(icol.g, 1.0f/igam.g); \n"
" result.b = pow(icol.b, 1.0f/igam.b); \n"
" return result; \n"
"} \n]]>"
" </source>"
" </implementation>"
" <implementation render=\"OGSRenderer\" language=\"GLSL\" lang_version=\"3.0\">"
" <function_name val=\"gammaShaderPluginFragment\" />"
" <source><![CDATA["
"vec3 gammaShaderPluginFragment(vec3 icol, vec3 igam) \n"
"{ \n"
" vec3 result; \n"
" result.r = pow(icol.r, 1.0f/igam.r); \n"
" result.g = pow(icol.g, 1.0f/igam.g); \n"
" result.b = pow(icol.b, 1.0f/igam.b); \n"
" return result; \n"
"} \n]]>"
" </source>"
" </implementation>"
" </implementation>"
"</fragment>";
// Register fragments with the manager if needed
MHWRender::MRenderer* theRenderer = MHWRender::MRenderer::theRenderer();
if (theRenderer)
{
MHWRender::MFragmentManager* fragmentMgr =
theRenderer->getFragmentManager();
if (fragmentMgr)
{
// Add fragments if needed
bool fragAdded = fragmentMgr->hasFragment(sFragmentName);
if (!fragAdded)
{
fragAdded = (sFragmentName == fragmentMgr->addShadeFragmentFromBuffer(sFragmentBody, false));
}
// Use the fragment on successful add
if (fragAdded)
{
fFragmentName = sFragmentName;
}
}
}
}