{ SCCSid "$SunId$ LBL" } { Interpolate triangle-mesh values using barycentric coordinates. A1 = Major axis (0==X, 1==Y, 2==Z) A2 through A7 = Transformation for barycentric system and: A8 through A16 = Surface normal perturbation matrix or: A8 through A13 = Lookup in 2-dimensional pattern or texture } { Compute barycentric coordinates } bu = select(arg(1)+1, Py, Pz, Px); bv = select(arg(1)+1, Pz, Px, Py); a = bu*arg( 2) + bv*arg( 3) + arg( 4); b = bu*arg( 5) + bv*arg( 6) + arg( 7); c = 1 - a - b; { Compute variables } v1 = a*arg( 8) + b*arg( 9) + c*arg(10); v2 = a*arg(11) + b*arg(12) + c*arg(13); v3 = a*arg(14) + b*arg(15) + c*arg(16); { Surface normal perturbation } nf = 1/sqrt(v1*v1 + v2*v2 + v3*v3); dx = v1*nf - Nx; dy = v2*nf - Ny; dz = v3*nf - Nz; { Lookup table index } u = v1; v = v2;