i wrote a custom material shader for maya, all has gone very well until I put it in a override field of a basic surface shader( ex. Reflection Material. ), and in the final image, i got the object shaded in a basic shading. I looked in the vray_MtlOverride.cpp and I noticed that override's shade() calls my overriding material's shade(). I tried printing something when my own material's shade() is called. But nothing was printed... So I supposed that override material has not called my material's shade() at all??? How that could happen?? Am I missing something?
Best regards
thekraken
here is a simple pseudo code of my material shader:
Best regards
thekraken
here is a simple pseudo code of my material shader:
Code:
using namespace VR; // Plugin parameters struct MyMaterialParams: VRayParameterListDesc { MyMaterialParams(void) { ////////////////// } ; // The plugin itself struct MyMaterialMyMaterial: VRayMaterial { MyMaterial(VRayPluginDesc *desc):VRayMaterial(desc) { ///////// } // From VRayPlugin void renderBegin(VRayRenderer *vray) { brdf_pool.init(vray->getSequenceData().maxRenderThreads); } void renderEnd(VRayRenderer *vray) { brdf_pool.freeMem(); } void frameBegin(VR::VRayRenderer *vray); // From MaterialInterface void shade(VR::VRayContext &rc); // From BRDFInterface BSDFSampler *newBSDF(const VR::VRayContext &rc, BSDFFlags flags) { VR::DiffuseBRDF *bsdf=brdf_pool.newBRDF(rc); initBSDF(rc, *bsdf); return static_cast<BSDFSampler*>(bsdf); } void deleteBSDF(const VR::VRayContext &rc, BSDFSampler *bsdf) { if (bsdf) brdf_pool.deleteBRDF(rc, (VR::DiffuseBRDF*) bsdf); } void initBSDF(const VRayContext &rc, VR::DiffuseBRDF &brdf); PluginBase* getPlugin() { return static_cast<PluginBase*>(this); } virtual PluginInterface* newInterface(InterfaceID id) { if( id == EXT_RTMTL ) { return static_cast<PluginInterface*>((RTMtlInterface*)this); } return VRayMaterial::newInterface(id); } private: // Cached parameters ////////////////////// BRDFPool<VR::DiffuseBRDF> brdf_pool; }; // Define the plugin #define MyMaterial_PluginID PluginID(LARGE_CONST(2012022011)) SIMPLE_PLUGIN_LIBRARY(MyMaterial_PluginID, EXT_MATERIAL, "MyMaterial", "MyMaterial for VRay", MyMaterial, MyMaterialParams); void MyMaterial::frameBegin(VR::VRayRenderer *vray) { VRayMaterial::frameBegin(vray); } void MyMaterial::initBSDF(const VRayContext &rc, VR::DiffuseBRDF &bsdf) { std::cout<< "initBSDF is called"<<std::endl; Color diffuse=combineTex(rc, diffuse_tex, Color(0.0,0.0,0.0),1.0); bsdf.init(diffuse, Color(.0,.0,.0), rc); } void MyMaterial::shade(VR::VRayContext &rc) { std::cout<< "shade is called" <<std::endl; Color alpha=transparency.whiteComplement(); if ((rc.rayparams.rayType & RT_SHADOW) || rc.rayresult.realBack) { rc.mtlresult.color.makeZero(); rc.mtlresult.transp=transparency; rc.mtlresult.alpha=alpha; rc.mtlresult.alphaTransp=transparency; return; } /* computing */ rc.mtlresult.color+=result; rc.mtlresult.transp=transparency; rc.mtlresult.alpha=alpha; rc.mtlresult.alphaTransp=transparency; }
Comment