DiscussionsIssue archiveOCCT:Visualization

Archived issue #0027607

Visualization - Implement adaptive screen space sampling in path tracing

Open CASCADEOCCT:Visualizationclosed62 public notes

Search issues

Description

TODO

Steps to reproduce

Activating the feature
vrenderparams -iss

Activating debug mode
vrenderparams -issd

Public activity

62 archived notes

Participants are labeled by their role within this record.

01Commenter 4
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Jun 15 13:59:26 2016 +0300

    3!

Author: Author
Date: Tue Jun 14 16:53:45 2016 +0300

    2.

Author: Author
Date: Tue Jun 14 15:18:01 2016 +0300

    Initial commit.
02Commenter 4
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Jun 15 14:09:58 2016 +0300

    Add missing files.

03Commenter 4
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Jun 15 14:58:40 2016 +0300

    Bug fix.

04Commenter 4
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Jun 15 16:04:45 2016 +0300

    Improve variance estimation.

05Commenter 4
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: duv
Date: Thu Jun 16 11:44:11 2016 +0300

    Border tiles fix

06Commenter 4
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: duv
Date: Thu Jun 16 15:57:31 2016 +0300

    Refactoring in progress

Author: duv
Date: Thu Jun 16 13:08:30 2016 +0300

    Refactoring in progress

07Commenter 4
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Thu Jun 16 16:19:35 2016 +0300

    Code style.

Author: Author
Date: Thu Jun 16 15:59:43 2016 +0300

    Update.

Author: Author
Date: Thu Jun 16 14:26:05 2016 +0300

    Fix issue in point light sampling.

08Commenter 4
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Thu Jun 16 16:50:01 2016 +0300

    Code style.

09Commenter 4
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Thu Jun 16 17:02:32 2016 +0300

    Code style.

10Commenter 4
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: duv
Date: Thu Jun 16 17:14:12 2016 +0300

    ImportanceScreenSampling parameter.

Author: duv
Date: Thu Jun 16 16:10:45 2016 +0300

    Stereo for adaptive path tracing

11Commenter 4
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: duv
Date: Fri Jun 17 14:38:51 2016 +0300

    Framebuffer fix

Author: duv
Date: Fri Jun 17 11:43:12 2016 +0300

    Refactoring in progress

12Commenter 4
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: duv
Date: Mon Jun 20 11:02:19 2016 +0300

    Error metric instead of variance

Author: duv
Date: Mon Jun 20 10:49:25 2016 +0300

    Fix FSAA.

13Commenter 4
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sun Jun 26 14:02:15 2016 +0300

    0027607: Visualization - Implement adaptive screen space sampling in path tracing

Author: Author
Date: Mon Jun 20 19:43:44 2016 +0300

    0027590: Visualization, Ray Tracing - port to quad BVH trees (QBVH)
    
    In frames of this issue binary BVH tree produced by building algorithms was collapsed into 4-ary BVH (QBVH).
    The BVH traversal code in GLSL was modified to process such trees correctly.
    This allows to implore thread coherence, decrease BVH memory consumption (~2 times), and use traversal stack of the half size.
    As a result, ray tracing scalability is improved, as well as rendering performance. For various setups, speedup is 12-18%.
14Commenter 4
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
15Commenter 4
Branch [archived branch] has been created by Author.

[revision removed]


No new revisions were added by this update.
16Commenter 4
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Jul 13 12:19:27 2016 +0300

    0027607: Visualization - Implement adaptive screen space sampling in path tracing
    
    This commit provides useful functionality for path tracing rendering core. Graphic3d_RenderingParams
    class was extended with additional AdaptiveScreenSampling option (disabled by default). If this option is
    enabled, path tracing tries to adjust the number of samples for different screen pixels. In this way, the
    more complex areas (from the point of light conditions) are sampled more intensively, while the simple
    areas are sampled very rarely. For example, caustics and glossy reflections are typical candidates for
    more precise sampling. In general, this allows to equalize image convergence and not to waste resources
    for already converged areas. It is also possible to visualize sampling densities by enabling ShowSamplingTiles
    option (activeting and deactivating this option does not affect on the accumulated image).
17Commenter 17
Dear kgv,

Could you please review the issue in CR27607_5 branch?
18Commenter 4
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
19Commenter 1
+float randFloat (int /*theDimension*/)
+{
+  return (float)rand() / RAND_MAX;
+}

why rand()?

+void OpenGl_TileSampler::GrabVarianceMap()

