I'm having a little trouble scripting the creation of a Universal Material and was hoping you could help me.
In Diffuse, Specular, Normal, Roughness, etc. I'm able to insert a bitmap shader because there is a slot for Texture. In the case of Metallic (Specular Map), there is a float next to a button labeled 'Tex.' I can call the button click with:
- Code: Select all
c4d.CallButton(mat(), c4d.OCT_MAT_ADD_SPECULAR_MAP_BTN)
However, that gives me a contextual menu with the options (Float, Image, Rgb, Gaussian Spectrum). It does not print to Cinema 4D's Script Log, so I don't know the slot's ID/parameters I'd need to insert an ImageTexture.
With this code I can add a bitmap shader for the Specular Map, but it doesn't have an ImageTexture to connect as you can see in the Node Editor image.
- Code: Select all
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.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()
Could you tell me how I can insert an ImageTexture node into the Universal Material's Metallic/Specular Map slot please? Thank you!