#include "phongShaderOverride.h"
#include <maya/MFnDependencyNode.h>
#include <maya/MShaderManager.h>
{
return new phongShaderOverride(obj);
}
phongShaderOverride::phongShaderOverride(
const MObject& obj)
: MPxSurfaceShadingNodeOverride(obj)
, fObject(obj)
, fResolvedSpecularColorName("")
{
fSpecularColor[0] = 0.5f;
fSpecularColor[1] = 0.5f;
fSpecularColor[2] = 0.5f;
}
phongShaderOverride::~phongShaderOverride()
{
}
MHWRender::DrawAPI phongShaderOverride::supportedDrawAPIs() const
{
return MHWRender::kOpenGL | MHWRender::kDirectX11 | MHWRender::kOpenGLCoreProfile;
}
MString phongShaderOverride::fragmentName()
const
{
fResolvedSpecularColorName = "";
return "mayaPhongSurface";
}
void phongShaderOverride::getCustomMappings(
{
"diffuse", "diffuseReflectivity", true, true);
mappings.
append(diffuseMapping);
"translucence", "translucenceCoeff", true, true);
mappings.
append(translucenceMapping);
"reflectivity", "reflectionGain", true, true);
mappings.
append(reflectivityMapping);
"cosinePower", "power", true, true);
mappings.
append(powerMapping);
"specularColor", "", true, true);
mappings.
append(specColMapping);
}
MString phongShaderOverride::primaryColorParameter()
const
{
return "color";
}
MString phongShaderOverride::bumpAttribute()
const
{
return "normalCamera";
}
void phongShaderOverride::updateDG()
{
if (status)
{
float specularity = 0.5f;
node.findPlug("specularity", true).getValue(specularity);
fSpecularColor[0] = specularity;
fSpecularColor[1] = specularity;
fSpecularColor[2] = specularity;
}
}
void phongShaderOverride::updateShader(
{
if (fResolvedSpecularColorName.length() == 0)
{
if (mapping)
{
}
}
if (fResolvedSpecularColorName.length() > 0)
{
shader.
setParameter(fResolvedSpecularColorName, fSpecularColor);
}
}