convert VRay materials to C4D Materials

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Display Modes
  3 Weeks Ago
convert VRay materials to C4D Materials

Do you have a scipt to do this (i'm using C4D R17 et VRay R15_140910)

I found this script in a forum but it doesn't work. 

"Stuart, did you get anywhere?
See the framework how it could be done.
Note, only checked with R11/Vray1.1 as
I don't have Vray1.2 installed in R12.

Cheers
Lennart

Copy -all- into script manager and keep your fingers crossed

// VrayMat_To_C4DMat tcastudios.com©2011
//
// In Material Manager, select all VrayMaterial to be replaced.
// Creates new C4D materials based on:
// Vray Materials DiffuseLayer 1 Diffuse Color -> C4D Color Channel
// Vray DiffuseLayer 1 Diffuse Transparency -> C4D Transparency Channel
// Vray Material Weight -> C4D Alpha Channel
// Vray Specular1 -> C4D Specular and Specular Color Channel
//
// Then replaces found VrayMat Tags in Object Manager
//
// NOTE! Only tested in R11 and VrayForC4d v1.1.
// Check UNDO and Vray enumerates for R12+/VrayForC4D 1.2, see comments in code


TagVrayToC4D(obj,vmat,cmat) // Search and replace TextureTag materials(Vray->C4D) for object
{
var tag = obj->GetFirstTag();
if(!tag) return NULL;
var doc = tag->GetObject()->GetDocument();
while(tag)
{
if(tag && tag->GetType() == Ttexture && tag#TEXTURETAG_MATERIAL == vmat)
{
doc->AddUndo(UNDO_TAG_DATA,tag); // R11+
//doc->AddUndo(UNDOTYPE_CHANGE,tag); // R12+ <----------
tag#TEXTURETAG_MATERIAL = cmat;
EventAdd();
}
tag = tag->GetNext();
}
return NULL;
}

VrayToC4D(obj,vmat,cmat) // Iterate the scene
{
while(obj)
{
TagVrayToC4D(obj,vmat,cmat); // Do the Tag thing
VrayToC4D(obj->GetDown(),vmat,cmat);
obj = obj->GetNext();
}
}

main(doc,op)

if(!material()) return;// No Mats selected

var i = 0;
doc->StartUndo();
while(material(i)) // While iterating materials
{
var cmat;
var vmat = material(i);
if(vmat->GetType() == 1020295) // If VrayMaterial
{
cmat = AllocMaterial(Mmaterial); // Make C4D Material
doc->AddUndo(UNDO_NEW,cmat); // R11+
//doc->AddUndo(UNDOTYPE_NEW,cmat); // R12+ <----------
cmat->SetName(stradd(tostring(vmat->GetName()),"_c4d")); // Name it

///// Vray Material Weight to C4D Alpha //////////////////////////
if(vmat#VRAYMATERIAL_USE_TRANSP)
{
if(vmat#VRAYMATERIAL_TRANSP_SHADER != NULL)// If shader
{
cmat#MATERIAL_USE_ALPHA = TRUE;// Activate C4D Alpha Channel
cmat#MATERIAL_ALPHA_INVERT = TRUE; // Alpha Invert
cmat#MATERIAL_ALPHA_SHADER = vmat#VRAYMATERIAL_TRANSP_SHADER;// Vray Shader to C4D shader
cmat#MATERIAL_ALPHA_SHADER->SetContainer(vmat#VRAYMATERIAL_TRANSP_SHADER->GetContainer());// Shader Settings
}
}
///////////////////////////////////////////////////////////////////

///// Vray Diffuse1 to C4D color //////////////////////////////////
if(vmat#VRAYMATERIAL_USE_COLOR)

cmat#MATERIAL_COLOR_COLOR = vmat#VRAYMATERIAL_COLOR_COLOR; 
if(vmat#VRAYMATERIAL_COLOR_SHADER != NULL) // If shader
{
cmat#MATERIAL_COLOR_SHADER = vmat#VRAYMATERIAL_COLOR_SHADER; // Vray Shader to C4D shader
cmat#MATERIAL_COLOR_SHADER->SetContainer(vmat#VRAYMATERIAL_COLOR_SHADER->GetContainer());// Shader Settings
}

// Vray Diffuse1 Transparency to C4D Transparency Channel
if(vmat#VRAYMATERIAL_COLOR_TRANSP_MULT > 0) 
{
cmat#MATERIAL_USE_TRANSPARENCY = TRUE; // Activate Transparency C4D Channel
cmat#MATERIAL_TRANSPARENCY_COLOR = vmat#VRAYMATERIAL_COLOR_TRANSP; // Vray Transp to C4D Transp
cmat#MATERIAL_TRANSPARENCY_BRIGHTNESS = vmat#VRAYMATERIAL_COLOR_TRANSP_MULT;// Set level
if(vmat#VRAYMATERIAL_COLOR_TRANSPSHADER != NULL) // If Shader
{
cmat#MATERIAL_TRANSPARENCY_SHADER = vmat#VRAYMATERIAL_COLOR_TRANSPSHADER;// Vray Shader to C4D shader
cmat#MATERIAL_TRANSPARENCY_SHADER->SetContainer(vmat#VRAYMATERIAL_COLOR_TRANSPSHADER->GetContainer());// Shader Settings
}
}
}
//////////////////////////////////////////////////////////////////

///// Vray Reflection to C4D Reflection Channel //////////////////
if(vmat#VRAYMATERIAL_USE_REFLECTION)
{
cmat#MATERIAL_USE_REFLECTION = TRUE;
cmat#MATERIAL_REFLECTION_COLOR = vmat#VRAYMATERIAL_REFLECTION_COLOR;
if(vmat#VRAYMATERIAL_REFLECTION_SHADER != NULL)
{
cmat#MATERIAL_REFLECTION_SHADER = vmat#VRAYMATERIAL_REFLECTION_SHADER;
cmat#MATERIAL_REFLECTION_BRIGHTNESS = vmat#VRAYMATERIAL_REFLECTION_COLOR_MULT;
cmat#MATERIAL_REFLECTION_TEXTUREMIXING = 0; // "Normal"
cmat#MATERIAL_REFLECTION_TEXTURESTRENGTH = vmat#VRAYMATERIAL_REFLECTION_TEXTUREMULT;
cmat#MATERIAL_REFLECTION_SHADER->SetContainer(vmat#VRAYMATERIAL_REFLECTION_SHADER->GetContainer());
}
}
//////////////////////////////////////////////////////////////////

///// Vray Specular Layer1 to C4D Specular and Spec Color Channel //////////////////
if(vmat#VRAYMATERIAL_USE_SPECULAR1)
{
cmat#MATERIAL_USE_SPECULAR = TRUE;
cmat#MATERIAL_SPECULAR_WIDTH = 1.0 - (vmat#VRAYMATERIAL_SPECULAR1_HIGHLIGHTGLOSS);
cmat#MATERIAL_USE_SPECULARCOLOR = TRUE;
cmat#MATERIAL_SPECULAR_COLOR = vmat#VRAYMATERIAL_SPECULAR1_COLOR;
cmat#MATERIAL_SPECULAR_BRIGHTNESS = vmat#VRAYMATERIAL_SPECULAR1_COLOR_MULT;
if(vmat#VRAYMATERIAL_SPECULAR1_SHADER)
{
cmat#MATERIAL_SPECULAR_SHADER = vmat#VRAYMATERIAL_SPECULAR1_SHADER;
cmat#MATERIAL_SPECULAR_TEXTUREMIXING = 0;
cmat#MATERIAL_SPECULAR_TEXTURESTRENGTH = vmat#VRAYMATERIAL_SPECULAR1_TEXTUREMULT;
cmat#MATERIAL_SPECULAR_SHADER->SetContainer(vmat#VRAYMATERIAL_SPECULAR1_SHADER->GetContainer());
}

}
///////////////////////////////////////////////////////////////////////////////////

cmat->InsertBefore(material(0)); // Insert it
VrayToC4D(doc->GetFirstObject(),vmat,cmat); // Find and replace it in Object Manager
}
i = i+1; // Next Material
}

doc->EndUndo();
}
"

Thanks you
 
  1 Week Ago
Go to Plugins and scroll down to VrayBridge as shown below ...


__________________
David

iMac 3.06 ghz Intel Core 2 Duo / 16 GB / OS 10.13.4 / C4D StudioR12 / CS6
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:48 AM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.