GrabVarianceMap(Handle(OpenGl_Context)& theCtx)
and preferably add glGetTexImage to OpenGl_Context for consistency.

+  if (glGetError() != GL_NO_ERROR)
+  {
+    Standard_ASSERT_INVOKE ("Error! Failed to fetch visual error map");
+  }
...
+    if (glGetError() != GL_NO_ERROR)
+    {
+      Standard_ASSERT_INVOKE ("Error! Failed to upload tile offset map");
+    }

inconsistent error handling in TKOpenGl - asserts are not used here.
And please use theCtx->core11fwd->glGetError().

+  glGetTexImage (GL_TEXTURE_2D, 0, GL_RED_INTEGER, GL_INT, &aRawData.front());

please update headers to avoid compiler errors on Android with OpenGL ES 2.0
(see OpenGl_GlFunctions.hxx - GL_RED_INTEGER/GL_RG_INTEGER/GL_RG32I are not defined within #if defined(GL_ES_VERSION_2_0).

+float& OpenGl_TileSampler::Tile (const int theX, const int theY)

ChangeTile() will be better.

+void OpenGl_TileSampler::Upload (const Handle(OpenGl_Context)& theContext, const Handle(OpenGl_Texture)& theTexture, bool theAdaptive)
+{
+  if (theTexture != NULL)

inconsistent NULL check for Handle type.

+    glTexImage2D (GL_TEXTURE_2D, 0, GL_RG32I, myTilesX, myTilesY, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, &aData.front());

theCtx->core11fwd->glTexImage2D().

+#ifdef ADAPTIVE_SAMPLING
+  #extension GL_ARB_shader_image_load_store : require
+  #extension GL_NV_shader_atomic_float : require
+#endif

I suppose this makes new mode compatible with NVIDIA hardware only - I don't see any AMD driver supporting GL_NV_shader_atomic_float. Any chance using some alternative?
These extensions should be also checked on C++ level to provide meaningful error description instead of shader compilation error.

This commit provides useful functionality for path tracing rendering core. Graphic3d_RenderingParams
class was extended with additional AdaptiveScreenSampling option (disabled by default). If this option is
enabled, path tracing tries to adjust the number of samples for different screen pixels. In this way, the
more complex areas (from the point of light conditions) are sampled more intensively, while the simple
areas are sampled very rarely. For example, caustics and glossy reflections are typical candidates for
more precise sampling. In general, this allows to equalize image convergence and not to waste resources
for already converged areas. It is also possible to visualize sampling densities by enabling ShowSamplingTiles
option (activeting and deactivating this option does not affect on the accumulated image).

the commit description should be revised / split into smaller blocks.
Changes with mixture of rasterization / RT / PT should be documented as well.

20Commenter 4
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Jul 13 12:19:27 2016 +0300

    0027607: Visualization - Implement adaptive screen space sampling in path tracing
    
    This commit provides useful functionality for path tracing rendering core.
    
    1) Graphic3d_RenderingParams class was extended with additional
       AdaptiveScreenSampling option (disabled by default). If this
       option is enabled, path tracing tries to adjust the number of
       samples for different screen areas.
    
       In this way, the more complex areas (from the point of light
       conditions) are sampled more intensively, while the simple
       areas are sampled very rarely. For example, caustics and
       glossy reflections are typical candidates for more precise
       sampling.
    
       In general, this allows to equalize image convergence and not
       to waste resources for already converged areas. It is also
       possible to visualize sampling densities by enabling ShowSamplingTiles
       option (activating and deactivating this option does not affect on the
       accumulated image).
    
    2) Mixing OpenGL and ray-tracing output has been changed. Now blending is
       performed using OpenGL functionality, while ray-tracing shaders only
       output correct Z-value.
21Commenter 21
Dear kgv,

Could you please review corrected patch (CR27607_6)?
22Commenter 4
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Jul 13 12:19:27 2016 +0300

    0027607: Visualization - Implement adaptive screen space sampling in path tracing
    
    This commit provides useful functionality for path tracing rendering core.
    
    1) Graphic3d_RenderingParams class was extended with additional
       AdaptiveScreenSampling option (disabled by default). If this
       option is enabled, path tracing tries to adjust the number of
       samples for different screen areas.
    
       In this way, the more complex areas (from the point of light
       conditions) are sampled more intensively, while the simple
       areas are sampled very rarely. For example, caustics and
       glossy reflections are typical candidates for more precise
       sampling.
    
       In general, this allows to equalize image convergence and not
       to waste resources for already converged areas. It is also
       possible to visualize sampling densities by enabling ShowSamplingTiles
       option (activating and deactivating this option does not affect on the
       accumulated image).
    
    2) Mixing OpenGL and ray-tracing output has been changed. Now blending is
       performed using OpenGL functionality, while ray-tracing shaders only
       output correct Z-value.
