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

    Copy Shader tree from mat1 to mat2

    SDK Help
    0
    14
    1.2k
    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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 28/04/2007 at 16:54, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   9.6+ 
      Platform:   Windows  ; Mac  ;  Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      Hi all,

      like the topic, i need to copy the shader tree from material1 to material2.

      I tried to SetLink() from the mat1 container to the mat2 container.
      The shader is placed but don't work.. and if i remove the mat1 from the document.. the shader tree disappear.

      Maybe that i need to send some message to it.. or duplicate the shadertree and put it in the mat2.

      Thanks in advance
      Renato

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 30/04/2007 at 07:09, xxxxxxxx wrote:

        Any help?

        Cheers
        Renato

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 30/04/2007 at 08:20, xxxxxxxx wrote:

          Have you tried CopyTo()? SetLink() will mean that both materials are using the same shader instance in memory - maybe this is not possible and thus the non-working secondary usage.

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

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 30/04/2007 at 08:33, xxxxxxxx wrote:

            Hi Robert,now i've tried to getclone of shader tree and put it in the new material (Custom Material).

            In fact the shaders tree are copied and i can see it in my VrayMaterial but.. are not working. Just i need to copy/paste the texture and it work.

            for now i've tried this code:

            Bool TransferShader (BaseMaterial* matStart, BaseMaterial* matDest,BaseDocument *doc, LONG shaderIdStart, LONG shaderIdDest){
                 BaseContainer *bcMatStart = matStart->GetDataInstance();
                 BaseContainer *bcMatDest = matDest->GetDataInstance();
                 PluginShader *tempShader = (PluginShader* ) bcMatStart->GetLink(shaderIdStart,doc);
                 if (tempShader){
                      PluginShader *clonedShader = (PluginShader* ) tempShader->GetClone(NULL,NULL);
                      if (clonedShader){
                           bcMatDest->SetLink ( shaderIdDest, clonedShader );
                           doc->InsertShader(clonedShader,NULL);
                           clonedShader->Message(MSG_CHANGE);
                      }
                 }
                 return TRUE;
            };

            now i'll reading the copyto 🙂

            Cheers
            Renato

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

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 02/05/2007 at 09:57, xxxxxxxx wrote:

              Hi all,

              still is not working.

              I tried to send msg to material, to the shaders.. but still   the material preview is without the texture.
              The OpenGL preview and the vray rendering is fine.

              maybe that my material is a custom material?

              Do i set somethings inside it ?

              Cheers
              Renato

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

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 04/05/2007 at 09:37, xxxxxxxx wrote:

                Any Help from SDK support?

                thanks
                Renato

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

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 04/05/2007 at 10:05, xxxxxxxx wrote:

                  Remember that Matthias is out for the week (until May 6) at a conference.

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

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 04/05/2007 at 10:28, xxxxxxxx wrote:

                    thanks Robert 🙂

                    Cheers
                    Renato

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

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 11/05/2007 at 19:51, xxxxxxxx wrote:

                      Any help?

                      Cheers
                      Renato

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

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 15/05/2007 at 06:59, xxxxxxxx wrote:

                        You have to add an EventAdd() after inserting the shader to refresh the preview. Little piece of working code:

                        BaseMaterial *bm = doc->GetFirstMaterial();
                        if(!bm) return TRUE;

                        BaseContainer *data = bm->GetDataInstance();
                        PluginShader *shd = PluginShader::Alloc(1001162);
                        if(!shd) return FALSE;

                        data->SetLink(MATERIAL_LUMINANCE_SHADER,shd);
                        bm->InsertShader(shd,NULL);
                        bm->Message(MSG_CHANGE);
                        bm->Update(TRUE,TRUE);
                        EventAdd();

                        this loads the mandelbrot shader from the sdk examples into the luminance channel.

                        cheers,
                        Matthias

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

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 15/05/2007 at 23:55, xxxxxxxx wrote:

                          Hi Matthias,

                          i'm sorry but still not workin 😞

                          Cheers
                          Renato

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

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 16/05/2007 at 00:29, xxxxxxxx wrote:

                            have you called the BaseMaterial Update() function after inserting the shader?

                            cheers,
                            Matthias

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

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 16/05/2007 at 01:09, xxxxxxxx wrote:

                              Hi Matthias,

                              here my code:

                              Bool TransferShader (BaseMaterial* matStart, BaseMaterial* matDest, LONG shaderIdStart, BaseDocument *doc, LONG shaderIdDest){
                                   BaseContainer *bcMatStart = matStart->GetDataInstance();
                                   BaseContainer *bcMatDest = matDest->GetDataInstance();
                                   PluginShader *tempShader = (PluginShader* ) bcMatStart->GetLink(shaderIdStart,doc);
                                   if (tempShader){
                                        PluginShader *clonedShader = (PluginShader* ) tempShader->GetClone(NULL,NULL);
                                        if (clonedShader){
                                             bcMatDest->SetLink ( shaderIdDest, (BaseList2D* ) clonedShader );
                                             doc->InsertShader(clonedShader,NULL);
                                             matDest->Message(MSG_CHANGE);
                                             matDest->Update(TRUE,TRUE);
                                             EventAdd();
                                        }
                                   return TRUE;
                                   }
                                   return FALSE;
                              };

                              Cheers 🙂
                              Renato

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

                                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                On 31/05/2007 at 07:34, xxxxxxxx wrote:

                                Any Help?

                                Cheers
                                Renato

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