On 02/04/2015 at 08:38, xxxxxxxx wrote:
Cinema 4D Version: R15
Platform: Windows ;
Language(s) : C++ ;
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).
Here is my implementation of InitGLImage:
Bool EnviroPortal::InitGLImage(BaseMaterial *mat, BaseDocument *doc, BaseThread *th, BaseBitmap *bmp, C4DInt32 doccolorspace, Bool linearworkflow)
BaseBitmap *alpha = bmp->GetInternalChannel();
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);
Also, I use PLUGINFLAG_MATERIAL_GLIMAGE_WITH_ALPHA in RegisterMaterialPlugin.
Thanks for any help.
On 02/04/2015 at 14:12, xxxxxxxx wrote:
To add more info, it seems to be working correctly only when the center of transparent object is farther from camera plane than center of the other object - it seems when object are drawn, it is ordering them by z-coord of their center from front to back... So, is it possible it is a bug in C4D (note than I used 15.057)? Because I don't see how it could be caused by my code?
On 16/04/2015 at 10:30, xxxxxxxx wrote:
Ok, so I have another update. I noticed once I add some object with standard C4D material with enabled transparency, all transparent objects (including those using my material) displays correctly. If I remove the c4d material (or turn off transparency in view panel settings), it starts drawing objects in the wrong order again. So I guess I need to enable "something" in C4D to draw transparenct objects correctly...
So, does anybody know what is to be called / enabled?
On 17/04/2015 at 02:15, xxxxxxxx wrote:
sorry for the late answer. We talked with the developers about this and indeed this is currently a bug in the MaterialData class. We hope to fix this soon so custom materials will work properly.
On 17/04/2015 at 05:50, xxxxxxxx wrote:
thanks for answer. I look forward for any update, in the meantime, I will try to find some workaround
On 24/08/2016 at 18:37, xxxxxxxx wrote:
Hi, Did you find something about that?
On 25/08/2016 at 00:13, xxxxxxxx wrote:
since R17 there is MaterialData::HasEditorTransparency() that has to be implemented to inform the editor if the material uses transparency.
On 25/08/2016 at 08:14, xxxxxxxx wrote:
On 25/08/2016 at 19:09, xxxxxxxx wrote:
it work but... when i register my materialdata with PLUGINFLAG_MATERIAL_GLIMAGE_WITH_ALPHA, the InitGlImage() is constantly called even i do nothing in the material or in the editor.
Do you have any idea about that?
On 25/08/2016 at 23:40, xxxxxxxx wrote:
off the top of my head I have no idea. Could you open a new thread on the topic with the relevant sections of your source code?
On 26/08/2016 at 04:57, xxxxxxxx wrote:
I found why, is my problem.
On 06/09/2016 at 03:13, xxxxxxxx wrote:
I have same issue. Constantly called InitGlImage() with this flag. How could you sorted the issue?
On 07/09/2016 at 05:14, xxxxxxxx wrote:
Hi, in my case was a setdirty() . was not dependent from the PLUGINFLAG_MATERIAL_GLIMAGE_WITH_ALPHA.
On 08/09/2016 at 09:03, xxxxxxxx wrote:
it seems that currently (R18 SP1) there is some bug with the PLUGINFLAG_MATERIAL_GLIMAGE_WITH_ALPHA flag. This should be fixed for the next service pack.
On 08/09/2016 at 10:02, xxxxxxxx wrote:
Thanks a lot
On 18/11/2016 at 08:55, xxxxxxxx wrote:
Is this fixed somehow with new service packs?