Converting Octane Materials back to C4D counterparts

Forums: Converting Octane Materials back to C4D counterparts
Sub forum for feature requests etc

Moderator: aoktar

Converting Octane Materials back to C4D counterparts

Postby Tag12345 » Wed Jan 04, 2017 11:08 pm

Tag12345 Wed Jan 04, 2017 11:08 pm
I mentioned this in one of my posts and remembered someone saying it would be easy to script that in either python or into the plugin itself, forget which.

But I think its really important that we can go back and forth between octane and C4D materials, or at least when in a group where others may not have octane, it would be nice to be able to convert the scenes materials back into their C4D counterparts. With a couple projects Ive been doing, i find it a hassle to have to have made a C$D standard materials copy before I work in octane this way I have two seperate versions, but it would be helpful to have. The way it is now, one has to make new materials for every octane material you may have and then re material everything in the scene, which is tedious when its 1000's of objects.


So if there is a way to do this without affecting the plugin, then cool, but I think this is a needed feature!

Happy Holidays
Tag12345
Licensed Customer
Licensed Customer
 
Posts: 107
Joined: Sat Feb 27, 2016 11:23 am

Re: Converting Octane Materials back to C4D counterparts

Postby aoktar » Wed Jan 04, 2017 11:35 pm

aoktar Wed Jan 04, 2017 11:35 pm
I don't wanna spend time on this but it's possible by scripts. Somebody will appreciate if someone does it. Here is some sample scripts done by me. I can answer any technical questions.
viewtopic.php?f=87&t=56039
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
aoktar
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 13516
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye

Re: Converting Octane Materials back to C4D counterparts

Postby Tag12345 » Thu Jan 05, 2017 12:32 am

Tag12345 Thu Jan 05, 2017 12:32 am
I appreciate it
Tag12345
Licensed Customer
Licensed Customer
 
Posts: 107
Joined: Sat Feb 27, 2016 11:23 am

Re: Converting Octane Materials back to C4D counterparts

Postby aoktar » Thu Jan 05, 2017 1:11 am

aoktar Thu Jan 05, 2017 1:11 am
I just can give a sample script for making a simple conversion. It should be impossible or very hard to make exactly same looking material conversion.
Octane For Cinema 4D developer / 3d generalist

3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
User avatar
aoktar
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 13516
Joined: Tue Mar 23, 2010 8:28 pm
Location: Türkiye

Re: Converting Octane Materials back to C4D counterparts

Postby Tag12345 » Thu Jan 05, 2017 1:40 am

Tag12345 Thu Jan 05, 2017 1:40 am
yeah, just something to convert over my diffuse and bump channels, something simple is all i need :P
Tag12345
Licensed Customer
Licensed Customer
 
Posts: 107
Joined: Sat Feb 27, 2016 11:23 am

Re: Converting Octane Materials back to C4D counterparts

Postby nscr » Mon Sep 24, 2018 9:27 pm

nscr Mon Sep 24, 2018 9:27 pm
Wondering if this script was posted anywhere?

Thanks!
nscr
Licensed Customer
Licensed Customer
 
Posts: 8
Joined: Wed Nov 30, 2016 3:34 am

Re: Converting Octane Materials back to C4D counterparts

Postby lightborne » Wed Jun 12, 2019 8:36 pm

lightborne Wed Jun 12, 2019 8:36 pm
I'm looking to convert some octane materials back to C4D standard materials. I know they won't look nearly as good, but I need a script or simple way to extract the image textures from the various channels in an octane material and transfer them into the equivalent channels in a C4D standard material... basically the reverse of what Octane's "convert materials" command does. Anyone know of anything like that?

Thanks!
lightborne
Licensed Customer
Licensed Customer
 
Posts: 2
Joined: Thu Aug 07, 2014 7:21 pm

Re: Converting Octane Materials back to C4D counterparts

Postby bepeg4d » Thu Jun 13, 2019 2:37 pm

bepeg4d Thu Jun 13, 2019 2:37 pm
Hi,
a possible solution is to use Octane Baking:
http://www.aoktar.com/octane/Baking.html
to extract the maps of these passes:
DBAB606C-4BDA-4E03-BCC0-926D24F7DEEB.jpeg

to more easily recreate a similar material with c4d standard render.
ciao Beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 7387
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Converting Octane Materials back to C4D counterparts

Postby franchus » Sat May 02, 2020 6:50 am

franchus Sat May 02, 2020 6:50 am
There is a user in Maxon forums named Graeme MacDougall that wrote this script, I've tried it and it works:

"""
OctaneToC4d
v0.1

Written by Graeme McDougall for Painting Practice
Copyright: Painting Practice (www.paintingpractice.com)
Written for Cinema 4d R20.057

Name-US:OctaneToC4d
Description-US:Converts selected Octane materials to Cinema 4d materials, as best as possible
"""

