Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /****************************************************************************
- 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\n");
- for (int i=-1; ++i<pblockBasic->NumParams();)
- {
- OutputDebugString("\t");
- OutputDebugString(pblockBasic->GetLocalName(pblockBasic->IndextoID(i)));
- OutputDebugString("\n");
- }
- OutputDebugString(_T("pblockMaps\n"));
- for (int i=-1; ++i<pblockMaps->NumParams();)
- {
- OutputDebugString("\t");
- OutputDebugString(pblockMaps->GetLocalName(pblockMaps->IndextoID(i)));
- OutputDebugString("\n");
- }
- OutputDebugString(_T("pblockOptions\n"));
- for (int i=-1; ++i<pblockOptions->NumParams();)
- {
- OutputDebugString("\t");
- OutputDebugString(pblockOptions->GetLocalName(pblockOptions->IndextoID(i)));
- OutputDebugString("\n");
- }
- OutputDebugString(_T("pblockBRDF\n"));
- for (int i=-1; ++i<pblockBRDF->NumParams();)
- {
- OutputDebugString("\t");
- OutputDebugString(pblockBRDF->GetLocalName(pblockBRDF->IndextoID(i)));
- OutputDebugString("\n");
- }
- */
- 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));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement