C4D Material Builder

  • On 19/11/2017 at 19:33, xxxxxxxx wrote:


    I'm writing a simple script that creates and sets up a C4D Material based on a folder of .jpgs with appropriate "*_diffuse.jpg", "*_specular.jpg" etc. names.

    I've figured out how to create a material, but I'm stuck on how to add the filepath to a ".jpg" to the [c4d.MATERIAL_COLOR_SHADER].

    Create new C4D Material

    c4d.CallCommand(13015, 13015) # New Material
    # Get First Material, the one we just created
    material = doc.GetFirstMaterial()
    # rename: cdmat-"name"
    material[c4d.ID_BASELIST_NAME] = "name"
    # Enable Color Mat[c4d.MATERIAL_USE_COLOR]
    material.SetChannelState(c4d.CHANNEL_COLOR, True)
    # Set Mat[c4d.MATERIAL_COLOR_SHADER] to name_diffuse.jpg
    material[c4d.MATERIAL_COLOR_SHADER] = "D:\CD-Scenes\008-BedroomDemo\008-Bedroom-01.jpg"



  • On 19/11/2017 at 20:27, xxxxxxxx wrote:

    you need to do like this

        material = c4d.BaseMaterial(c4d.Mmaterial)
        # Set the state of a channel
        material[c4d.MATERIAL_USE_COLOR] = True
        # Create Bitmap Shader
        shader = c4d.BaseShader(c4d.Xbitmap)
        shader[c4d.BITMAPSHADER_FILENAME]= r"D:\CD-Scenes\008-BedroomDemo\008-Bedroom-01.jpg"
        # Inserts a shader in the objects shader list
        material[c4d.MATERIAL_COLOR_SHADER] = shader
        # Inserts Material in Project

  • On 20/11/2017 at 06:14, xxxxxxxx wrote:

    Hi Matt,

    if you are interested in a bit more background, what anion did in his code and why, you may want to visit the C++ Docs (no worries!) :
    BaseShader Manual
    Material Manual

Log in to reply