本文整理汇总了C++中VisibilityTester::isOccluded方法的典型用法代码示例。如果您正苦于以下问题:C++ VisibilityTester::isOccluded方法的具体用法?C++ VisibilityTester::isOccluded怎么用?C++ VisibilityTester::isOccluded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisibilityTester
的用法示例。
在下文中一共展示了VisibilityTester::isOccluded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: estimateDirectLighting
Spectrum Path::estimateDirectLighting( const RayIntersection i_intersection, RenderablePtr i_light, const Sampler &i_sampler, const SceneData &i_scene )
{
// Direct contribution
Spectrum Ld = Spectrum::black();
float lightPdf = 0.0f;
float surfacePdf = 0.0f;
vec3f wiWorld;
const vec3f &woWorld = -i_intersection.dir;
const vec3f &woLocal = i_intersection.worldToSurface( woWorld );
const vec3f &normal = i_intersection.getSurfacePoint().normal;
const shading::BSDF &bsdf = i_intersection.getBSDF();
/* ==================== */
/* Sample Light */
/* ==================== */
{
VisibilityTester visibilityTester;
const vec3f &uLight = i_sampler.sample3D();
Spectrum Li = i_light->sampleIncidenceRadiance( i_intersection, uLight, &wiWorld, &lightPdf, &visibilityTester );
// Convert to local (surface) coords
const vec3f &wiLocal = i_intersection.worldToSurface( wiWorld );
// Sample light
if ( !Li.isBlack() && lightPdf > 0.0f ) {
const Spectrum &f = bsdf.computeF( woLocal, wiLocal ) * absDot( wiWorld, normal );
surfacePdf = bsdf.pdf( woLocal, wiLocal );
if ( !f.isBlack() ) {
// Ray is in shadow
if ( visibilityTester.isOccluded( i_scene ) ) {
Li = Spectrum::black();
}
if ( !Li.isBlack() ) {
// Weight with MIS
float misWeight = powerHeuristic( lightPdf, surfacePdf );
Ld += ( Li * f * misWeight ) / lightPdf;
}
}
}
}
/* ==================== */
/* Sample BSDF */
/* ==================== */
{
const vec2f &uSurface = i_sampler.sample2D();
vec3f wiLocal;
const Spectrum &f = bsdf.sampleF( woLocal, &wiLocal, uSurface, &surfacePdf ) * absDot( wiWorld, normal );
if ( !f.isBlack() && surfacePdf > 0.0f ) {
// TODO computer light PDF
lightPdf = 0.0;
// No contribution, return
if ( lightPdf == 0.0 ) {
return Ld;
}
// Convert to local (surface) coords
vec3f wiWorld = i_intersection.surfaceToWorld( wiLocal );
const Ray bsdfRay = Ray( i_intersection.getSurfacePoint().pos, wiWorld );
RayIntersection lightIntersection;
bool foundIntersection = i_scene.intersect( bsdfRay, lightIntersection );
Spectrum Li = Spectrum::black();
if ( foundIntersection ) {
if ( lightIntersection.m_shapeId == i_light->getIdentifier() ) {
Li = i_light->computeRadiance( lightIntersection.getSurfacePoint(), wiWorld );
}
}
if ( !Li.isBlack() ) {
// Weight with MIS
float misWeight = powerHeuristic( lightPdf, surfacePdf );
Ld += ( Li * f * misWeight ) / surfacePdf;
}
}
}
return Ld;
}