
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have created my own custom shader inheriting from MPxHwShaderNode -- and the virtual functions geometry / glGeometry never get called. -- However the compute virtual function does get called.
How do I get these geometry/glGeometry functions to get called?
Here is a snippet of the header file:
class HwShader : public MPxHwShaderNode
{
public:
void postConstructor() override;
MStatus compute(const MPlug&, MDataBlock&) override;
MStatus glGeometry(const MDagPath& shapePath,
int glPrim, unsigned int writeMask, int indexCount, const unsigned int* indexArray, int vertexCount, const int * vertexIDs, const float * vertexArray, int normalCount, floatArrayPtr normalArrays, int colorCount, floatArrayPtr colorArrays, int texCoordCount, floatArrayPtr texCoordArrays) override;
MStatus geometry(const MDrawRequest& request, M3dView& view, int prim, unsigned int writable, int indexCount, const unsigned int * indexArray, int vertexCount, const int * vertexIDs, const float * vertexArray, int normalCount, floatArrayPtr normalArrays, int colorCount, floatArrayPtr colorArrays, int texCoordCount, floatArrayPtr texCoordArrays) override;
int colorsPerVertex() override;
int normalsPerVertex() override;
int texCoordsPerVertex() override;
bool hasTransparency() override;
bool provideVertexIDs() override;
static void* creator();
static MStatus initialize();
MStatus bind(const MDrawRequest &request, M3dView &view) override;
MStatus unbind(const MDrawRequest &request, M3dView &view) override;
MStatus glBind(const MDagPath& path) override;
MStatus glUnbind(const MDagPath& path) override;
const static MTypeId typeId;
const static MString typeName;
};
//Snippet of initialize plugin
MStatus initializePlugin(MObject obj)
{
MStatus status;
MFnPlugin shaderPlugin(obj, "Shader");
// a classification for where the node will appear on the create menus
// of the multilister and hypershade.
const MString UserClassify("shader/surface/utility");
shaderPlugin.registerDragAndDropBehavior(ShaderBehavior::typeName, IugoShaderBehavior::creator);
status = shaderPlugin.registerNode(HwShader::typeName, HwShader::typeId, HwShader::creator, HwShader::initialize, MPxNode::Type::kHwShaderNode, &UserClassify);
}
Solved! Go to Solution.