lecopivo
12-10-2011, 08:57 PM
Hello,
I'm really confused with DG evaluation. I wrote simple shading node but i doesnt work as I expected. The node gets value "pointWorld" from shading engine. It sends this value to another node. There it gets modified and then gets value back. Now I want to use this modified value to determine output color.
Problem is that DG is not updated and I get zeros. What is even stranger that the shader works as I want in viewport but not in render. And one more thing that if I don't let shading engine send "pointWorld" value to my node but I enter it manualy by myself I get right answer.
So I'll describe how I did it:
I have node with four attributes:
pointWorld...input...shading engine feeds this attrubute with location where it wants to know color
sampleOrg...output...just copy pointWorld value to the sampleOrg
sampleDef...input....from here I get modified value of sampleOrg
outColor...output...color
//attribute dependencies
attributeAffect(pointWorld,sampleOrg)
attributeAffect(sampleDef,outColor)
//external connections
sampleOrg affects sampleDef through connection in DG
and my compute function looks like this:
MStatus textureDef::compute( const MPlug& plug, MDataBlock& data )
{
if(plug == outColor) {
MDataHandle inputHandle = data.inputValue( sampleDef );
float* s = inputHandle.asFloat3();
MDataHandle outputHandle = data.outputValue( outColor );
outputHandle.set3Float(s[0],s[1],s[2]);
data.setClean(plug);
return MS::kSuccess;
}
if(plug == sampleOrg){
MDataHandle inputHandle = data.inputValue( pointWorld );
float* s = inputHandle.asFloat3();
MDataHandle outputHandle = data.outputValue( sampleOrg );
outputHandle.set3Float(s[0],s[1],s[2]);
data.setClean(plug);
return MS::kSuccess;
}
return MS::kUnknownParameter;
}
I would be most gratefull for any help!!!
I'm really confused with DG evaluation. I wrote simple shading node but i doesnt work as I expected. The node gets value "pointWorld" from shading engine. It sends this value to another node. There it gets modified and then gets value back. Now I want to use this modified value to determine output color.
Problem is that DG is not updated and I get zeros. What is even stranger that the shader works as I want in viewport but not in render. And one more thing that if I don't let shading engine send "pointWorld" value to my node but I enter it manualy by myself I get right answer.
So I'll describe how I did it:
I have node with four attributes:
pointWorld...input...shading engine feeds this attrubute with location where it wants to know color
sampleOrg...output...just copy pointWorld value to the sampleOrg
sampleDef...input....from here I get modified value of sampleOrg
outColor...output...color
//attribute dependencies
attributeAffect(pointWorld,sampleOrg)
attributeAffect(sampleDef,outColor)
//external connections
sampleOrg affects sampleDef through connection in DG
and my compute function looks like this:
MStatus textureDef::compute( const MPlug& plug, MDataBlock& data )
{
if(plug == outColor) {
MDataHandle inputHandle = data.inputValue( sampleDef );
float* s = inputHandle.asFloat3();
MDataHandle outputHandle = data.outputValue( outColor );
outputHandle.set3Float(s[0],s[1],s[2]);
data.setClean(plug);
return MS::kSuccess;
}
if(plug == sampleOrg){
MDataHandle inputHandle = data.inputValue( pointWorld );
float* s = inputHandle.asFloat3();
MDataHandle outputHandle = data.outputValue( sampleOrg );
outputHandle.set3Float(s[0],s[1],s[2]);
data.setClean(plug);
return MS::kSuccess;
}
return MS::kUnknownParameter;
}
I would be most gratefull for any help!!!
