当前位置: 首页>>代码示例>>C++>>正文


C++ Light::Sample方法代码示例

本文整理汇总了C++中Light::Sample方法的典型用法代码示例。如果您正苦于以下问题:C++ Light::Sample方法的具体用法?C++ Light::Sample怎么用?C++ Light::Sample使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Light的用法示例。


在下文中一共展示了Light::Sample方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BuildIndirectPhotonMap

    void PhotonMap::BuildIndirectPhotonMap(int32_t n)
    {
        for ( LightIter iter = scene->mLights.begin(); iter != scene->mLights.end(); iter++ ) {
            Light *light = *iter;
            int32_t nPhotons = (int) (n * light->mIntensity);
            for ( int32_t i = 0; i < nPhotons; i++ ) {
                Color color;
                Vector pi, dir;
                Shape *shape = NULL;

                while ( true ) {
                    if ( confEnableDirectedPhotons ) {
                        Vector r(gRandom.Rand(), gRandom.Rand(), gRandom.Rand());
                        dir = confPhotonDirectedP1 + r * (confPhotonDirectedP2 - confPhotonDirectedP1) 
                            - light->GetCentroid();
                        dir.Normalize();
                    } else {
                        dir = light->RandomDirection(gRandom);
                    }
                    float dist = MAXDISTANCE;
                    if ( scene->FindNearest(Ray(light->GetCentroid(), dir), dist, shape) == IR_MISS ) 
                        continue;
                    pi = light->GetCentroid() + dir * dist;
                    color = light->Sample(pi);
                    if ( !color.IsBlack() ) break;
                }
                ShootIndirectPhoton(dir, pi, color, shape, 0);
            }
        }
    }
开发者ID:zhaoruoxu,项目名称:lyraefx,代码行数:30,代码来源:PhotonMap.cpp

示例2: BuildCausticsPhotonMap

 void PhotonMap::BuildCausticsPhotonMap(int32_t n)
 {
     vector<Shape *> causticsShapes;
     uint32_t causticsCount;
     for ( ShapeIter iter = scene->mShapes.begin(); iter != scene->mShapes.end(); iter++ ) {
         Shape *shape = *iter;
         if ( shape->GetType() == SHAPE_TRIANGLE ) continue;
         if ( shape->mMaterial->MatchesBSDFFlags(BSDF_SPECULAR) ) {
             causticsShapes.push_back(shape);
         }
     }
     causticsCount = causticsShapes.size();
     if ( causticsCount == 0 ) {
         Warning("No caustics shape.");
         return;
     }
     for ( LightIter iter = scene->mLights.begin(); iter != scene->mLights.end(); iter++ ) {
         Light *light = *iter;
         int32_t nPhotons = static_cast<int>(n * light->mIntensity);
         for ( int i = 0; i < nPhotons; i++ ) {
             Color color;
             Vector pi;
             Vector dir;
             Shape *shape = NULL;
             while ( true ) {
                 uint32_t shapeNr = static_cast<uint32_t>(gRandom.Rand() * causticsCount);
                 if ( shapeNr == causticsCount ) shapeNr = causticsCount-1;
                 Shape *causticsShape = causticsShapes[shapeNr];
                 AABB box = causticsShape->GetAABB();
                 Vector r(gRandom.Rand(), gRandom.Rand(), gRandom.Rand());
                 dir = box.mPos + box.mSize * r - light->GetCentroid();
                 dir.Normalize();
                 float dist = MAXDISTANCE;
                 if ( scene->FindNearest(Ray(light->GetCentroid(), dir), dist, shape) == IR_MISS )
                     continue;
                 pi = light->GetCentroid() + dir * dist;
                 color = light->Sample(pi);
                 if ( !color.IsBlack() ) break;
             }
             ShootCausticsPhoton(dir, pi, color, shape, 0);
         }
     }
 }
开发者ID:zhaoruoxu,项目名称:lyraefx,代码行数:43,代码来源:PhotonMap.cpp


注:本文中的Light::Sample方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。