예제 #1
0
void RadiosityRenderer::computeStep() {

    PatchRandomAccessEnumerator &patch = *patchEnumerator_;

    // Initialize radiosityLast tag of Triangle objects
    for(int i=0; i<patchCount_; i++) {
        Triangle &dest = patch[i];
        dest.radiosityLast = dest.radiosity;
        (*sceneRadiosity_)[i] = dest.radiosity;
    }

    if(patchCache_->full())
    {
        // OpenGL uses thread-local storage (all GL calls
        // must be from the thread that owns the context)
        // if the cache is full then OpenGL can't be called
        // which makes it safe to parallelize this loop
        #pragma omp parallel for
        for(int p = 0; p < patchCount_; ++p)
            computePatch(p, false, true);
    }
    else
    {
        // Compute new step
        for(currentPatch_=0; currentPatch_<patchCount_; currentPatch_++)
        {
            notifyPerStepProgress();
            computePatch(currentPatch_, currentStep_ == 0, false);
        }
    }
}
예제 #2
0
void RadiosityRenderer::computeStep() {

    PatchRandomAccessEnumerator &patch = *patchEnumerator_;

    // Initialize radiosityLast tag of Triangle objects
    for(int i=0; i<patchCount_; i++) {
        Triangle &dest = patch[i];
        dest.radiosityLast = dest.radiosity;
    }

    // Compute new step
    for(currentPatch_=0; currentPatch_<patchCount_; currentPatch_++) {
        notifyPerStepProgress();

        // Compute radiosity
        Triangle &dest = patch[currentPatch_];
        Color &rad = dest.radiosity;
        rad = patchCache_->totalRadiosity(currentPatch_);
        rad *= dest.reflectivity;
        rad += dest.emission;

        updateColorPeak(rad);
    }
}