MantisBT - Open CASCADE
View Issue Details
0024437Open CASCADE[OCCT] OCCT:Visualizationpublic2013-12-05 07:442019-03-05 13:48
san 
apn 
normalfeature 
verifiedfixed 
ALL
[OCCT] 6.7.0 
[OCCT] 7.4.0 
v3d glsl outline1 outline2
0024437: Visualization - silhouette edges based on OpenGL
Currently, OCCT runs rather heavy geometrical computations on CPU in order to compute hidden-line representation of an AIS_Shape object. And it works with bugs on some specific kinds of input shapes.

Normally, HLR output includes:
1. Visible face boundaries and visible free edges
2. Silhouette edges
3. Optionally, hidden face boundaries and free edges can be visualized using specific visual attributes (line stipple, different line color, etc.)

These visual results can be produced efficiently using OpenGL and/or GLSL.
Simple algorithms doing this seem to exist for a decade, see e.g. http://www.opengl.org/archives/resources/faq/technical/miscellaneous.htm#misc0010 [^]
A simple implementation is based on OpenGL fixed-pipeline functionality and includes three rendering passes:
a. Draw the shaded triangulation to depth buffer only (nothing drawn to the frame-buffer) with polygon offsets used to shift the depth values a bit farther from the eye. Polygon offsets are needed to avoid depth test artifacts at step (b) below.
b. Draw the face boundaries and stand-alone edges in normal mode (depth test enabled, frame-buffer writes enabled) - like this, all hidden stuff is removed by depth test.
c. Draw the triangulation in GL_LINE polygon mode, with thicker line width and polygon offsets used to shift produced depth values farther from the eye than for step (a) above. Like this, we produce the shape's silhouette.

Naturally, GLSL shaders can be used to produce HLR image of higher quality.

The main advantages of this approach are:
- Invariance with respect to the input geometry: as soon as OCCT is able to triangulate the shape, it can be displayed in HLR correctly.
- High performance and low CPU load: most of the work is done by the graphic card.

It is proposed to consider OpenGL-based HLR as replacement for the current implementation.

Extra references:
- Outline through Geometry Shader and adjacent triangles.
  http://prideout.net/blog/?tag=opengl-silhouette [^]
- Post processing on Geometry Buffer
  https://gamedev.stackexchange.com/questions/68401/how-can-i-draw-outlines-around-3d-models [^]

Implementation of shader should correspond to the idea of outline shader:
1. The first pass uses vertex shader to draw an "inflated" primitives (with given shift along the normal of given vertex); the color is black;
2. During the first pass only the back faces are drawn;
3. The second pass draws the primitives by a standard way (with color corresponding to the background); no inflation is applied;
4. During the second pass only the front faces are drawn;
5. The edges and other primitives (not triangles) are drawn "as is"
The new test case is implemented:

