Hi Roger, thanks for providing the test picture.
Unfortunately I've not being able to reproduce the issue with the test code below.
Could you kindly check the same code on your side and see how it behaves?
ObjectData::Modify()
Bool PC_11085_ObjectData::ModifyObject(BaseObject* mod, BaseDocument* doc, BaseObject* op, const Matrix& op_mg, const Matrix& mod_mg, Float lod, Int32 flags, BaseThread* thread)
{
if (!mod || !op || !doc || !thread)
return false;
// Retrieve the BaseContainer instance of the modifier.
BaseContainer *bcPtr = mod->GetDataInstance();
// // Retrieve the Object Manager parameters values.
const Bool useXbitmap = bcPtr->GetBool(PC11085_XBITMAP);
BaseList2D* const xBitmapBL = bcPtr->GetLink(PC11085_SHADERLINK, doc);
const String textureFilename = bcPtr->GetString(PC11085_TEXTURE);
// allocate and init the InitRenderStruct
InitRenderStruct irs(doc);
// check the color space
COLORSPACETRANSFORMATION transform = COLORSPACETRANSFORMATION_NONE;
// check if linear workflow is enabled
if (irs.linear_workflow)
transform = COLORSPACETRANSFORMATION_LINEAR_TO_SRGB;
if (xBitmapBL)
{
// cast to BaseShader
BaseShader* activeMatColorBS = (BaseShader*)xBitmapBL;
// define the ChannelData and set the u/v coords for sampling
ChannelData chData;
// call the InitRender before executing sampling
const INITRENDERRESULT res = activeMatColorBS->InitRender(irs);
if (res != INITRENDERRESULT_OK)
return EXECUTIONRESULT_OK;
const Int32 steps = 100;
for (Int32 x = 0; x < steps; x++)
{
for (Int32 y = 0; y < steps; y++)
{
chData.p.x = double(x)/double(steps);
chData.p.y = double(y)/double(steps);
// sample
const Vector sampledValue = activeMatColorBS->Sample(&chData);
// correct based on the color space transformation
const Vector transformedColor = TransformColor(sampledValue, transform).Clamp01();
// just print
GePrint("Shader sample at ["+String::FloatToString(chData.p.x)+","+String::FloatToString(chData.p.y)+"]: "+String::VectorToString(sampledValue)+" / "+String::VectorToString(transformedColor));
}
}
// call the FreeRender to release allocated memory used for sampling
activeMatColorBS->FreeRender();
}
// Notify Cinema about the internal data update.
op->Message(MSG_UPDATE);
return true;
}
TagData::Execute()
EXECUTIONRESULT PC_11085_TagData::Execute (BaseTag *tag, BaseDocument *doc, BaseObject *op, BaseThread *bt, Int32 priority, EXECUTIONFLAGS flags)
{
if (!tag || !doc || !op || !bt)
return EXECUTIONRESULT_OUTOFMEMORY;
// allocate and init the InitRenderStruct
InitRenderStruct irs(doc);
// check the color space
COLORSPACETRANSFORMATION transform = COLORSPACETRANSFORMATION_NONE;
// check if linear workflow is enabled
if (irs.linear_workflow)
transform = COLORSPACETRANSFORMATION_LINEAR_TO_SRGB;
// find for the attached TextureTag and the related material
TextureTag* opTTag = (TextureTag*)op->GetTag(Ttexture);
if (!opTTag)
return EXECUTIONRESULT_OK;
BaseMaterial* opMat = opTTag->GetMaterial();
if (!opMat)
return EXECUTIONRESULT_OK;
// look for the material BaseContainer and the BaseList2D associated to the color param
BaseContainer* activeMatBC = opMat->GetDataInstance();
if (!activeMatBC)
return EXECUTIONRESULT_OK;
BaseList2D* activeMatColorBL = activeMatBC->GetLink(MATERIAL_COLOR_SHADER, doc);
if (!activeMatColorBL)
return EXECUTIONRESULT_OK;
// cast to BaseShader
BaseShader* activeMatColorBS = (BaseShader*)activeMatColorBL;
// define the ChannelData and set the u/v coords for sampling
ChannelData chData;
// call the InitRender before executing sampling
const INITRENDERRESULT res = activeMatColorBS->InitRender(irs);
if (res != INITRENDERRESULT_OK)
return EXECUTIONRESULT_OK;
const Int32 steps = 100;
for (Int32 x = 0; x < steps; x++)
{
for (Int32 y = 0; y < steps; y++)
{
chData.p.x = double(x)/double(steps);
chData.p.y = double(y)/double(steps);
// sample
const Vector sampledValue = activeMatColorBS->Sample(&chData);
// correct based on the color space transformation
const Vector transformedColor = TransformColor(sampledValue, transform).Clamp01();
// just print
GePrint("Shader "+activeMatColorBL->GetName()+" sample at ["+String::FloatToString(chData.p.x)+","+String::FloatToString(chData.p.y)+"]: "+String::VectorToString(sampledValue)+" / "+String::VectorToString(transformedColor));
}
}
// call the FreeRender to release allocated memory used for sampling
activeMatColorBS->FreeRender();
return EXECUTIONRESULT_OK;
}
Looking forward hearing from you, give best
Riccardo