23Commenter 4
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Jul 13 12:19:27 2016 +0300

    0027607: Visualization - Implement adaptive screen space sampling in path tracing
    
    This commit provides useful functionality for path tracing rendering core.
    
    1) Graphic3d_RenderingParams class was extended with additional
       AdaptiveScreenSampling option (disabled by default). If this
       option is enabled, path tracing tries to adjust the number of
       samples for different screen areas.
    
       In this way, the more complex areas (from the point of light
       conditions) are sampled more intensively, while the simple
       areas are sampled very rarely. For example, caustics and
       glossy reflections are typical candidates for more precise
       sampling.
    
       In general, this allows to equalize image convergence and not
       to waste resources for already converged areas. It is also
       possible to visualize sampling densities by enabling ShowSamplingTiles
       option (activating and deactivating this option does not affect on the
       accumulated image).
    
    2) Mixing OpenGL and ray-tracing output has been changed. Now blending is
       performed using OpenGL functionality, while ray-tracing shaders only
       output correct Z-value.
24Commenter 24
Dear kgv,

Could you please review the patch in branch CR27607_8?
25Commenter 4
Branch [archived branch] has been updated by Commenter 1.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Thu Aug 18 21:44:07 2016 +0300

    fix compilation error

26Commenter 1
Please test the patch.
27Commenter 4
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
28Commenter 28
Branch [archived branch] has been rebased on the current master
29Commenter 29
Dear Commenter 2,

Branch CR27607_8 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
[revision removed]

Number of compiler warnings:
occt component:
   Linux: 0 (0 on master)
   Windows: 0 (0 on master)
   MasOS: Not available
products component:
   Linux: 64
   Windows: 0
   MacOS: Not available
During building of branch CR27607_8 from occt git-repository (and master from products git-repository) compilation errors have been detected.
On MacOS:
http://jenkins-test-05.nnov.opencascade.com/view/CR27607_8-master/job/CR27607_8-master-OCCT-MacOS-opt-compile/2/parsed_console/

Regressions/Differences:
http://occt-tests/CR27607_8-master-OCCT/Debian70-64/summary.html
http://occt-tests/CR27607_8-master-OCCT/Windows-64-VC10/summary.html
bugs vis bug27083

Testing on Linux:
Total MEMORY difference: 89620534 / 89521833 [+0.11%]
Total CPU difference: 19477.57000000005 / 19495.010000000108 [-0.09%]

Testing on Windows:
Total MEMORY difference: 57148740 / 57161393 [-0.02%]
Total CPU difference: 17998.755775898862 / 18084.68112669885 [-0.48%]

There are differences in images found by testdiff:
http://occt-tests/CR27607_8-master-OCCT/Debian70-64/diff-Debian70-64.html
http://occt-tests/CR27607_8-master-OCCT/Windows-64-VC10/diff-Windows-64-VC10-image.html
v3d raytrace bug24819
30Commenter 30
Dear Kirill,

Branch [archived branch] has been rejected due to:
- compilation errors
- regressions/differences/improvements
- differences in images
31Commenter 1
Please also add at least one test case for new rendering mode.
32Commenter 32
Results for test case v3d raytrace bug24819 show that blending semi-transparent ray traced fragments over non-raytraceable scene elements (e.g. wireframe or text labels) is no longer supported.
Meanwhile, this feature improves the visual results and user perception significantly for a mixed scene. Thus it should be restored in the updated patch.
33Commenter 1
Please also extend Graphic3d_TypeOfLimit enumeration and method OpenGl_GraphicDriver::InquireLimit() with new entities to check which RayTracing / PathTracing features are expected to be available in current context.

E.g. Graphic3d_TypeOfLimit_HasRayTracing, Graphic3d_TypeOfLimit_HasRayTracingTextures, Graphic3d_TypeOfLimit_HasRayTracingAdaptiveScreenSpace.