test bugs vis bug24437
No tags attached.
png hlr_2.png (18,975) 2018-05-18 14:49
https://tracker.dev.opencascade.org/
png hlr_1.png (34,107) 2018-05-21 09:55
https://tracker.dev.opencascade.org/
png cad_outliuned.png (63,038) 2018-05-22 21:38
https://tracker.dev.opencascade.org/
png bottle_outlined.png (11,338) 2019-02-28 15:30
https://tracker.dev.opencascade.org/
Issue History
2013-12-05 07:44sanNew Issue
2013-12-05 07:44sanAssigned To => san
2018-05-10 16:03kgvRelationship addedhas duplicate 0029752
2018-05-10 16:40gitNote Added: 0075928
2018-05-10 18:05gitNote Added: 0075930
2018-05-10 19:53sanAssigned Tosan => asl
2018-05-10 19:53sanStatusnew => assigned
2018-05-17 16:07gitNote Added: 0076014
2018-05-17 16:10gitNote Added: 0076015
2018-05-17 17:02gitNote Added: 0076016
2018-05-17 17:32gitNote Added: 0076017
2018-05-18 10:48gitNote Added: 0076030
2018-05-18 10:50gitNote Added: 0076031
2018-05-18 10:56aslNote Added: 0076033
2018-05-18 10:56aslAssigned Toasl => san
2018-05-18 10:56aslStatusassigned => resolved
2018-05-18 10:56aslSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=19107#r19107
2018-05-18 11:23aslAssigned Tosan => kgv
2018-05-18 12:06kgvSummaryEfficient HLR visualization based on OpenGL and GLSL => Visualization - Efficient HLR visualization based on OpenGL and GLSL
2018-05-18 12:07kgvNote Added: 0076035
2018-05-18 12:07kgvAssigned Tokgv => asl
2018-05-18 12:07kgvPrioritylow => normal
2018-05-18 12:07kgvStatusresolved => feedback
2018-05-18 12:07kgvTarget Version => 7.4.0
2018-05-18 14:49aslFile Added: hlr_1.png
2018-05-18 14:49aslFile Added: hlr_2.png
2018-05-18 14:50gitNote Added: 0076037
2018-05-18 14:51aslAssigned Toasl => kgv
2018-05-18 14:51aslStatusfeedback => resolved
2018-05-18 15:39abvNote Added: 0076038
2018-05-18 16:35kgvRelationship addedrelated to 0029787
2018-05-21 09:50gitNote Added: 0076048
2018-05-21 09:52aslNote Added: 0076049
2018-05-21 09:55aslFile Deleted: hlr_1.png
2018-05-21 09:55aslFile Added: hlr_1.png
2018-05-22 15:10sanRelationship addedrelated to 0029801
2018-05-22 16:19gitNote Added: 0076102
2018-05-22 18:43gitNote Added: 0076104
2018-05-22 20:00kgvDescription Updatedbug_revision_view_page.php?rev_id=19136#r19136
2018-05-22 20:02kgvDescription Updatedbug_revision_view_page.php?rev_id=19137#r19137
2018-05-22 20:16gitNote Added: 0076107
2018-05-22 20:27gitNote Added: 0076108
2018-05-22 21:05kgvSummaryVisualization - Efficient HLR visualization based on OpenGL and GLSL => Visualization - silhouette edges based on OpenGL
2018-05-22 21:37gitNote Added: 0076109
2018-05-22 21:38kgvFile Added: cad_outliuned.png
2018-05-22 21:41gitNote Added: 0076110
2018-05-22 21:42kgvNote Added: 0076111
2018-05-22 21:42kgvAssigned Tokgv => san
2018-05-23 08:27kgvNote Added: 0076118
2018-05-23 10:25gitNote Added: 0076127
2018-05-23 10:54gitNote Added: 0076133
2018-05-23 10:54gitNote Added: 0076134
2018-05-23 12:15sanNote Added: 0076154
2018-05-23 12:15sanAssigned Tosan => asl
2018-05-23 12:15sanStatusresolved => feedback
2018-05-23 13:50kgvFile Added: solidworks-heads-up-view-toolbar-display-style-example-window.jpg
2018-05-23 13:50kgvFile Deleted: solidworks-heads-up-view-toolbar-display-style-example-window.jpg
2018-05-23 13:53kgvDescription Updatedbug_revision_view_page.php?rev_id=19141#r19141
2019-02-28 01:41gitNote Added: 0082434
2019-02-28 01:43gitNote Added: 0082435
2019-02-28 15:08gitNote Added: 0082458
2019-02-28 15:28gitNote Added: 0082459
2019-02-28 15:30kgvFile Added: bottle_outlined.png
2019-02-28 17:42gitNote Added: 0082466
2019-02-28 18:48kgvNote Added: 0082471
2019-02-28 18:48kgvAssigned Toasl => bugmaster
2019-02-28 18:48kgvStatusfeedback => reviewed
2019-02-28 19:17apnTest case number => v3d glsl outline1 outline2
2019-02-28 20:18apnNote Added: 0082475
2019-02-28 20:18apnStatusreviewed => tested
2019-03-03 21:12apnChangeset attached => occt master 6ef0d6f1
2019-03-03 21:12apnAssigned Tobugmaster => apn
2019-03-03 21:12apnStatustested => verified
2019-03-03 21:12apnResolutionopen => fixed
2019-03-05 13:46gitNote Added: 0082606
2019-03-05 13:46gitNote Added: 0082607
2019-03-05 13:48gitNote Added: 0082653
2019-03-05 13:48gitNote Added: 0082654
2019-03-05 13:48gitNote Added: 0082655
2019-03-05 13:48gitNote Added: 0082656

Notes
(0075928)
git   
2018-05-10 16:40   
Branch CR24437 has been created by asl.

SHA-1: d26d46876623b7e7eef24628412d4588db546e2b


Detailed log of new commits:

Author: asl
Date: Thu May 10 16:39:09 2018 +0300

    0024437: Efficient HLR visualization based on OpenGL and GLSL
    
    New interior style Aspect_IS_HLR is supported for Graphic3d_AspectFillAre3d.
    If this style is set, the triangles primitive array is drawn using the outline shader.
