Apart from mentioned Boolean flag, Path Tracing requires a plenty of setup:
Enabling Ray Tracing (Graphic3d_RenderingParams::Method = Graphic3d_RM_RAYTRACING) + Path Tracing (Graphic3d_RenderingParams::IsGlobalIlluminationEnabled).
Configuring PBR materials for your models (simplified Graphic3d_MaterialAspect::PBRMaterial() and advanced Graphic3d_MaterialAspect::BSDF()).
You may start from importing some glTF 2.0 models, which are expected to have realistic materials.
Configuring light sources (Graphic3d_CLight) with proper power Graphic3d_CLight::Intensity (scalable to physical dimensions of your scene) and extra parameters specific to Path Tracing.
Configuring IBL (Image-Based-Lighting) for environment lighting (V3d_View::SetBackgroundCubeMap()).
Enabling continuous rendering for Path-Tracing to advance (AIS_ViewController::IsContinuousRedraw() or whatever you use in your application).
Configuring other Ray-Tracing parameters in Graphic3d_RenderingParams.
Ray Tracing doesn't use CUDA - it is implemented using OpenGL shader programs, so it is irrelevant which C++ compiler to use for building OCCT.
Default implementation of AIS_ViewController::SetContinuousRedraw() ends up in calling Aspect_Window::InvalidateContent(). In case of interconnection with GUI frameworks (like Qt in your case), this might not work as expected or do not work at all. If Aspect_NeutralWindow implementation is used or a custom subclass of Aspect_Window wrapping Qt widget - this method may do nothing.
In such cases, it is better checking documentation of your GUI framework for a best way to ask it continuously redrawing 3D widget content. Usually these mechanisms are used for drawing animation. In case of QtQuick, for instance, calling QQuickWindow::update() at the end of a frame (e.g. right after repainting OCCT 3D Viewer content) would be enough to ask Qt to draw one more frame. In case of QOpenGlWidget, this could be done by calling QOpenGlWidget::update() (see how AIS_ViewController::handleViewRedraw() is overridden to handle myToAskNextFrame):
AIS_ViewController::myToAskNextFrame is set to TRUE in case of some animation started or when AIS_ViewController::IsContinuousRedraw() is set. I guess that in case of a usual QWidget there should be some other way to do similar thing.
AIS_ViewController::SetContinuousRedraw() is just a helper to redraw view automatically again and again using native window invalidation routines like calling
InvalidateRect ((HWND )myHWindow, NULL, TRUE);
from WinAPI at the end of currently drawn frame (AIS_ViewController::HandleViewEvents()).
You may implement this redrawing logic on your own with help of GUI framework, like configuring multimedia timer redrawing the viewer at desired framerate (by calling V3d_View::Invalidate() and AIS_ViewController::FlushViewEvents()).
Sun, 12/05/2021 - 03:23
I found it:
ChangeRenderingParams().IsGlobalIlluminationEnabled = true;
problem is that it doesn't work or extremely slow. There is no load on the CPU, nor GPU.
I am running Window. But now I am worried that I have to switch to MSVC instead MinGW since CUDA is not avaliable for MinGW?
Sun, 12/05/2021 - 11:23
Apart from mentioned Boolean flag, Path Tracing requires a plenty of setup:
You may start from importing some glTF 2.0 models, which are expected to have realistic materials.
Ray Tracing doesn't use CUDA - it is implemented using OpenGL shader programs, so it is irrelevant which C++ compiler to use for building OCCT.
Draw Harness comes with a couple of samples of Path Tracing setups, which might be a good point to start with:
Tue, 12/07/2021 - 03:53
Thanks Kirill,
the missing part was - and is - AIS_ViewController::IsContinuousRedraw()
a workaround is a for to loop and Redraw().
I run 7.5.0 and it is not available there. Currently try to compile 7.6.0
Sun, 12/12/2021 - 21:36
I can't get the AIS_ViewController do anything. Ho do I get continuesRedraw going?
Thanks
Mon, 12/13/2021 - 13:56
Default implementation of AIS_ViewController::SetContinuousRedraw() ends up in calling Aspect_Window::InvalidateContent(). In case of interconnection with GUI frameworks (like Qt in your case), this might not work as expected or do not work at all. If Aspect_NeutralWindow implementation is used or a custom subclass of Aspect_Window wrapping Qt widget - this method may do nothing.
In such cases, it is better checking documentation of your GUI framework for a best way to ask it continuously redrawing 3D widget content. Usually these mechanisms are used for drawing animation. In case of QtQuick, for instance, calling QQuickWindow::update() at the end of a frame (e.g. right after repainting OCCT 3D Viewer content) would be enough to ask Qt to draw one more frame. In case of QOpenGlWidget, this could be done by calling QOpenGlWidget::update() (see how AIS_ViewController::handleViewRedraw() is overridden to handle myToAskNextFrame):
AIS_ViewController::myToAskNextFrame is set to TRUE in case of some animation started or when AIS_ViewController::IsContinuousRedraw() is set. I guess that in case of a usual QWidget there should be some other way to do similar thing.
Wed, 05/11/2022 - 05:34
HI,Kirill Gavrilov。 In OCCT7.5 has no method AIS_ViewController::SetContinuousRedraw()。Can use GPU Path-Tracing on 7.5?
Wed, 05/11/2022 - 13:09
AIS_ViewController::SetContinuousRedraw() is just a helper to redraw view automatically again and again using native window invalidation routines like calling
from WinAPI at the end of currently drawn frame (AIS_ViewController::HandleViewEvents()).
You may implement this redrawing logic on your own with help of GUI framework, like configuring multimedia timer redrawing the viewer at desired framerate (by calling V3d_View::Invalidate() and AIS_ViewController::FlushViewEvents()).