import c4d
from c4d import documents

ID_OCTANE_MATERIAL = 1029501 #Here we define more readable IDs for any integer IDs we are using
ID_OCTANE_IMAGE_TEXTURE = 1029508 #To make our code more readable
ID_OCTANE_COLORCORRECTION = 1029512
ID_OCTANE_INVERT_TEXTURE = 1029514
ID_OCTANE_MULTIPLY_TEXTURE = 1029516
ID_OCTANE_MIXTEXTURE = 1029505
mainLayerId = 526336


def CheckSelection(doc, mats): #Checks selection & returns a list of only the Octane materials
oct_mats = [] #Create an empty list, to later store any Octane materials
if mats: #If there are any materials selected...
count = len(mats) #...get how many
for i in range(count): #for each one...
if mats[i].GetType() == ID_OCTANE_MATERIAL: #...if it's an Octane material...
oct_mats.append(mats[i]) #...add it to our list of Octane materials
return oct_mats #Return the list of Ocatne mats

def GetTexture(doc, oct_mat, channel): #Gets a filename from a particular channel of an Octane mat
image_name = None #Create an empty variable to store the image name
image_shader = oct_mat[channel] #Check the texture link & load shader in variable image_tex
if image_shader: #If one is found...
shader_type = image_shader.GetType() #...get it's type

if shader_type == ID_OCTANE_MULTIPLY_TEXTURE: #If it's a multiply shader...
image_shader = image_shader[c4d.MULTIPLY_TEXTURE1] #Get the first shader in it
if image_shader: #If we found a shader of some sort
shader_type = image_shader.GetType() #Load it's type into the tex_type variable

if shader_type == ID_OCTANE_MIXTEXTURE: #If it's a mix shader...
image_shader = image_shader[c4d.MIXTEX_TEXTURE1_LNK] #Get the first shader in it
if image_shader: #If we found a shader of some sort
shader_type = image_shader.GetType() #Load it's type into the tex_type variable

if shader_type == ID_OCTANE_COLORCORRECTION: #If it's a colour correction shader
image_shader = image_shader[c4d.COLORCOR_TEXTURE_LNK] #Get the texture in it's texture link & replace the image_tex var
if image_shader: #If we found a shader of some sort
shader_type = image_shader.GetType() #Load it's type into the tex_type variable

if shader_type == ID_OCTANE_INVERT_TEXTURE: #If it's an invert shader
image_shader = image_shader[c4d.INVERT_TEXTURE] #Get the texture in it's texture link & replace the image_tex var
if image_shader: #If we found a shader of some sort
shader_type = image_shader.GetType() #Get it's type

if shader_type == ID_OCTANE_IMAGE_TEXTURE: #If after checking all this, we have an image texture shader..
image_name = image_shader[c4d.IMAGETEXTURE_FILE] #Read the filename into the image_link variable
print image_name
return image_name #Return the filename, if found

def ReAssign(doc, oct_mat, c4d_mat): #Assigns the new Cinema 4D material to the texture tags
obj_link = oct_mat[c4d.ID_MATERIALASSIGNMENTS] #Get the link list for the Octane Material's assignment
link_count = obj_link.GetObjectCount() #Get how many objects are in the link list
for i in range(link_count): #For each of them...
tex_tag = obj_link.ObjectFromIndex(doc, i) #Get the texture tag
doc.AddUndo(c4d.UNDOTYPE_CHANGE, tex_tag) #Add an undo for the tex tag change
tex_tag[c4d.TEXTURETAG_MATERIAL] = c4d_mat #Replace the Octane Material with the Cinema 4D material
tex_tag.Message(c4d.MSG_CHANGE) #update the tex tag

def RebuildMats(doc, oct_mats): #Rebuilds each Octane material as a Cinema 4D material
c4d_mats = [] #Create an empty list where we store our new Cinema 4D mats
count = len(oct_mats) #Get how many Octane mats we have
for i in range(count): #For each one...
oct_mat = oct_mats[i] #Read the Octane Material into the variable oct_mat
c4d_mat = c4d.BaseMaterial(c4d.Mmaterial) #Create a new Cinema 4D material
name = oct_mat[c4d.ID_BASELIST_NAME] #Read the Material's name from the Octane mat...
c4d_mat[c4d.ID_BASELIST_NAME] = name #...and name the c4d material the same

diff_file = GetTexture(doc, oct_mat, c4d.OCT_MATERIAL_DIFFUSE_LINK) #Get the texure filename from the diffuse channel
if diff_file: #If we did find a texrure filename...
diff_shader = c4d.BaseShader(c4d.Xbitmap) #...create a new empty bitmap shader...
diff_shader[c4d.BITMAPSHADER_FILENAME] = diff_file #...and load the filename in there
c4d_mat[c4d.MATERIAL_COLOR_SHADER] = diff_shader #Assign the bitmap shader to the material's colour channel...
c4d_mat.InsertShader(diff_shader) #...and insert it into the material