(0075930)
git   
2018-05-10 18:05   
Branch CR24437 has been updated by asl.

SHA-1: 8b50b0dcbf1cdf41e22c0dd884f50e980692c9b2


Detailed log of new commits:

Author: asl
Date: Thu May 10 18:05:06 2018 +0300

    0024437: Efficient HLR visualization based on OpenGL and GLSL
    
    New interior style Aspect_IS_HLR is supported for Graphic3d_AspectFillAre3d.
    If this style is set, the triangles primitive array is drawn using the outline shader.

(0076014)
git   
2018-05-17 16:07   
Branch CR24437 has been updated by asl.

SHA-1: 1f497002579d51251e68c9ddbc8b166d2a9a0dc1


Detailed log of new commits:

Author: asl
Date: Thu May 17 16:07:40 2018 +0300

    0024437: Efficient HLR visualization based on OpenGL and GLSL
    
    New interior style Aspect_IS_HLR is supported for Graphic3d_AspectFillAre3d.
    If this style is set, the triangles primitive array is drawn using the outline shader.

(0076015)
git   
2018-05-17 16:10   
Branch CR24437_1 has been created by asl.

SHA-1: be999be67fd657c11d5352c8c055d53443c12971


Detailed log of new commits:

Author: asl
Date: Thu May 17 16:10:30 2018 +0300

    0024437: Efficient HLR visualization based on OpenGL and GLSL
    
    New interior style Aspect_IS_HLR is supported for Graphic3d_AspectFillAre3d.
    If this style is set, the triangles primitive array is drawn using the outline shader
(0076016)
git   
2018-05-17 17:02   
Branch CR24437 has been updated by asl.

SHA-1: 6ede2957e74bec2ea5ee92f51590a1388629fbc7


Detailed log of new commits:

Author: asl
Date: Thu May 17 17:01:57 2018 +0300

    remove selection attributes

(0076017)
git   
2018-05-17 17:32   
Branch CR24437 has been updated by asl.

SHA-1: d4a3b1f0ec8b0f0d03c4804ef8788a91fe9833e5


Detailed log of new commits:

Author: asl
Date: Thu May 17 17:04:39 2018 +0300

    optimization of vertex moving

(0076030)
git   
2018-05-18 10:48   
Branch CR24437 has been updated by asl.

SHA-1: 48685e81e952cf88c17dd6465cbf34ddee967800


Detailed log of new commits:

Author: asl
Date: Fri May 18 10:48:31 2018 +0300

    debug of HLR presentation

(0076031)
git   
2018-05-18 10:50   
Branch CR24437_1 has been updated forcibly by asl.

SHA-1: 0fb485f958927ddd624801413878cb0c1e8a8fec
(0076033)
asl   
2018-05-18 10:56   
The HLR presentation is implemented via the new interior style: Aspect_IS_HLR. When this style is applied to the primitive set of triangles then the outline shader is applied:

1. The first pass draws only back faces with applied shift along normals of faces and with the color of silhouette.
2. The second pass draw only the front faces without shift and with the color of background.
3. The silhouette color is taken from the edge color of the aspect fill area; the silhouette width is calculated on the base of edge width (may be a little incorrect for the projective camera).
(0076035)
kgv   
2018-05-18 12:07   
The screenshots demonstrating new feature should be attached to the bug.
(0076037)
git   
2018-05-18 14:50   
Branch CR24437_1 has been updated forcibly by asl.

SHA-1: 2f2b107bff82157bb06c74da6b329cb06c5aafa5
(0076038)
abv   
2018-05-18 15:39   
Please consider renaming Aspect_IS_HLR to Aspect_IS_OUTLINE
(0076048)
git   
2018-05-21 09:50   
Branch CR24437_1 has been updated forcibly by asl.

SHA-1: 0e06209cef6b5106c85092d852e764915a15f7b4
(0076049)
asl   
2018-05-21 09:52   
the item Aspect_IS_HLR is renamed to Aspect_IS_OUTLINE
(0076102)
git   
2018-05-22 16:19   
Branch CR24437_1 has been updated by kgv.

SHA-1: d529e220616a4409723b3f03cdd87dd0df676b23


Detailed log of new commits:

Author: kgv
Date: Tue May 22 16:19:33 2018 +0300

    Aspect_InteriorStyle - added missing documentation to enum values.
    vsetinteriorstyle now alias to "vaspects -setInteriorStyle".

(0076104)
git   
2018-05-22 18:43   
Branch CR24437_1 has been updated by kgv.

