本文整理汇总了C++中BSDF::G方法的典型用法代码示例。如果您正苦于以下问题:C++ BSDF::G方法的具体用法?C++ BSDF::G怎么用?C++ BSDF::G使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BSDF
的用法示例。
在下文中一共展示了BSDF::G方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShootCausticsPhoton
void PhotonMap::ShootCausticsPhoton(const Vector &dir, const Vector &pi, const Color &color, Shape *shape, int depth)
{
if ( depth >= confPhotonCausticsMaximumDepth ) return;
if ( depth != 0 && shape->mMaterial->MatchesBSDFFlags(BSDF_DIFFUSE) ) {
// Diffuse material, add photon
Photon *photon = new Photon(color, dir);
AddPhoton(causticsMap, pi, photon);
} else if ( shape->mMaterial->MatchesBSDFFlags(BSDF_SPECULAR) ) {
// Specular material, continue build photon
Vector N = shape->GetNormal(pi);
for ( uint32_t i = 0; i < shape->mMaterial->BSDFs.size(); i++ ) {
BSDF *bsdf = shape->mMaterial->BSDFs[i];
if ( !bsdf->MatchesFlags(BSDFType(BSDF_SPECULAR)) ) continue;
Vector newDir;
Color matColor;
Vector *vos = NULL;
int voNum = 0;
if ( bsdf->G(-dir, vos, voNum, N, matColor, 1.f) ) {
_ASSERT(voNum > 0);
newDir = vos[0];
delete [] vos;
vos = NULL;
matColor *= shape->GetColor(pi);
if ( matColor.IsBlack() ) continue;
float dist = MAXDISTANCE;
Shape *newShape;
Vector norm = N.Dot(dir) > 0 ? -N : N;
if ( bsdf->MatchesFlags(BSDF_TRANSMISSION) ) norm = -norm;
if ( scene->FindNearest(Ray(pi + norm * EPSILON, newDir), dist, newShape) == IR_MISS )
continue;
ShootCausticsPhoton(newDir, pi + newDir * dist, color * matColor, newShape, depth + 1);
}
}
}
}