------------------------------------------------------------------------------
| 3182 | |
| 3183 | //------------------------------------------------------------------------------ |
| 3184 | void vtkOpenGLGPUVolumeRayCastMapper::GPURender(vtkRenderer* ren, vtkVolume* vol) |
| 3185 | { |
| 3186 | vtkOpenGLClearErrorMacro(); |
| 3187 | |
| 3188 | const bool isInteractive = vol->GetAllocatedRenderTime() < 1.0; |
| 3189 | const auto previousVolumetricScatteringBlending = this->VolumetricScatteringBlending; |
| 3190 | if (isInteractive) |
| 3191 | { |
| 3192 | // Turn off volumetric multi-scattering for interactive renders |
| 3193 | this->VolumetricScatteringBlending = 0; |
| 3194 | } |
| 3195 | |
| 3196 | vtkOpenGLCamera* cam = vtkOpenGLCamera::SafeDownCast(ren->GetActiveCamera()); |
| 3197 | |
| 3198 | if (this->GetBlendMode() == vtkVolumeMapper::ISOSURFACE_BLEND && |
| 3199 | vol->GetProperty()->GetIsoSurfaceValues()->GetNumberOfContours() == 0) |
| 3200 | { |
| 3201 | // Early exit: nothing to render. |
| 3202 | return; |
| 3203 | } |
| 3204 | |
| 3205 | vtkOpenGLRenderWindow* renWin = vtkOpenGLRenderWindow::SafeDownCast(ren->GetRenderWindow()); |
| 3206 | this->ResourceCallback->RegisterGraphicsResources(renWin); |
| 3207 | // Make sure the context is current |
| 3208 | renWin->MakeCurrent(); |
| 3209 | |
| 3210 | // Get window size and corners |
| 3211 | this->Impl->CheckPropertyKeys(vol); |
| 3212 | if (!this->Impl->PreserveViewport) |
| 3213 | { |
| 3214 | ren->GetTiledSizeAndOrigin(this->Impl->WindowSize, this->Impl->WindowSize + 1, |
| 3215 | this->Impl->WindowLowerLeft, this->Impl->WindowLowerLeft + 1); |
| 3216 | } |
| 3217 | else |
| 3218 | { |
| 3219 | int vp[4]; |
| 3220 | glGetIntegerv(GL_VIEWPORT, vp); |
| 3221 | this->Impl->WindowLowerLeft[0] = vp[0]; |
| 3222 | this->Impl->WindowLowerLeft[1] = vp[1]; |
| 3223 | this->Impl->WindowSize[0] = vp[2]; |
| 3224 | this->Impl->WindowSize[1] = vp[3]; |
| 3225 | } |
| 3226 | |
| 3227 | this->Impl->NeedToInitializeResources = |
| 3228 | (this->Impl->ReleaseResourcesTime.GetMTime() > this->Impl->InitializationTime.GetMTime()); |
| 3229 | |
| 3230 | this->ComputeReductionFactor(vol->GetAllocatedRenderTime()); |
| 3231 | if (!this->Impl->SharedDepthTextureObject) |
| 3232 | { |
| 3233 | this->Impl->CaptureDepthTexture(ren); |
| 3234 | } |
| 3235 | |
| 3236 | vtkMTimeType renderPassTime = this->GetRenderPassStageMTime(vol); |
| 3237 | |
| 3238 | const auto multiVol = vtkMultiVolume::SafeDownCast(vol); |
| 3239 | this->Impl->MultiVolume = multiVol && this->GetInputCount() > 1 ? multiVol : nullptr; |
| 3240 | |
| 3241 | this->Impl->ClearRemovedInputs(renWin); |
no test coverage detected