hi,
I follow the instruction of "V-Ray for Maya translator SDK" to try to make a simple VRay shader visiable in maya's hypershade but it not works.
This is my VRay plugin code:
TexInputTypeTest_VC11.cpp
and the corresponding maya plugin as follows:
VRayInputTypeTestNode.h
VRayInputTypeTestNode.cpp
pluginMain.cpp
Both plugins are successfully compiled (with just some warning about DLL exporting) and the produced files are named "vray_TexInputTypeTest.dll" and "VRayInputTypeTest.mll". I put both of them in the same folder and set a desc.txt with content like this:
Then set "MAYA_PLUG_IN_PATH" environment variable to the path that plugin files reside. I think that's all i have to do to make my shader appear in maya's hypershade but it not. Do i miss anything ? (I also try to compile the blinn material in the maya plugin example folder but it also not work at all)
I follow the instruction of "V-Ray for Maya translator SDK" to try to make a simple VRay shader visiable in maya's hypershade but it not works.
This is my VRay plugin code:
TexInputTypeTest_VC11.cpp
Code:
#include "vrayplugins.h" #include "vrayinterface.h" #include "vrayrenderer.h" #include "vraytexutils.h" #include "meshinfobase.h" #include "meshinfointerface.h" #include "globalnewdelete.cpp" // Prevent from "to tchar*" conversion warning ... #if (defined __GNUC__) && !(defined __clang__) #pragma GCC diagnostic ignored "-Wwrite-strings" #endif //(defined __GNUC__) && !(defined __clang__) using namespace VR; // Parameters struct TexInputTypeTest_Params: VRayParameterListDesc { TexInputTypeTest_Params(void) { addParamInt("int", 0, -1); } }; struct TexInputTypeTest: VRayTexture { TexInputTypeTest(VRayPluginDesc *pluginDesc):VRayTexture(pluginDesc) { // Set parameter caches paramList->setParamCache("int", &int_val); } AColor getTexColor(const VRayContext &rc); void getTexColorBounds(AColor &cmin, AColor &cmax); Vector getColorBumpGradient(const VRayContext &rc); virtual PluginInterface* newInterface(InterfaceID id) { return VRayTexture::newInterface(id); } // VRayTexture Member function PluginBase* getPlugin(void) { return static_cast<PluginBase*>(this); } // These pure virtual functions have to be implemented if support RTTexInterface //int getDataSize(void) { return 0; } //void getData(float *fdata) { } //int getSource(const char *part,const char *outParam,const char *lang,VUtils::ShaderSource &, OCLData &mtlData); private: int int_val; }; #define TexInputTypeTest_PluginID PluginID(LARGE_CONST(2004711829)) SIMPLE_PLUGIN_LIBRARY(TexInputTypeTest_PluginID, EXT_TEXTURE, "TexInputTypeTest", "Test curious input type of VRay plugin", TexInputTypeTest, TexInputTypeTest_Params); AColor TexInputTypeTest::getTexColor(const VRayContext &rc) { return AColor(0.0f, 0.0f, 0.0f, 1.0f); } void TexInputTypeTest::getTexColorBounds(AColor &cmin, AColor &cmax) { cmin = AColor(0.0f, 0.0f, 0.0f, 1.0f); cmax = AColor(1.0f, 1.0f, 1.0f, 1.0f); } Vector TexInputTypeTest::getColorBumpGradient(const VRayContext &rc) { return Vector(0.0f, 0.0f, 0.0f); }
and the corresponding maya plugin as follows:
VRayInputTypeTestNode.h
Code:
#ifndef _VRayInputTypeTestNode #define _VRayInputTypeTestNode #include <maya/MPxNode.h> #include <maya/MFnNumericAttribute.h> #include <maya/MTypeId.h> class VRayInputTypeTest : public MPxNode { public: VRayInputTypeTest(); virtual ~VRayInputTypeTest(); virtual MStatus compute(const MPlug& plug, MDataBlock& data); static void* creator(); static MStatus initialize(); static MTypeId id; static MString apiType; static MString classification; private: // Input Attributes static MObject m_Int; // Output Attributes static MObject m_OutColor; static MObject m_OutAPIType; static MObject m_OutAPIClassification; }; #endif
VRayInputTypeTestNode.cpp
Code:
#include <maya/MPlug.h> #include <maya/MDataBlock.h> #include <maya/MDataHandle.h> #include <maya/MGlobal.h> #include <maya/MFnTypedAttribute.h> #include <maya/MFnStringData.h> // V-Ray headers #include "vraybase.h" #include "vrayplugins.h" #include "VRayInputTypeTestNode.h" MTypeId VRayInputTypeTest::id(0x002104F1); MString VRayInputTypeTest::classification("shader/surface/utility/:swatch/VRayMtlSwatchGen"); MObject VRayInputTypeTest::m_Int; MObject VRayInputTypeTest::m_OutColor; MObject VRayInputTypeTest::m_OutAPIType; MObject VRayInputTypeTest::m_OutAPIClassification; VRayInputTypeTest::VRayInputTypeTest() {} VRayInputTypeTest::~VRayInputTypeTest() {} MStatus VRayInputTypeTest::compute( const MPlug& plug, MDataBlock& data ) { return MS::kSuccess; } void* VRayInputTypeTest::creator() { return new VRayInputTypeTest(); } MStatus VRayInputTypeTest::initialize() { MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnStringData strData; MStatus stat; // Create input attributes m_Int = nAttr.createColor("Int", "mit"); CHECK_MSTATUS(nAttr.setKeyable(false)); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(true)); // Create output attributes m_OutColor = nAttr.createColor("OutColor", "oc"); CHECK_MSTATUS(nAttr.setKeyable(false)); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); //strData.create(VRayInputTypeTest::m_OutAPIType); // Error ??? m_OutAPIType = tAttr.create("OutAPIType", "oat", MFnData::kString, strData.object()); CHECK_MSTATUS(tAttr.setStorable(true)); CHECK_MSTATUS(tAttr.setKeyable(false)); CHECK_MSTATUS(tAttr.setHidden(true)); //strData.create(VRayInputTypeTest::m_OutAPIClassification); m_OutAPIClassification = tAttr.create("OutAPIClassification", "oac", MFnData::kString, strData.object()); CHECK_MSTATUS(tAttr.setStorable(true)); CHECK_MSTATUS(tAttr.setKeyable(false)); CHECK_MSTATUS(tAttr.setHidden(true)); // Add the attributes CHECK_MSTATUS(addAttribute(m_Int)); CHECK_MSTATUS(addAttribute(m_OutColor)); CHECK_MSTATUS(addAttribute(m_OutAPIType)); CHECK_MSTATUS(addAttribute(m_OutAPIClassification)); return MS::kSuccess; }
pluginMain.cpp
Code:
#include "defines.h" #ifdef X64 #define Bits64_ #endif #include "VRayInputTypeTestNode.h" #include <maya/MFnPlugin.h> #include <maya/MGlobal.h> MStatus initializePlugin(MObject obj) { MStatus status; MString errStr; MFnPlugin plugin(obj, "Seila", "1.0", "Any"); if (!status) { MGlobal::displayInfo("Could not initialize MFnPlugin\n"); errStr = "Failed to initialize plugin"; status.perror(errStr); } // Register the VRayInputTypeTest node const MString classification(VRayInputTypeTest::classification); status = plugin.registerNode("VRayInputTypeTest", VRayInputTypeTest::id, VRayInputTypeTest::creator, VRayInputTypeTest::initialize, MPxNode::kDependNode, &classification); if (!status) { errStr = "RegisterNode failed"; status.perror(errStr); } return status; } MStatus uninitializePlugin(MObject obj) { MStatus status; MString errStr; MFnPlugin plugin(obj); // Deregister the VRayInputTypeTest node status = plugin.deregisterNode(VRayInputTypeTest::id); if (!status) { status.perror("Deregister Node Failed"); } return status; }
Code:
TexInputTypeTest VRayInputTypeTest { "int" number "Int" number INPUT "" texture "OutColor" texture OUTPUT }
Comment