Announcement

Collapse
No announcement yet.

Getting/Setting the material effectID in VRayMtl

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting/Setting the material effectID in VRayMtl

    I've made a few helper functions in .NET to scan xref scenes (recursively) for object and material id's. Obviously the regular method doesn't work with VRayMtl override effect id. Where abouts do I get this? I printed out all the pblocks and didn't see anything obvious.

    If it matters, we're using VRay 2.4 here.

  • #2
    Nothing? I'm also using a GUP done in C++ so I just would like to know what property I should be looking up. I'm not tied to c#.

    Comment


    • #3
      It should work fine, from MaxScript at least. The parameters are called "effect_id" and "override_effect_id"

      Best regards,
      Vlado
      I only act like I know everything, Rogers.

      Comment


      • #4
        Oh I know it works from maxscript - I'm trying to get it from C++.

        Comment


        • #5
          Something like this should work:
          Code:
          enum {
          	vrayMtl_basic_id=1,
          	vrayMtl_BRDF_id,
          	vrayMtl_options_id,
          	vrayMtl_maps_id,
          	vrayMtl_reflIMap_id,
          	vrayMtl_refrIMap_id,
          };
          
          enum {
          	pb_effect_id=78,
          	pb_override_effect_id,
          };
          
          ...
          Mtl *mtl=...;
          if (mtl) {
          	IParamBlock2 *pblockOptions=mtl->GetParamBlockByID(vrayMtl_options_id);
          	if (pblockOptions) {
          		int effectID=pblockOptions->GetInt(pb_effect_id);
          		int overrideEffectID=pblockOptions->GetInt(pb_override_effect_id);
          	}
          }
          Best regards,
          Vlado
          I only act like I know everything, Rogers.

          Comment


          • #6
            Brilliant, tested and works - thanks Vlado. Here's the C# code if anyone is interested:

            Code:
            public static IClass_ID CLASSID_VRAYMTL = GlobalInterface.Instance.Class_ID.Create(935280431, 1882483036);
            
            public static int GetVRayEffectId(IMtl mtl)
            {
                if (mtl.ClassID.OperatorNotEquals(CLASSID_VRAYMTL) == 1)
                    return -1;
            
                var effectId = -1;
                var overrideEffectId = -1;
            
                var pblock = mtl.GetParamBlockByID(3);
                if(pblock != null)
                {
                    effectId = pblock.GetInt(78, GlobalInterface.Instance.COREInterface14.Time, 0);
                    overrideEffectId = pblock.GetInt(79, GlobalInterface.Instance.COREInterface14.Time, 0);
                }
            
                return overrideEffectId == 1 ? effectId : (int) mtl.GBufID;
            }

            Comment

            Working...
            X