SHA-1: 65c443cf1660db961784fee00a9f618ff51e60b2


Detailed log of new commits:

Author: kgv
Date: Tue May 22 18:43:46 2018 +0300

    # OpenGl_ShaderManager - do not use non-standard vertex attribute normal.
    # Define occIsSilhouettePass as int.

(0076107)
git   
2018-05-22 20:16   
Branch CR24437_1 has been updated by kgv.

SHA-1: bbb6df24bf7a83ab7923c2f46ab3fdec5382a833


Detailed log of new commits:

Author: kgv
Date: Tue May 22 20:16:31 2018 +0300

    # eliminated redundant 3rd rendering pass
    # fixed Perspective projection
    # simplified SILHOUETTE shader program
    # disable Color buffer writes for interior (only SILHOUETTE fills color),
    # so that there is no need to pass background color (gradient works automatically)

(0076108)
git   
2018-05-22 20:27   
Branch CR24437_1 has been updated forcibly by kgv.

SHA-1: e5e77394e82c9dc945840377b0cf968d023d316f
(0076109)
git   
2018-05-22 21:37   
Branch CR24437_1 has been updated by kgv.

SHA-1: 1d5f48c0f8576b9807144d389076fe542ab7931b


Detailed log of new commits:

Author: kgv
Date: Tue May 22 21:37:45 2018 +0300

    vsetedgetype has been extended with -width option.

(0076110)
git   
2018-05-22 21:41   
Branch CR24437_2 has been created by kgv.

SHA-1: 3c713e1989db463ad4cf360e8462a43f0721e0e7


Detailed log of new commits:

Author: asl
Date: Thu May 17 16:10:30 2018 +0300

    0024437: Visualization - silhouette edges based on OpenGL
    
    New interior styles Aspect_IS_OUTLINE and Aspect_IS_OUTLINED_SOLID have been introduced.
    If this style is set, the triangles primitive array is drawn using the outline shader.
    
    vsetinteriorstyle now alias to "vaspects -setInteriorStyle".
    vsetedgetype has been extended with -width option.
(0076111)
kgv   
2018-05-22 21:42   
Dear Sergey,

could you please take a look onto the patch with my modifications?
(0076118)
kgv   
2018-05-23 08:27   
Alexander,

when you are adding a test case, it should either perform some checks to print KO,
or to dump images for visual comparison (or both).

http://occt-tests/CR24437_2-master-KGV-OCCT/Debian70-64/bugs/vis/bug24437.html [^]
(0076127)
git   
2018-05-23 10:25   
Branch CR24437_2 has been updated by kgv.

SHA-1: ff620cebd5f69c457eca839d06a878871d055fe3


Detailed log of new commits:

Author: kgv
Date: Wed May 23 10:24:36 2018 +0300

    # fix regression with vsetinteriorstyle hatch; added image dump to the test

(0076133)
git   
2018-05-23 10:54   
Branch CR24437_2 has been updated by kgv.

SHA-1: 3c723f1fe810a204aeb67162e5b65af7a016cb9e


Detailed log of new commits:

Author: kgv
Date: Wed May 23 10:53:58 2018 +0300

    # fill background color

(0076134)
git   
2018-05-23 10:54   
Branch CR24437_3 has been created by kgv.

SHA-1: 5ac1eae43c8b5fb2930666faf178e67e6dff7555


Detailed log of new commits:

Author: asl
Date: Thu May 17 16:10:30 2018 +0300

    0024437: Visualization - silhouette edges based on OpenGL
    
    New interior styles Aspect_IS_OUTLINE and Aspect_IS_OUTLINED_SOLID have been introduced.
    If this style is set, the triangles primitive array is drawn using the outline shader.
    
    vsetinteriorstyle now alias to "vaspects -setInteriorStyle".
    vsetedgetype has been extended with -width option.
(0076154)
san   
2018-05-23 12:15   
Is the implemented HLR algorithm intended for usage with outline width > 1?
See cad_outliuned.png attached - it does not seem to work.
Can you please consider a possible improvement - else outline width should always be clamped to 1 in the current version.
(0082434)
git   
2019-02-28 01:41   
Branch CR24437_4 has been created by kgv.

SHA-1: b0cb6458f21e5b7feaf854c58d579818c24a1835


Detailed log of new commits:

Author: kgv
Date: Thu Feb 28 01:36:32 2019 +0300

    0024437: Visualization - silhouette edges based on OpenGL
    
    New interior styles Aspect_IS_OUTLINE and Aspect_IS_OUTLINED_SOLID have been introduced.
    If this style is set, the triangles primitive array is drawn using the outline shader.
    
    vsetinteriorstyle now alias to "vaspects -setInteriorStyle".
    vsetedgetype has been extended with -width option.
