AColor mrTwoSidedShader::EvalColor(ShadeContext& sc) { // Provide a good default for this (for the material editor peview)... // Use the front color for the top half of the screen the the back color // for the bottom half. if(m_mainPB != NULL) { Point2 screenUV; Point2 screenDUV; sc.ScreenUV(screenUV, screenDUV); // Front map is used for top part of the image bool useFront = (screenUV.y > 0.5f); TimeValue t = sc.CurTime(); BOOL mapOn = m_mainPB->GetInt(useFront ? kMainPID_FrontMapOn : kMainPID_BackMapOn, t); if(mapOn) { Texmap* map = m_mainPB->GetTexmap(useFront ? kMainPID_FrontMap : kMainPID_BackMap, t); if(map != NULL) { return map->EvalColor(sc); } } // Return the color only AColor col = m_mainPB->GetAColor(useFront ? kMainPID_FrontColor : kMainPID_BackColor, t); return col; } return AColor(0,0,0); }
AColor UVtex::EvalColor(ShadeContext& sc) { if (gbufID) sc.SetGBufferID(gbufID); #if MAX_RELEASE > 3100 Point3 uvw; if (uvChannel < 0) { if (sc.InMtlEditor()) { Point2 a, b; sc.ScreenUV(a, b); uvw = Point3(a.x, a.y, 0.0f); } else if (sc.globContext != NULL && sc.NodeID() >= 0) { RenderInstance* ri = sc.globContext->GetRenderInstance(sc.NodeID()); Mesh* m = ri->mesh; if (m->mapSupport(uvChannel)) { Point3 bc = sc.BarycentricCoords(); int i = sc.FaceNumber(); UVVert* v = m->mapVerts(uvChannel); TVFace* f = m->mapFaces(uvChannel); uvw = v[f[i].t[0]] * bc.x + v[f[i].t[1]] * bc.y + v[f[i].t[2]] * bc.z; } else { uvw = Point3(0.0,0.0,0.0); } } else { uvw = Point3(0.0,0.0,0.0); } } else { uvw = sc.UVW(uvChannel); } #else Point3 uvw = sc.UVW(uvChannel); #endif if (clampUVW) { uvw.x = Clamp(uvw.x); uvw.y = Clamp(uvw.y); uvw.z = Clamp(uvw.z); } else { uvw.x = mod(uvw.x, 1.0000001f); uvw.y = mod(uvw.y, 1.0000001f); uvw.z = mod(uvw.z, 1.0000001f); } return EvalUVtex(uvw); }