lambertShader/lambertShaderOverride.cpp

lambertShader/lambertShaderOverride.cpp
//-
// ===========================================================================
// Copyright 2015 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.
// ===========================================================================
//+
#include "lambertShaderOverride.h"
MHWRender::MPxSurfaceShadingNodeOverride* lambertShaderOverride::creator(const MObject& obj)
{
return new lambertShaderOverride(obj);
}
lambertShaderOverride::lambertShaderOverride(const MObject& obj)
: MPxSurfaceShadingNodeOverride(obj)
{
}
lambertShaderOverride::~lambertShaderOverride()
{
}
MHWRender::DrawAPI lambertShaderOverride::supportedDrawAPIs() const
{
// works in both gl and dx
}
MString lambertShaderOverride::fragmentName() const
{
// Just reuse Maya's lambert surface shader
return "mayaLambertSurface";
}
void lambertShaderOverride::getCustomMappings(
{
// The "color", "transparency" and "incandescence" attributes are all
// named the same as the corresponding parameters on the fragment so they
// will map automatically. Need to remap diffuseReflectivity and
// translucence though
"diffuse", "diffuseReflectivity", true, true);
mappings.append(diffuseMapping);
"translucence", "translucenceCoeff", true, true);
mappings.append(translucenceMapping);
}
MString lambertShaderOverride::primaryColorParameter() const
{
// Use the color parameter from the lambert fragment as the primary color
return "color";
}
MString lambertShaderOverride::transparencyParameter() const
{
// Use the "transparency" parameter from the lambert fragment for transparency
return "transparency";
}
MString lambertShaderOverride::bumpAttribute() const
{
// Use the "normalCamera" attribute to recognize bump connections
return "normalCamera";
}