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 from one material to another

    Cinema 4D SDK
    2
    3
    608
    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.
    • M
      Motion4D
      last edited by

      Hi, I'm trying to copy a shader from one material to another. I know how to set the other material to the same type of shader but I don't know how to copy it exactly? for example if the noise parameters were tweaked on the texture we're copying.
      The code assumes 2 materials are selected for coping the shader.

      #Get the type of shader from 1st Material
      shaderType = c4d.BaseList2D(mat[0][c4d.MATERIAL_LUMINANCE_SHADER].GetType()) 
      
      #Set shader to same type on 2nd
      mat[1].InsertShader(shaderType)
      mat[1][c4d.MATERIAL_ALPHA_SHADER] = shaderType
      
      
      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        InsertShader() and the parameter do NOT need the shader type. They desire an actual shader instance. You can create a clone of the original shader with GetClone().

        See also BaseShader Manual.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • M
          Motion4D
          last edited by

          Thanks Bach! I knew it was going to be something simple like that.

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