Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Transparent material in editor view

    SDK Help
    0
    16
    1.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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?

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 17/04/2015 at 02:15, xxxxxxxx wrote:

            Hello,

            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.

            Best wishes,
            Sebastian

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 17/04/2015 at 05:50, xxxxxxxx wrote:

              Hi Sebastian,
              thanks for answer. I look forward for any update, in the meantime, I will try to find some workaround 🙂

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 24/08/2016 at 18:37, xxxxxxxx wrote:

                Hi, Did you find something about that?

                Thanks 🙂
                Renato T.

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  On 25/08/2016 at 00:13, xxxxxxxx wrote:

                  Hello,

                  since R17 there is MaterialData::HasEditorTransparency() that has to be implemented to inform the editor if the material uses transparency.

                  Best wishes,
                  Sebastian

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    On 25/08/2016 at 08:14, xxxxxxxx wrote:

                    Hi Sebastian,

                    Many thanks!
                    Renato

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      On 25/08/2016 at 19:09, xxxxxxxx wrote:

                      Hi Sebastian,

                      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?

                      Thanks 🙂
                      Renato

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        On 25/08/2016 at 23:40, xxxxxxxx wrote:

                        Hello,

                        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?

                        Best wishes,
                        Sebastian

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

                          On 26/08/2016 at 04:57, xxxxxxxx wrote:

                          Hi Sebastian,

                          I found why, is my problem.

                          Thanks
                          Renato

                          1 Reply Last reply Reply Quote 0
                          • H
                            Helper
                            last edited by

                            On 06/09/2016 at 03:13, xxxxxxxx wrote:

                            Hi,
                            I have same issue. Constantly called InitGlImage() with this flag. How could you sorted the issue?

                            Best,
                            Ahmet

                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

                              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.

                              I'm sorry

                              1 Reply Last reply Reply Quote 0
                              • H
                                Helper
                                last edited by

                                On 08/09/2016 at 09:03, xxxxxxxx wrote:

                                Hello,

                                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.

                                best wishes,
                                Sebastian

                                1 Reply Last reply Reply Quote 0
                                • H
                                  Helper
                                  last edited by

                                  On 08/09/2016 at 10:02, xxxxxxxx wrote:

                                  Thanks a lot 🙂

                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    Helper
                                    last edited by

                                    On 18/11/2016 at 08:55, xxxxxxxx wrote:

                                    Hi!
                                    Is this fixed somehow with new service packs?

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post