#include <maya/MIOStream.h>
#include <maya/MPxNode.h>
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MArrayDataHandle.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnLightDataAttribute.h>
#include <maya/MFloatVector.h>
#include <maya/MFnPlugin.h>
#include <maya/MGlobal.h>
#include <maya/MDrawRegistry.h>
#include "lambertShaderOverride.h"
{
public:
lambert();
~lambert() override;
static void * creator();
SchedulingType
schedulingType()
const override {
return SchedulingType::kParallel; }
protected:
static MObject aDiffuseReflectivity;
static MObject aLightShadowFraction;
static MObject aPreShadowIntensity;
};
MObject lambert::aTranslucenceCoeff;
MObject lambert::aDiffuseReflectivity;
MObject lambert::aLightShadowFraction;
MObject lambert::aPreShadowIntensity;
lambert::lambert() { }
lambert::~lambert() { }
void* lambert::creator()
{
return new lambert();
}
{
aTranslucenceCoeff = nAttr.
create(
"translucenceCoeff",
"tc",
aDiffuseReflectivity = nAttr.
create(
"diffuseReflectivity",
"drfl",
&status );
&status );
&status );
aColor = nAttr.
create(
"color",
"c", aColorR, aColorG, aColorB,
&status );
aIncandescenceR = nAttr.
create(
"incandescenceR",
"ir",
aIncandescenceG = nAttr.
create(
"incandescenceG",
"ig",
aIncandescenceB = nAttr.
create(
"incandescenceB",
"ib",
aIncandescence = nAttr.
create(
"incandescence",
"ic", aIncandescenceR,
aIncandescenceG, aIncandescenceB, &status );
aInTransR = nAttr.
create(
"transparencyR",
"itr",
aInTransG = nAttr.
create(
"transparencyG",
"itg",
aInTransB = nAttr.
create(
"transparencyB",
"itb",
aInTransparency = nAttr.
create(
"transparency",
"it", aInTransR,
aInTransG, aInTransB, &status );
0, &status );
0, &status );
0, &status );
aOutColor = nAttr.
create(
"outColor",
"oc", aOutColorR, aOutColorG,
aOutColorB, &status );
aOutTransR = nAttr.
create(
"outTransparencyR",
"otr",
aOutTransG = nAttr.
create(
"outTransparencyG",
"otg",
aOutTransB = nAttr.
create(
"outTransparencyB",
"otb",
aOutTransparency = nAttr.
create(
"outTransparency",
"ot",
aOutTransR,aOutTransG,aOutTransB, &status );
aNormalCameraX = nAttr.
create(
"normalCameraX",
"nx",
aNormalCameraY = nAttr.
create(
"normalCameraY",
"ny",
aNormalCameraZ = nAttr.
create(
"normalCameraZ",
"nz",
aNormalCamera = nAttr.
create(
"normalCamera",
"n", aNormalCameraX,
aNormalCameraY, aNormalCameraZ, &status );
aLightDirectionX = nAttr.
create(
"lightDirectionX",
"ldx",
aLightDirectionY = nAttr.
create(
"lightDirectionY",
"ldy",
aLightDirectionZ = nAttr.
create(
"lightDirectionZ",
"ldz",
aLightDirection = nAttr.
create(
"lightDirection",
"ld",
aLightDirectionX, aLightDirectionY, aLightDirectionZ,
&status );
aLightIntensityR = nAttr.
create(
"lightIntensityR",
"lir",
aLightIntensityG = nAttr.
create(
"lightIntensityG",
"lig",
aLightIntensityB = nAttr.
create(
"lightIntensityB",
"lib",
aLightIntensity = nAttr.
create(
"lightIntensity",
"li",
aLightIntensityR, aLightIntensityG, aLightIntensityB,
&status );
aLightAmbient = nAttr.
create(
"lightAmbient",
"la",
aLightDiffuse = nAttr.
create(
"lightDiffuse",
"ldf",
aLightSpecular = nAttr.
create(
"lightSpecular",
"ls",
aLightShadowFraction = nAttr.
create(
"lightShadowFraction",
"lsf",
aPreShadowIntensity = nAttr.
create(
"preShadowIntensity",
"psi",
aLightBlindData = nAttr.
createAddr(
"lightBlindData",
"lbld",
&status );
aLightData = lAttr.
create(
"lightDataArray",
"ltd", aLightDirection,
aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular,
aLightShadowFraction, aPreShadowIntensity, aLightBlindData,
&status );
true, true, false, 1.0f, 1.0f, NULL ) );
CHECK_MSTATUS( attributeAffects( aTranslucenceCoeff, aOutColor ) );
CHECK_MSTATUS( attributeAffects( aDiffuseReflectivity, aOutColor ) );
CHECK_MSTATUS( attributeAffects( aInTransR, aOutTransparency ) );
CHECK_MSTATUS( attributeAffects( aInTransG, aOutTransparency ) );
CHECK_MSTATUS( attributeAffects( aInTransB, aOutTransparency ) );
CHECK_MSTATUS( attributeAffects( aInTransparency, aOutTransparency ) );
CHECK_MSTATUS( attributeAffects( aLightIntensityR, aOutColor ) );
CHECK_MSTATUS( attributeAffects( aLightIntensityB, aOutColor ) );
CHECK_MSTATUS( attributeAffects( aLightIntensityG, aOutColor ) );
CHECK_MSTATUS( attributeAffects( aLightDirectionX, aOutColor ) );
CHECK_MSTATUS( attributeAffects( aLightDirectionY, aOutColor ) );
CHECK_MSTATUS( attributeAffects( aLightDirectionZ, aOutColor ) );
CHECK_MSTATUS( attributeAffects( aLightShadowFraction, aOutColor ) );
CHECK_MSTATUS( attributeAffects( aPreShadowIntensity, aOutColor ) );
return( MS::kSuccess );
}
{
if( plug == aOutColor
|| plug == aOutColorR
|| plug == aOutColorG
|| plug == aOutColorB
|| plug == aOutTransparency
|| plug == aOutTransR
|| plug == aOutTransG
|| plug == aOutTransB )
{
aDiffuseReflectivity, &status ).
asFloat();
&status );
for( int count=1; count <= numLights; count++ )
{
{
resultColor += lightIntensity;
}
{
float cosln = lightDirection * surfaceNormal;
if ( cosln > 0.0f ) {
resultColor += lightIntensity
* ( cosln * diffuseReflectivity );
}
}
if ( count < numLights ) {
status = lightData.
next();
}
}
resultColor[0] = resultColor[0] * surfaceColor[0] + incandescence[0];
resultColor[1] = resultColor[1] * surfaceColor[1] + incandescence[1];
resultColor[2] = resultColor[2] * surfaceColor[2] + incandescence[2];
if ( plug == aOutColor || plug == aOutColorR || plug == aOutColorG
|| plug == aOutColorB)
{
&status );
outColor = resultColor;
}
if ( plug == aOutTransparency || plug == aOutTransR
|| plug == aOutTransG || plug == aOutTransB )
{
aOutTransparency, &status );
outTrans = transparency;
}
}
else
{
return( MS::kUnknownParameter );
}
return( MS::kSuccess );
}
static const MString sRegistrantId(
"lambertShaderPlugin");
static const MString sDrawDBClassification(
"drawdb/shader/surface/lambertShader");
static const MString sFullClassification(
"shader/surface:" + sDrawDBClassification);
{
MString command(
"if( `window -exists createRenderNodeWindow` ) {refreshCreateRenderNodeWindow(\"" );
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"4.5",
"Any" );
CHECK_MSTATUS( plugin.registerNode(
"lambertShader", lambert::id,
&sFullClassification ) );
sDrawDBClassification,
sRegistrantId,
lambertShaderOverride::creator));
command += sFullClassification;
command += "\");}\n";
return( MS::kSuccess );
}
{
const MString sFullClassification(
"shader/surface:drawdb/shader/surface/lambertShader" );
MString command(
"if( `window -exists createRenderNodeWindow` ) {refreshCreateRenderNodeWindow(\"" );
sDrawDBClassification, sRegistrantId));
command += sFullClassification;
command += "\");}\n";
return MS::kSuccess;
}