On 02/04/2015 at 08:38, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R15
Platform: Windows ;
Language(s) : C++ ;
---------
Hi,
I am trying to implement transparent material using plugin derived from MaterialData. I have no problem with part used by renderer (CalcSurface, CalcAlpha etc), but I have problems with the way C4D shows my material in editor view - it seems like objects are drawn in the wrong order, causing transparent object hide object behind it (see attached image, left part). It works only sometimes, usually when objects are intersected (right part of image).
See https://drive.google.com/file/d/0B7g1HtV8lD7gdlEzeVFsVVAzNVk/view?usp=sharing
Here is my implementation of InitGLImage:
Bool EnviroPortal::InitGLImage(BaseMaterial *mat, BaseDocument *doc, BaseThread *th, BaseBitmap *bmp, C4DInt32 doccolorspace, Bool linearworkflow)
{
if (!bmp)
return FALSE;
BaseBitmap *alpha = bmp->GetInternalChannel();
if (!alpha)
alpha = bmp->AddChannel(TRUE, FALSE);
for (C4DInt32 j = 0; j < bmp->GetBh(); ++j)
for (C4DInt32 i = 0; i < bmp->GetBw(); ++i)
{
bmp->SetPixel(i, j, 255, 255, 0);
bmp->SetAlphaPixel(alpha, i, j, 64);
}
return TRUE;
}
Also, I use PLUGINFLAG_MATERIAL_GLIMAGE_WITH_ALPHA in RegisterMaterialPlugin.
Thanks for any help.