On 02/06/2016 at 23:17, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 14+
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;
---------
Hi,
I am having a problem detecting animation on a sampled shader, like an animated noise shader or movie file loaded as a bitmap.
When using dirty flags on a noise shader for example, I get an update only when parameters (like global scale) are keyframed, but not with the built-in animation speed which does not require keyframes.
Also, dirty flags seem to have no effect on animated movie files.
Here is the code I am using to get the shader, as discussed in an earlier thread of mine.
AutoAlloc<BaseBitmap> bmp;
BaseShader* shaderLink = (BaseShader* )bc->GetLink(MYSHADERLINK,doc);
if (shaderLink)
{
InitRenderStruct irs;
shaderLink->InitRender(irs);
LONG bitmapWidth = 100;
LONG bitmapHeight = 100;
IMAGERESULT res = bmp->Init(bitmapWidth, bitmapHeight);
if (res == IMAGERESULT_OK)
{
ChannelData chD;
chD.p = Vector(0, 0, 0);
chD.n = Vector(0, 1, 0);
chD.d = Vector(0, 0, 0);
chD.texflag = TEX_TILE;
chD.vd = NULL;
chD.off = 0.0;
chD.scale = 0.0;
chD.t = doc->GetTime().GetFrame(doc->GetFps()); //doesn't do anything
for (LONG x=0; x < bitmapWidth; x++)
{
for (LONG y=0; y < bitmapHeight; y++)
{
chD.p.x = (Real) x / bitmapWidth;
chD.p.y = (Real) y /bitmapHeight;
Vector pixel = shaderLink->Sample(&chD);
LONG r1 = pixel.x * 255;
LONG g1 = pixel.y * 255;
LONG b1 = pixel.z * 255;
bmp->SetPixel(x, y, r1, g1, b1);
}
}
}
shaderLink->FreeRender();
}
Any help on auto-updating animated shaders would be great. Thanks!