Copy shader from one material to another



  • 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
    
    


  • 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.



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


Log in to reply