Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Inserting an Image Shader into a Dynamic Slot

    Cinema 4D SDK
    r20 python
    4
    6
    890
    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.
    • ?
      A Former User
      last edited by r_gigante

      Hi,
      I'm trying to script the creation of an Octane Universal Material. I am able to get most of the channels' shaders connected correctly using BaseList2D's InsertShader method. I am getting hung up, however, when trying to connect the Metallic texture to the Metallic shader.

      The shader starts as a float with a Texture button next to it:
      Step 1

      The button opens a contextual menu allowing the user to choose the type of shader:
      Step 2

      With Image selected, I could then insert the shader into the ImageTexture slot as with the other channels:
      Step 3

      This is my current code:

      import c4d
      
      ID_OCTANE_BITMAP = 1029508
      ID_OCTANE_SPECULAR_MAP = 1029508
      
      def addMetallicTexture(id,mat):
          imageTexture = c4d.BaseShader(ID_OCTANE_BITMAP)
          imageTexture[c4d.IMAGETEXTURE_FILE] = "Clear_Plastic_Mat_metallic.png"
          mat[id] = imageTexture
          doc.AddUndo(c4d.UNDOTYPE_CHANGE, mat)
          mat[c4d.OCT_MAT_SPECULAR_MAP_LINK].InsertShader(imageTexture)
          mat.Message(c4d.MSG_UPDATE)
          c4d.EventAdd()
      
      def main():
          doc = c4d.documents.GetActiveDocument()
          doc.StartUndo()
          mat = doc.GetActiveMaterial()
          addMetallicTexture(ID_OCTANE_SPECULAR_MAP,mat)
          doc.EndUndo()
      
      if __name__=='__main__':
          main()
      

      It works in the creation of the node, but doesn't create the Image Texture into the Metallic channel so it can be inserted. No commands appear in the Script Log when I select "Image" nor when I connect the nodes in the Octane Node Editor, so I'm not sure how else to create the Image Texture.

      Octane Node Editor

      I've also tried to call the Button, but it opens the contextual menu without inserting the Image Texture:

      c4d.CallButton(mat(), c4d.OCT_MAT_ADD_SPECULAR_MAP_BTN)
      

      Can anyone help me script this? Thank you!

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by

        Hi,

        have you tried sending your button id as a message to your material node instead of using c4d.CallButton()?

        Cheers
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        ? 2 Replies Last reply Reply Quote 0
        • M
          m_adam
          last edited by m_adam

          Hi, @blastframe your best bet is to directly contact octane developer.

          But from my personal test (around 1 year ago), octane does not offer any API for its c4d node system.
          Meaning you can't link shader together, same for the popup is up to the GUI developer to send a message.

          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User @ferdinand
            last edited by

            @zipit said in Inserting an Image Shader into a Dynamic Slot:

            Hi,

            have you tried sending your button id as a message to your material node instead of using c4d.CallButton()?

            Cheers
            zipit

            Hi @zipit , that sounds very interesting. Could you please explain how I'd do that?

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User @ferdinand
              last edited by A Former User

              @m_adam Thank you for the reply. I did reach out to the developer here.

              I found the solution. This is the C++ code of the shader:

                  GROUP ID_MATERIAL_SPECULAR_MAP_GROUP
                  {
                      COLUMNS 1;
                      GROUP ID_MATERIAL_SPECULAR_MAP_FLOAT_GROUP
                      {
                          COLUMNS 2;
                          REAL OCT_MAT_SPECULAR_MAP_FLOAT { SCALE_H; MIN 0.0; STEP 0.01; MAX 1.0; MAXSLIDER 1.0;  CUSTOMGUI OCTNSLIDER;; }
                          BUTTON OCT_MAT_ADD_SPECULAR_MAP_BTN   { ANIM OFF; }
                      }
                      SHADERLINK OCT_MAT_SPECULAR_MAP_LINK { OPEN; INPORT;}
                  }
              

              I didn't know the Specular Map link was there as it isn't visible without pressing the button. I got it working with the following code:

              mat[c4d.OCT_MAT_SPECULAR_MAP_LINK ] = imageTexture
              mat.InsertShader(imageTexture)
              

              Thanks for the help!

              1 Reply Last reply Reply Quote 0
              • S
                s_bach
                last edited by

                @blastframe said in Inserting an Image Shader into a Dynamic Slot:

                This is the C++ code of the shader:

                Hello,

                just to make things clear: the above snippet is NOT the "C++ code of the shader".

                It is the resource parameter description, that defines the parameter types and layout. See Description Resource.

                best wishes,
                Sebastian

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

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