So that application can display options actually available to user without duplicating the same checks that buried inside TKOpenGl.
34Commenter 4
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Jul 13 12:19:27 2016 +0300

    0027607: Visualization - Implement adaptive screen space sampling in path tracing
    
    This commit provides useful functionality for path tracing rendering core.
    
    1) Graphic3d_RenderingParams class was extended with additional
       AdaptiveScreenSampling option (disabled by default). If this
       option is enabled, path tracing tries to adjust the number of
       samples for different screen areas.
    
       In this way, the more complex areas (from the point of light
       conditions) are sampled more intensively, while the simple
       areas are sampled very rarely. For example, caustics and
       glossy reflections are typical candidates for more precise
       sampling.
    
       In general, this allows to equalize image convergence and not
       to waste resources for already converged areas. It is also
       possible to visualize sampling densities by enabling ShowSamplingTiles
       option (activating and deactivating this option does not affect on the
       accumulated image).
    
    2) Mixing OpenGL and ray-tracing output has been changed. Now blending is
       performed using OpenGL functionality, while ray-tracing shaders only
       output correct Z-value.
35Commenter 35
Dear kgv,

Could you please review the patch in branch CR27607_9?

Please note that background/text mixing issues will be resolved in separate patch (0027898: Visualization, Ray Tracing - Use OpenGL background drawing subroutines in ray tracing).
36Commenter 4
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
37Commenter 4
Branch [archived branch] has been updated by Commenter 1.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Sun Sep 25 14:05:35 2016 +0300

    cosmetics, fix compilation on OpenGL ES

38Commenter 1
Please test the patch.
Please check also compilation on Android platform.
39Commenter 39
40Commenter 40
Dear Kirill,

Branch [archived branch] has been rejected due to:
- compilation errors
41Commenter 4
Branch [archived branch] has been updated forcibly by Commenter 1.

[revision removed]
42Commenter 1
The compilation error should be fixed now.
Why there was no log for Android build?
43Commenter 43
Dear Commenter 2,

Branch CR27607_9 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS, Windows and Android platforms and tested.
[revision removed]

Number of compiler warnings:
occt component:
   Linux: 2 (0 on master)
   Windows: 0 (0 on master)
   MasOS: 2 (0 on master)
products component:
   Linux: 64
   Windows: 0
   MacOS: 1152
New warnings have been detected during OCCT component building
on Linux:
http://jenkins-test-08.nnov.opencascade.com/view/%20CR27607_9/job/CR27607_9_master-OCCT-Debian70-64-opt-compile/2/warnings18Result/
on MacOS:
http://jenkins-test-08.nnov.opencascade.com/view/%20CR27607_9/job/CR27607_9_master-OCCT-MacOS-opt-compile/2/warnings8Result/

Compilation errors have been detected durng building on Android:
http://jenkins-test-08.nnov.opencascade.com/view/%20CR27607_9/job/CR27607_9_master-OCCT-Debian70-32-Android-opt-compile/2/parsed_console/
http://jenkins-test-08.nnov.opencascade.com/view/%20CR27607_9/job/CR27607_9_master-OCCT-Windows-32-Android-opt-compile/2/parsed_console/

Regressions/Differences:
http://occt-tests/CR27607_9_master-OCCT/Debian70-64/summary.html
http://occt-tests/CR27607_9_master-OCCT/Windows-64-VC10/summary.html
bugs vis bug27083

Testing on Linux:
Total MEMORY difference: 90518828 / 90241021 [+0.31%]
Total CPU difference: 19911.680000000142 / 19251.879999999877 [+3.43%]

Testing on Windows:
Total MEMORY difference: 57207264 / 57221541 [-0.02%]
Total CPU difference: 18077.6142813987 / 18310.78897609872 [-1.27%]

There are differences in images found by testdiff:
http://occt-tests/CR27607_9_master-OCCT/Debian70-64/diff-Debian70-64.html
http://occt-tests/CR27607_9_master-OCCT/Windows-64-VC10/diff-Windows-64-VC10-image.html
v3d raytrace bug24819 (approved by developer)

44Commenter 44
Dear Kirill,

Branch [archived branch] has been rejected due to:
- compilation errors
- additional warnings
- regressions/differences/improvements

45Commenter 4
Branch [archived branch] has been updated by Commenter 1.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Wed Sep 28 13:53:28 2016 +0300

    fix compiler warnings

46Commenter 4
Branch [archived branch] has been updated by Commenter 1.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Wed Sep 28 14:03:11 2016 +0300

    Test case bugs vis bug27083 has been updated
    (the alpha value is now correctly set by Ray-Tracing to 1, opaque).

47Commenter 4
Branch [archived branch] has been updated by Commenter 1.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Wed Sep 28 14:11:21 2016 +0300

    Fix compilation issues when using OpenGL ES.