(0082435)
git   
2019-02-28 01:43   
Branch CR24437_4 has been updated forcibly by kgv.

SHA-1: b785bfccef195587d0a0863db18e68b191b96e67
(0082458)
git   
2019-02-28 15:08   
Branch CR24437_5 has been created by kgv.

SHA-1: 914249209ec6a99a7807004b21981372d4aea291


Detailed log of new commits:

Author: asl
Date: Thu Feb 28 01:36:32 2019 +0300

    0024437: Visualization - silhouette edges based on OpenGL
    
    Added new flag Graphic3d_AspectFillArea3d::ToDrawSilhouette() activating silhouette (outline) rendering.
    
    The new feature can simulate fake HLR look-n-feel,
    when combined with Aspect_IS_HIDDENLINE interior style (filling object with background color),
    face boundary edges (with most continuity flag set to c2 or lower).
    
    Silhouette GLSL program is very simple - it displaces model alongside vertex normal,
    so that it is applicable only to smooth surfaces and closed volumes,
    and produces visual artifacts at sharp corners, especially when face boundary is disabled.
    
    OpenGl_SetOfShaderPrograms has been modified so that to reduce
    dimensions of the grid of static size based on amount of program combinations.
    
    OpenGl_PrimitiveArray no more allocates VBO resources if primitive array
    is marked to be not drawn via interior style / line type / marker type.

Author: asl
Date: Wed Feb 27 19:39:08 2019 +0300

    0029787: Visualization - Avoid in presentation edges of certain continuity class
    
    A new flag Prs3d_Drawer::FaceBoundaryUpperContinuity() has been introduced
    handled by StdPrs_ShadedShape::FillFaceBoundaries() method to exclude edges
    of higher continuity class (e.g. to skip seam edges).
    
    Draw Harness command vshowfaceboundary has been replaced by vaspects:
    > vaspects -setFaceBoundaryDraw 1 -setFaceBoundaryColor RED -setFaceBoundaryType DASH.
(0082459)
git   
2019-02-28 15:28   
Branch CR24437_5 has been updated forcibly by kgv.

SHA-1: 46fd7d42178c719b5df71c720eb098fa3c5c96f0
(0082466)
git   
2019-02-28 17:42   
Branch CR24437_5 has been updated forcibly by kgv.

SHA-1: da12c29fc34703665225dd4cab61e360f3dde41b
(0082471)
kgv   
2019-02-28 18:48   
Please raise the patch.
(0082475)
apn   
2019-02-28 20:18   
Combination -
OCCT branch : CR24437_5
master SHA - da12c29fc34703665225dd4cab61e360f3dde41b
d67d4b811012eef8913d3c535c29654d0acf3c4c
Products branch : IR-WEEK9 SHA - 19557bf07dc768ee1a794f6baa72b99d7cb52999
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 16541.79000000006 / 16542.15999999996 [-0.00%]
Products
Total CPU difference: 9080.550000000043 / 9061.510000000035 [+0.21%]
Windows-64-VC14:
OCCT
Total CPU difference: 18053.734375 / 17946.09375 [+0.60%]
Products
Total CPU difference: 10485.1875 / 10439.25 [+0.44%]

Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
(0082606)
git   
2019-03-05 13:46   
Branch CR24437_4 has been deleted by kgv.

SHA-1: b785bfccef195587d0a0863db18e68b191b96e67
(0082607)
git   
2019-03-05 13:46   
Branch CR24437_5 has been deleted by kgv.

SHA-1: da12c29fc34703665225dd4cab61e360f3dde41b
(0082653)
git   
2019-03-05 13:48   
Branch CR24437 has been deleted by kgv.

SHA-1: 48685e81e952cf88c17dd6465cbf34ddee967800
(0082654)
git   
2019-03-05 13:48   
Branch CR24437_1 has been deleted by kgv.

SHA-1: 1d5f48c0f8576b9807144d389076fe542ab7931b
(0082655)
git   
2019-03-05 13:48   
Branch CR24437_2 has been deleted by kgv.

SHA-1: 3c723f1fe810a204aeb67162e5b65af7a016cb9e
(0082656)
git   
2019-03-05 13:48   
Branch CR24437_3 has been deleted by kgv.

SHA-1: 5ac1eae43c8b5fb2930666faf178e67e6dff7555