本文整理汇总了C++中ShadeContext::BumpBasisVectors方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadeContext::BumpBasisVectors方法的具体用法?C++ ShadeContext::BumpBasisVectors怎么用?C++ ShadeContext::BumpBasisVectors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadeContext
的用法示例。
在下文中一共展示了ShadeContext::BumpBasisVectors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Illum
void WardShader::Illum(ShadeContext &sc, IllumParams &ip) {
LightDesc *l;
Color lightCol;
#ifdef _DEBUG
IPoint2 sp = sc.ScreenCoord();
if ( sp.x == stopX && sp.y == stopY )
sp.x = stopX;
#endif
BOOL isShiny= (ip.channels[W_SL].r > 0.0f) ? 1 : 0;
for (int i=0; i<sc.nLights; i++) {
l = sc.Light(i);
float NL, Kl;
Point3 L;
if (l->Illuminate( sc, sc.Normal(), lightCol, L, NL, Kl)) {
if (l->ambientOnly) {
ip.ambIllumOut += lightCol;
continue;
}
if (NL<=0.0f)
continue;
// diffuse
if (l->affectDiffuse){
ip.diffIllumOut += Kl / Pi * ip.channels[W_DL].r * lightCol;
}
// specular
if (isShiny && l->affectSpecular) {
float gx = ip.channels[W_GX].r;
float gy = ip.channels[W_GY].r;
assert( gx >= 0.0f && gy >= 0.0f );
Point3 H = Normalize(L - sc.V() ); // (L + -V)/2
float NH = DotProd(sc.Normal(), H);
if (NH > 0.0f) {
float g2 = normalizeOn ? gx * gy : DEFAULT_GLOSS2;
float norm = 1.0f / (4.0f * PI * g2);
float NV = -DotProd(sc.Normal(), sc.V() );
if ( NV <= 0.001f)
NV = 0.001f;
float g = 1.0f / (float)sqrt( NL * NV );
if ( g > 6.0f ) g = 6.0f;
//Point3 basisVecs[ 3 ];
//sc.DPdUVW( basisVecs, uvChan ); // 0 is vtxclr, 1..n is uv channels, max_meshmaps in mesh.h
//basisVecs[0] = Normalize( basisVecs[0] );
// This is the new preferred method for getting bump basis vectors -- DS 5/22/00
Point3 basisVecs[2];
sc.BumpBasisVectors(basisVecs, 0, uvChan);
// the line between the tip of vec[0] and its projection on N is tangent
Point3 T = basisVecs[0] - sc.Normal() * Dot( basisVecs[0], sc.Normal() );
Point3 B = CrossProd( sc.Normal(), T );
float x = DotProd( H, T ) / gx;
float y = DotProd( H, B ) / gy;
float e = (float)exp( -2.0 * (x*x + y*y) / (1.0+NH) );
ip.specIllumOut += Kl * ip.channels[W_SL].r * norm * g * e * lightCol;
}
}
}
} // for each light
// now we can multiply by the clrs,
ip.ambIllumOut *= ip.channels[W_AM];
ip.diffIllumIntens = Intens(ip.diffIllumOut);
ip.diffIllumOut *= ip.channels[W_DI];
ip.specIllumOut *= ip.channels[W_SP];
int chan = ip.stdIDToChannel[ ID_RR ];
ShadeTransmission(sc, ip, ip.channels[chan], ip.refractAmt);
chan = ip.stdIDToChannel[ ID_RL ];
ShadeReflection( sc, ip, ip.channels[chan] );
if (sc.globContext != NULL && sc.globContext->pToneOp != NULL) {
if (isInvertSelfIllum())
sc.globContext->pToneOp->RGBToScaled(ip.selfIllumOut);
if (isInvertReflect() && (ip.hasComponents & HAS_REFLECT))
sc.globContext->pToneOp->RGBToScaled(ip.reflIllumOut);
if (isInvertRefract() && (ip.hasComponents & HAS_REFRACT))
sc.globContext->pToneOp->RGBToScaled(ip.transIllumOut);
}
CombineComponents( sc, ip );
}