visjes
01-26-2011, 11:44 PM
:banghead:
Hello,
I have a deformer and a hardware shader and I want to pass a per-vertex value from one to the other. I've tried doing this via colorSet, which was a disastrous mess as any attempts to update colorSets from compute()/deform() just fail, and trying to manage which colorSet is used is also prone to disaster, i.e. trying to create a specific colorSet if it doesn't exist ends up sticking history nodes (even with history off) between the deformer and the mesh so the deformer never sees them anyway. That's the result anyway, if it's done oustide of compute().. inside compute() it just fails silently.
Another thing I tried was just to generate a float array myself and pass it via a plug as a kAddr, but any attempts to query that value from the MPxHwShaderNode::glGeometry just returns zero. I know that sucks because the shader could be applied to multiple meshes, and there's no guarantee that the pointer I'm given matches the geometry I'm being asked to render, etc. I'm just trying anything to get it to work. Maybe I am doing that wrong. Below is what should be the relevant code:
deformer::initialize
a_vertexDataPointer = na.createAddr( "vertexDataPointer", "vdp" );
na.setReadable( true );
na.setWritable( false );
na.setStorable( false );
na.setCached( false );
addAttribute( a_vertexDataPointer );deformer::compute
// float * m_vertexData;
if( plug == a_vertexDataPointer )
{
MDataHandle vdp_data = data.outputValue( a_vertexDataPointer );
vdp_data.asAddr() = (void *)m_vertexData;
vdp_data.setClean();
}hardwareshader::glGeometry
MPlug plug( thisMObject(), a_vertexData );
// now what? asInt()? there's no method for getting value as address..
float * addr = (float *)plug.asInt(); // returns 0This is pretty flakey, but at least if I can manage to get ahold of that pointer, I can reference the correct weight values via the vertexIDs passed to glGeometry, which are aligned with with the vertex position array. For what it's worth, it seems that compute() is never ever called for the vertexDataPointer plug in the deformer. Am I missing something or is there a scheme I'm just overlooking? Does blind data make any sense in this context? I don't see a way for it to follow the vertex data passed to hardware shaders. Any help on this will help to reduce the overall level of anxiety and frustration in the universe. :)
Thanks.
Hello,
I have a deformer and a hardware shader and I want to pass a per-vertex value from one to the other. I've tried doing this via colorSet, which was a disastrous mess as any attempts to update colorSets from compute()/deform() just fail, and trying to manage which colorSet is used is also prone to disaster, i.e. trying to create a specific colorSet if it doesn't exist ends up sticking history nodes (even with history off) between the deformer and the mesh so the deformer never sees them anyway. That's the result anyway, if it's done oustide of compute().. inside compute() it just fails silently.
Another thing I tried was just to generate a float array myself and pass it via a plug as a kAddr, but any attempts to query that value from the MPxHwShaderNode::glGeometry just returns zero. I know that sucks because the shader could be applied to multiple meshes, and there's no guarantee that the pointer I'm given matches the geometry I'm being asked to render, etc. I'm just trying anything to get it to work. Maybe I am doing that wrong. Below is what should be the relevant code:
deformer::initialize
a_vertexDataPointer = na.createAddr( "vertexDataPointer", "vdp" );
na.setReadable( true );
na.setWritable( false );
na.setStorable( false );
na.setCached( false );
addAttribute( a_vertexDataPointer );deformer::compute
// float * m_vertexData;
if( plug == a_vertexDataPointer )
{
MDataHandle vdp_data = data.outputValue( a_vertexDataPointer );
vdp_data.asAddr() = (void *)m_vertexData;
vdp_data.setClean();
}hardwareshader::glGeometry
MPlug plug( thisMObject(), a_vertexData );
// now what? asInt()? there's no method for getting value as address..
float * addr = (float *)plug.asInt(); // returns 0This is pretty flakey, but at least if I can manage to get ahold of that pointer, I can reference the correct weight values via the vertexIDs passed to glGeometry, which are aligned with with the vertex position array. For what it's worth, it seems that compute() is never ever called for the vertexDataPointer plug in the deformer. Am I missing something or is there a scheme I'm just overlooking? Does blind data make any sense in this context? I don't see a way for it to follow the vertex data passed to hardware shaders. Any help on this will help to reduce the overall level of anxiety and frustration in the universe. :)
Thanks.
