[Closed] Where is VRayMtl in VRay SDK
Hello guys,
I would want to export VRay Materials with an home-made exporter plugin.
I already have the code to export Standard Materials and tried to apply the same logic to VRay Mats.
But I can’t find the VRayMtl class in the VRay SDK!?
I saw they provided material examples to develop custom VRay Materials, but I didn’t find the VRayMtl class, which is the class I would want to export…
Am I missing something obvious?
Has somebody already played with the VRay SDK?
Thanks for advance,
As I was advised, I posted it on chaosgroup account.
A choasgroup member replied to me, sending a code example as attachment… but Chasgroup forums rules are so strict that I cannot even read the attachment.
Here is the link to the thread:
http://www.chaosgroup.com/forums/vbulletin/showthread.php?70235-Export-VRayMtl-to-third-party-software&p=563058#post563058
If any of you could repost the attachment here, I will be grateful.
Moreover, it could interest someonelse here.
Thanks
Actually just some property that you adjusted. So I think you can export by collect those property. To know the structure or name of properties, you can use showproperties function.
It will show all property that you can access. For quickly picking, you can change that propery and catch it in maxscript listener
For the record, here is a piece of code (from the above zip) that I used to extract VRayMtl properties :
http://pastebin.com/ewwhK1PF
/*************************************************************************
Convenient VRay Enums and Defines For Vray Materials manipulation
**********************************************************************/
#define VRAYMTL_CLASS_ID Class_ID(0x37bf3f2f, 0x7034695c)
#define VRAYMTL_NSUBTEX 17
#define SUBTEXNO_DIFFUSE 0
#define SUBTEXNO_REFLECT 1
#define SUBTEXNO_REFRACT 2
#define SUBTEXNO_BUMP 3
#define SUBTEXNO_REFLECT_GLOSSINESS 4
#define SUBTEXNO_REFRACT_GLOSSINESS 5
#define SUBTEXNO_DISPLACEMENT 6
#define SUBTEXNO_ENVIRONMENT 7
#define SUBTEXNO_TRANSLUCENCY 8
#define SUBTEXNO_IOR 9
#define SUBTEXNO_HILIGHT_GLOSSINESS 10
#define SUBTEXNO_FRESNELIOR 11
#define SUBTEXNO_OPACITY 12
#define SUBTEXNO_ROUGHNESS 13
#define SUBTEXNO_ANISO 14
#define SUBTEXNO_ANISO_ROTATION 15
#define SUBTEXNO_FOG 16
namespace VRayMtlParameters {
// Parameter block IDs
enum {
vrayMtl_old_id,
vrayMtl_basic_id,
vrayMtl_BRDF_id,
vrayMtl_options_id,
vrayMtl_maps_id,
vrayMtl_reflIMap_id,
vrayMtl_refrIMap_id,
};
// Parameters
enum {
pb_spin,
pb_diffuse_color,
pb_reflect_color, pb_reflect_glossiness, pb_reflect_subdivs,
pb_refract_color, pb_refract_glossiness, pb_refract_subdivs,
pb_reflect_fresnel,
pb_refract_ior,
pb_brdf_type,
pb_reflect_trace,
pb_refract_trace,
pb_doubleSided,
pb_reflectOnBack,
pb_diffuse_trace, pb_diffuse_subdivs,
pb_useIrradMap,
pb_diffuseGlossy,
pb_traceCaustics,
pb_reflect_maxDepth,
pb_refract_maxDepth,
pb_cutoffThresh,
pb_refract_fogColor, pb_refract_fogMult, pb_refract_translucent, pb_refract_thickness, pb_refract_volSubdivs, pb_refract_lightMult_old,
pb_refract_scatterCoeff, pb_refract_scatterDir, pb_refract_lightMult,
pb_fog_affectShadows,
pb_useInterpolation,
pb_interpSamples,
pb_colorThreshold,
pb_preservationMode,
pb_translucent_color, pb_translucent_map,
pb_reflect_minRate, pb_reflect_maxRate, pb_reflect_clrThresh, pb_reflect_nrmThresh, pb_reflect_interpSamples, pb_reflect_preset,
pb_refract_minRate, pb_refract_maxRate, pb_refract_clrThresh, pb_refract_nrmThresh, pb_refract_interpSamples, pb_refract_preset,
pb_reflect_exitColor, pb_refract_exitColor, pb_refract_exitColor_on,
pb_brdf_anisotropy, pb_brdf_anisotropy_channel,
pb_reflect_useInterpolation,
pb_refract_useInterpolation,
pb_brdf_anisotropy_rotation, pb_brdf_anisotropy_derivation, pb_brdf_anisotropy_axis,
pb_refract_affectAlpha,
pb_hilight_glossiness,
pb_reflect_ior, pb_reflect_glossiness_lock, pb_reflect_ior_lock,
pb_refract_fogBias,
pb_environment_priority,
pb_diffuse_roughness,
pb_brdf_soften,
pb_clampColors,
pb_reflect_dimDistance, pb_reflect_dimDistanceFallOff, pb_reflect_dimDistanceOn,
pb_refract_dispersion, pb_refract_dispersionOn,
pb_refract_fogUnitScaleOn,
pb_brdf_fixDarkEdges,
pb_effect_id,
pb_override_effect_id,
pb_reflect_affectAlpha,
};
#define SUBTEX_PARAM_ID 100
#define ON_OFFSET 50
#define MULT_OFFSET 100
#define VRAYMTL_TEXMAP_PARAMID(subtexNo) (SUBTEX_PARAM_ID+subtexNo)
#define VRAYMTL_TEXMAP_ON_PARAMID(subtexNo) (SUBTEX_PARAM_ID+subtexNo+ON_OFFSET)
#define VRAYMTL_TEXMAP_MULT_PARAMID(subtexNo) (SUBTEX_PARAM_ID+subtexNo+MULT_OFFSET)
} // namespace VRayMtlParameters
/**********************************************************************
DumpMaterialVRay (Get the VRayMtl material properties)
*************************************************************************/
void Max2Nmo::DumpMaterialVRayMtl(Mtl* mtl, VirtoolsMaterial &NMat, BOOL &OpacityValid)
{
/*
// list every parameters in its matching IParamBlock2
IParamBlock2 *pblockBasic=mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_basic_id);
IParamBlock2 *pblockMaps=mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_maps_id);
IParamBlock2 *pblockOptions=mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_options_id);
IParamBlock2 *pblockBRDF=mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_BRDF_id);
OutputDebugString("pblockBasic
");
for (int i=-1; ++i<pblockBasic->NumParams();)
{
OutputDebugString(" ");
OutputDebugString(pblockBasic->GetLocalName(pblockBasic->IndextoID(i)));
OutputDebugString("
");
}
OutputDebugString(_T("pblockMaps
"));
for (int i=-1; ++i<pblockMaps->NumParams();)
{
OutputDebugString(" ");
OutputDebugString(pblockMaps->GetLocalName(pblockMaps->IndextoID(i)));
OutputDebugString("
");
}
OutputDebugString(_T("pblockOptions
"));
for (int i=-1; ++i<pblockOptions->NumParams();)
{
OutputDebugString(" ");
OutputDebugString(pblockOptions->GetLocalName(pblockOptions->IndextoID(i)));
OutputDebugString("
");
}
OutputDebugString(_T("pblockBRDF
"));
for (int i=-1; ++i<pblockBRDF->NumParams();)
{
OutputDebugString(" ");
OutputDebugString(pblockBRDF->GetLocalName(pblockBRDF->IndextoID(i)));
OutputDebugString("
");
}
*/
TimeValue t = GetStaticFrame();
BOOL map_on;
float map_mult;
Color ambient_color(0.75, 0.75, 0.75);
Color diffuse_color(0.75, 0.75, 0.75);
Color reflection_color(0.0, 0.0, 0.0); // specular color
Color emissive_color(0.0, 0.0, 0.0);
float reflection_glossiness = 10.0f; // specular power
float transparency = 1.0f; // diffuse color alpha component
BOOL option_doubleSided = true;
Texmap *diffuse_texture = NULL;
//--
// Get VRay Material Properties
IParamBlock2 *pblockBasic = mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_basic_id);
IParamBlock2 *pblockMaps = mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_maps_id);
IParamBlock2 *pblockOptions = mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_options_id);
IParamBlock2 *pblockMaps = mtl->GetParamBlockByID(VRayMtlParameters::vrayMtl_maps_id);
// get colors
diffuse_color = pblockBasic->GetColor(VRayMtlParameters::pb_diffuse_color, t);
ambient_color = diffuse_color;
reflection_color = pblockBasic->GetColor(VRayMtlParameters::pb_reflect_color, t);
// get specular level
// from the "Reflection Glossiness" spinner [formula: (100* (1-value))]
reflection_glossiness = 100.0f * (1.0f - (pblockBasic->GetFloat(VRayMtlParameters::pb_reflect_glossiness, t)));
// get transparency value from the "Maps" rollout
map_on = pblockMaps->GetInt(VRAYMTL_TEXMAP_ON_PARAMID(SUBTEXNO_OPACITY), t);
if (map_on)
{
map_mult = pblockMaps->GetFloat(VRAYMTL_TEXMAP_MULT_PARAMID(SUBTEXNO_OPACITY), t);
transparency = (map_mult / 100.0f);
}
else
{
transparency = 1.0f;
}
// get both-sided value
option_doubleSided = pblockOptions->GetInt(VRayMtlParameters::pb_doubleSided);
// Diffuse map
int diffuse_map_on;
Texmap* diffuse_texture = NULL;
diffuse_map_on = pblockMaps->GetInt(VRAYMTL_TEXMAP_ON_PARAMID(SUBTEXNO_DIFFUSE), t);
if (diffuse_map_on)
{
diffuse_texture = pblockMaps->GetTexmap(VRAYMTL_TEXMAP_PARAMID(SUBTEXNO_DIFFUSE));
}
}