48Commenter 4
Branch [archived branch] has been created by Commenter 1.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Wed Jul 13 12:19:27 2016 +0300

    0027607: Visualization - Implement adaptive screen space sampling in path tracing
    
    This commit provides useful functionality for path tracing rendering core.
    
    1) Graphic3d_RenderingParams class was extended with additional AdaptiveScreenSampling option (disabled by default).
       If this option is enabled, path tracing tries to adjust the number of samples for different screen areas.
    
       In this way, the more complex areas (from the point of light conditions) are sampled more intensively,
       while the simple areas are sampled very rarely.
       For example, caustics and glossy reflections are typical candidates for more precise sampling.
    
       In general, this allows to equalize image convergence and not to waste resources for already converged areas.
       It is also possible to visualize sampling densities by enabling ShowSamplingTiles option
       (activating and deactivating this option does not affect on the accumulated image).
    
    2) Mixing OpenGL and ray-tracing output has been changed.
       Now blending is performed using OpenGL functionality, while ray-tracing shaders only output correct Z-value.
    
    Test case bugs vis bug27083 has been updated,
    since the alpha value is now correctly set by Ray-Tracing to 1, opaque.
49Commenter 1
Please check building of updated patch in branch CR27607_10.
Regression testing is not needed.

> Regressions/Differences:
> bugs vis bug27083
Test case has been updated to accept new color value.
Please check only this test (re-building of full patch is not needed for checking).
50Commenter 4
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: apv
Date: Thu Sep 29 09:54:42 2016 +0300

    Tuning of test case bugs/vis/bug27083

51Commenter 51
ear Commenter 2,

Branch CR27607_10 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS, Windows and Android platforms and tested.
[revision removed]

Number of compiler warnings:
occt component:
   Linux: 0 (0 on master)
   Windows: 0 (0 on master)
   MasOS: 0 (0 on master)
products component:
   Linux: 64
   Windows: 0
   MacOS: 1156

Regressions/Differences:
Not detected

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 90744196 / 90237446 [+0.56%]
Total CPU difference: 19533.88999999991 / 19251.959999999875 [+1.46%]

Testing on Windows:
Total MEMORY difference: 57208751 / 57221541 [-0.02%]
Total CPU difference: 18076.1166717987 / 18310.78897609872 [-1.28%]

There are differences in images found by testdiff:
http://occt-tests/CR27607_10_master-OCCT/Debian70-64/diff-Debian70-64.html
http://occt-tests/CR27607_10_master-OCCT/Windows-64-VC10/diff-Windows-64-VC10-image.html
v3d raytrace bug24819 (approved by developer)

52Commenter 1
Performance comparison of test case "pathtrace.tcl" on current master and 7.0.0:
source $env(CSF_OCCTSamplesPath)/tcl/pathtrace.tcl
dversion
vcaps -vsync 0
vzoom 1.001
vfps
vglinfo

# OpenGL info
OpenGL info:
  GLvendor    = 'ATI Technologies Inc.'
  GLdevice    = 'AMD Radeon R9 200 Series'
  GLversion   = '4.5.13447 Compatibility Profile Context 16.300.2311.0'
  GLSLversion = '4.50'

# occt 7.0.0
FPS: 80.493047313671539
CPU: 0.31200200000000011 msec
MRays/sec (upper bound): 337.61231031992179

# occt 7.1.0 dev (current master)
FPS: 48.963984436177611
CPU: 0.31200200000000011 msec
MRays/sec (upper bound): 205.36983577659751
53Commenter 53
The same comparison on GeForce GTX 680:

occt 7.0.0 - 34 FPS
current master - 48 fps

So, we have 1.4x improvement.

We should analyze the reason of performance drop on AMD!

54Commenter 4
Branch [archived branch] has been deleted by Commenter 1.

[revision removed]
55Commenter 4
Branch [archived branch] has been deleted by Commenter 1.

[revision removed]
56Commenter 4
Branch [archived branch] has been deleted by Commenter 1.

[revision removed]
57Commenter 4
Branch [archived branch] has been deleted by Commenter 1.

[revision removed]
58Commenter 4
Branch [archived branch] has been deleted by Commenter 1.

[revision removed]
59Commenter 4
Branch [archived branch] has been deleted by Commenter 1.

[revision removed]
60Commenter 4
Branch [archived branch] has been deleted by Commenter 1.

[revision removed]
61Commenter 4
Branch [archived branch] has been deleted by Commenter 1.

[revision removed]
62Commenter 4
Branch [archived branch] has been deleted by Commenter 1.

[revision removed]

Related records