void Gradient::Init() { if (uvGen) uvGen->Reset(); else ReplaceReference( UVGEN_REF, GetNewDefaultUVGen()); if (texout) texout->Reset(); else ReplaceReference( TEXOUT_REF, GetNewDefaultTextureOutput()); ivalid.SetEmpty(); }
ParamDlg* SampleShaderPlugin::CreateParamDlg(HWND hwMtlEdit, IMtlParams *imp) { IAutoMParamDlg* masterDlg = SampleShaderPluginDesc.CreateParamDlgs(hwMtlEdit, imp, this); uvGenDlg = uvGen->CreateParamDlg(hwMtlEdit, imp); masterDlg->AddDlg(uvGenDlg); //TODO: Set the user dialog proc of the param block, and do other initialization return masterDlg; }
//From MtlBase void SampleShaderPlugin::Reset() { if (uvGen) uvGen->Reset(); else ReplaceReference( 0, GetNewDefaultUVGen()); //TODO: Reset texmap back to its default values ivalid.SetEmpty(); }
//From MtlBase void CrackVisualizer::Reset() { if (uvGen) uvGen->Reset(); else ReplaceReference( 0, GetNewDefaultUVGen()); //TODO: Reset texmap back to its default values ivalid.SetEmpty(); }
Point3 Gradient::EvalNormalPerturb(ShadeContext& sc) { Point3 dPdu, dPdv; if (!sc.doMaps) return Point3(0,0,0); if (gbufID) sc.SetGBufferID(gbufID); Point2 dM = uvGen->EvalDeriv(sc,&mysamp); uvGen->GetBumpDP(sc,dPdu,dPdv); #if 0 // Blinn's algorithm Point3 N = sc.Normal(); Point3 uVec = CrossProd(N,dPdv); Point3 vVec = CrossProd(N,dPdu); Point3 np = -dM.x*uVec+dM.y*vVec; #else // Lazy algorithm Point3 np = dM.x*dPdu+dM.y*dPdv; // return texout->Filter(dM.x*dPdu+dM.y*dPdv); #endif Texmap* sub[3]; for (int i=0; i<3; i++) sub[i] = mapOn[i]?subTex[i]:NULL; if (sub[0]||sub[1]||sub[2]) { // d((1-k)*a + k*b ) = dk*(b-a) + k*(db-da) + da float a,b,k; Point3 da,db; Point2 UV, dUV; uvGen->GetUV(sc, UV,dUV); k = gradFunc(UV.x,UV.y); if (k<=center) { k = k/center; EVALSUBPERTURB(a,da,2); EVALSUBPERTURB(b,db,1); } else { k = (k-center)/(1.0f-center); EVALSUBPERTURB(a,da,1); EVALSUBPERTURB(b,db,0); } np = (b-a)*np + k*(db-da) + da; } return texout->Filter(np); }
float Gradient::EvalMono(ShadeContext& sc) { if (!sc.doMaps) return 0.0f; float f; if (sc.GetCache(this,f)) return f; if (gbufID) sc.SetGBufferID(gbufID); f = texout->Filter(uvGen->EvalUVMapMono(sc,&mysamp)); sc.PutCache(this,f); return f; }
AColor Gradient::EvalColor(ShadeContext& sc) { if (!sc.doMaps) return black; AColor c; if (sc.GetCache(this,c)) return c; if (gbufID) sc.SetGBufferID(gbufID); c = texout->Filter(uvGen->EvalUVMap(sc,&mysamp)); sc.PutCache(this,c); return c; }
BITMAPINFO* Gradient::GetVPDisplayDIB(TimeValue t, TexHandleMaker& thmaker, Interval &valid, BOOL mono, BOOL forceW, BOOL forceH) { Bitmap* bm = NULL; Interval v; Update(t,v); bm = BuildBitmap(thmaker.Size()); BITMAPINFO *bmi = thmaker.BitmapToDIB(bm,uvGen->SymFlags(),0,forceW,forceH); bm->DeleteThis(); valid.SetInfinite(); Color ac; pblock->GetValue( grad_color1, t, ac, valid ); pblock->GetValue( grad_color2, t, ac, valid ); pblock->GetValue( grad_color3, t, ac, valid ); return bmi; }
void Gradient::Update(TimeValue t, Interval& valid) { if (!ivalid.InInterval(t)) { ivalid.SetInfinite(); uvGen->Update(t,ivalid); texout->Update(t,ivalid); pblock->GetValue( grad_color1, t, col[0], ivalid ); col[0].ClampMinMax(); pblock->GetValue( grad_color2, t, col[1], ivalid ); col[1].ClampMinMax(); pblock->GetValue( grad_color3, t, col[2], ivalid ); col[2].ClampMinMax(); pblock->GetValue( grad_map1_on, t, mapOn[0], ivalid); pblock->GetValue( grad_map2_on, t, mapOn[1], ivalid); pblock->GetValue( grad_map3_on, t, mapOn[2], ivalid); pblock->GetValue( grad_type, t, type, ivalid ); pblock->GetValue( grad_noise_type, t, noiseType, ivalid ); pblock->GetValue( grad_amount, t, amount, ivalid ); pblock->GetValue( grad_size, t, size, ivalid ); pblock->GetValue( grad_phase, t, phase, ivalid ); pblock->GetValue( grad_center, t, center, ivalid ); pblock->GetValue( grad_levels, t, levels, ivalid ); pblock->GetValue( grad_high_thresh, t, high, ivalid ); pblock->GetValue( grad_low_thresh, t, low, ivalid ); pblock->GetValue( grad_thresh_smooth, t, smooth, ivalid ); if (low>high) { float temp = low; low = high; high = temp; } hminusl = (high-low); sd = hminusl*0.5f*smooth; if (size!=0.0f) size1 = 20.0f/size; else size1 = 0.0f; for (int i=0; i<NSUBTEX; i++) { if (subTex[i]) subTex[i]->Update(t,ivalid); } EnableStuff(); } valid &= ivalid; }
ParamDlg* Gradient::CreateParamDlg(HWND hwMtlEdit, IMtlParams *imp) { // JBW: the main difference here is the automatic creation of a ParamDlg by the new // ClassDesc2 function CreateParamDlgs(). This mirrors the way BeginEditParams() // can be redirected to the ClassDesc2 for automatic ParamMap2 management. In this // case a special subclass of ParamDlg, AutoMParamDlg, defined in IParamm2.h, is // created. It can act as a 'master' ParamDlg to which you can add any number of // secondary dialogs and it will make sure all the secondary dialogs are kept // up-to-date and deleted as necessary. // Here you see we create the Coordinate, Gradient and Output ParamDlgs in the desired // order, and then add the Coordinate and Output dlgs as secondaries to the // Gradient master AutoMParamDlg so it will keep them up-to-date automatically // create the rollout dialogs uvGenDlg = uvGen->CreateParamDlg(hwMtlEdit, imp); IAutoMParamDlg* masterDlg = gradCD.CreateParamDlgs(hwMtlEdit, imp, this); texoutDlg = texout->CreateParamDlg(hwMtlEdit, imp); // add the secondary dialogs to the master masterDlg->AddDlg(uvGenDlg); masterDlg->AddDlg(texoutDlg); EnableStuff(); return masterDlg; }
ULONG SampleShaderPlugin::LocalRequirements(int subMtlNum) { //TODO: Specify various requirements for the material return uvGen->Requirements(subMtlNum); }
int GetMapChannel () { return uvGen->GetMapChannel (); }
// Requirements ULONG LocalRequirements(int subMtlNum) { return uvGen->Requirements(subMtlNum); }
int GetUVWSource() { return uvGen->GetUVWSource(); }
// TODO: Return the tiling state of the texture for use in the viewports int GetTextureTiling() { return uvGen->GetTextureTiling(); }
// TODO: Return UV transformation matrix for use in the viewports void GetUVTransform(Matrix3 &uvtrans) { uvGen->GetUVTransform(uvtrans); }
void LocalMappingsRequired(int subMtlNum, BitArray & mapreq, BitArray &bumpreq) { uvGen->MappingsRequired(subMtlNum,mapreq,bumpreq); }
ULONG CrackVisualizer::LocalRequirements(int subMtlNum) { //TODO: Specify various requirements for the material // MTLREQ_PREPRO will cause the buildmaps to be called every frame return uvGen->Requirements(subMtlNum) | MTLREQ_PREPRO; }
void InitSlotType(int sType) {if (uvGen) uvGen->InitSlotType(sType);}