opac_file = GetTexture(doc, oct_mat, c4d.OCT_MATERIAL_OPACITY_LINK) #Get the texture filename from the opacity channel
if opac_file: #If we found one...
opac_shader = c4d.BaseShader(c4d.Xbitmap) #...create a new empty bitmap shader...
opac_shader[c4d.BITMAPSHADER_FILENAME] = opac_file #...and load the filename in there
c4d_mat[c4d.MATERIAL_ALPHA_SHADER] = opac_shader #Assign the bitmap shader to the material's alpha channel...
c4d_mat.InsertShader(opac_shader) #...and insert it into the material
c4d_mat[c4d.MATERIAL_USE_ALPHA] = True #Activate the alpha channel

normal_file = GetTexture(doc, oct_mat, c4d.OCT_MATERIAL_NORMAL_LINK) #Get the texure filename from the normal channel...
if normal_file: #If we found one...
normal_shader = c4d.BaseShader(c4d.Xbitmap) #...create a new empty bitmap shader
normal_shader[c4d.BITMAPSHADER_FILENAME] = normal_file #...and load the filename in there
c4d_mat[c4d.MATERIAL_NORMAL_SHADER] = normal_shader #Assign the bitmap shader to the material's mormal channel...
c4d_mat.InsertShader(normal_shader) #...and insert it into the material
c4d_mat[c4d.MATERIAL_USE_NORMAL] = True #Activate the normal channel

bump_file = GetTexture(doc, oct_mat, c4d.OCT_MATERIAL_BUMP_LINK) #Get the texure filename from the normal channel...
if bump_file: #If we found one...
bump_shader = c4d.BaseShader(c4d.Xbitmap) #...create a new empty bitmap shader
bump_shader[c4d.BITMAPSHADER_FILENAME] = bump_file #...and load the filename in there
c4d_mat[c4d.MATERIAL_BUMP_SHADER] = bump_shader #Assign the bitmap shader to the material's mormal channel...
c4d_mat.InsertShader(bump_shader) #...and insert it into the material
c4d_mat[c4d.MATERIAL_USE_BUMP] = True #Activate the normal channel

rough_file = GetTexture(doc, oct_mat, c4d.OCT_MATERIAL_ROUGHNESS_LINK) #Get the texure filename from the roughness channel...
if rough_file: #If we found one...
rough_shader = c4d.BaseShader(c4d.Xbitmap) #...create a new empty bitmap shader
rough_shader[c4d.BITMAPSHADER_FILENAME] = rough_file #...and load the filename in there
c4d_mat[c4d.MATERIAL_USE_REFLECTION] = True #Activate the Reflectance channel
c4d_mat[mainLayerId + c4d.REFLECTION_LAYER_MAIN_DISTRIBUTION] = 2 #Change the Default Specular to a Beckmann type
c4d_mat[mainLayerId + c4d.REFLECTION_LAYER_MAIN_SHADER_ROUGHNESS] = rough_shader
c4d_mat.InsertShader(rough_shader) #...and insert it into the material

ReAssign(doc, oct_mat, c4d_mat) #Assign the new Cinema material inplace of the Octane one

c4d_mats.append(c4d_mat) #Add the new mat to our list of Cinema 4D materials
doc.InsertMaterial(c4d_mat) #Insert the Cinema 4D Material in the document
doc.AddUndo(c4d.UNDOTYPE_NEW, c4d_mat) #Add an undo step for the new material

return


def main():
my_doc = documents.GetActiveDocument() #Get the active document
my_mats = my_doc.GetActiveMaterials() #Get the selected materials
my_oct_mats = CheckSelection(my_doc, my_mats) #Checks the selected mats & returns only the octane ones

if my_oct_mats: #If we did find Octane materials...
doc.StartUndo() #Start the undo chain
RebuildMats(my_doc, my_oct_mats) #...re-create them as Cinema 4D mats
doc.EndUndo() #End the undo chain
c4d.EventAdd() #Add an event



if __name__=='__main__':
main()
franchus
Licensed Customer
Licensed Customer
 
Posts: 42
Joined: Fri May 13, 2016 7:57 am
Location: Barcelona

Re: Converting Octane Materials back to C4D counterparts

Postby AndyReuter » Wed Jul 15, 2020 10:05 pm

AndyReuter Wed Jul 15, 2020 10:05 pm
I'm lost on this one. How do you use a script like this??
AndyReuter
Licensed Customer
Licensed Customer
 
Posts: 2
Joined: Wed Jul 27, 2016 10:14 pm
Next

Return to User requests


Who is online

Users browsing this forum: No registered users and 1 guest

Thu Aug 13, 2020 12:47 am [ UTC ]