View Issue Details

IDProjectCategoryView StatusLast Update
0024437Open CASCADEOCCT:Visualizationpublic2020-12-16 16:09
ReportersanAssigned Toapn  
PrioritynormalSeverityfeature 
Status closedResolutionfixed 
PlatformAOSL 
Product Version6.7.0 
Target Version7.4.0Fixed in Version7.4.0 
Summary0024437: Visualization - silhouette edges based on OpenGL
DescriptionCurrently, 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"
Steps To ReproduceThe new test case is implemented:

test bugs vis bug24437
TagsNo tags attached.
Test case numberv3d glsl outline1 outline2

Attached Files

  • hlr_2.png (18,975 bytes)
  • hlr_1.png (34,107 bytes)
  • cad_outliuned.png (63,038 bytes)
  • bottle_outlined.png (11,338 bytes)

Activities

git

2018-05-10 16:40

administrator   ~0075928

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.

git

2018-05-10 18:05

administrator   ~0075930

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.

git

2018-05-17 16:07

administrator   ~0076014

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.

git

2018-05-17 16:10

administrator   ~0076015

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

git

2018-05-17 17:02

administrator   ~0076016

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

git

2018-05-17 17:32

administrator   ~0076017

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

git

2018-05-18 10:48

administrator   ~0076030

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

git

2018-05-18 10:50

administrator   ~0076031

Branch CR24437_1 has been updated forcibly by asl.

SHA-1: 0fb485f958927ddd624801413878cb0c1e8a8fec

asl

2018-05-18 10:56

developer   ~0076033

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).

kgv

2018-05-18 12:07

developer   ~0076035

The screenshots demonstrating new feature should be attached to the bug.

asl

2018-05-18 14:49

developer  

hlr_2.png (18,975 bytes)

git

2018-05-18 14:50

administrator   ~0076037

Branch CR24437_1 has been updated forcibly by asl.

SHA-1: 2f2b107bff82157bb06c74da6b329cb06c5aafa5

abv

2018-05-18 15:39

manager   ~0076038

Please consider renaming Aspect_IS_HLR to Aspect_IS_OUTLINE

git

2018-05-21 09:50

administrator   ~0076048

Branch CR24437_1 has been updated forcibly by asl.

SHA-1: 0e06209cef6b5106c85092d852e764915a15f7b4

asl

2018-05-21 09:52

developer   ~0076049

the item Aspect_IS_HLR is renamed to Aspect_IS_OUTLINE

asl

2018-05-21 09:55

developer  

hlr_1.png (34,107 bytes)

git

2018-05-22 16:19

administrator   ~0076102

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".

git

2018-05-22 18:43

administrator   ~0076104

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.

git

2018-05-22 20:16

administrator   ~0076107

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)

git

2018-05-22 20:27

administrator   ~0076108

Branch CR24437_1 has been updated forcibly by kgv.

SHA-1: e5e77394e82c9dc945840377b0cf968d023d316f

git

2018-05-22 21:37

administrator   ~0076109

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.

kgv

2018-05-22 21:38

developer  

cad_outliuned.png (63,038 bytes)

git

2018-05-22 21:41

administrator   ~0076110

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.

kgv

2018-05-22 21:42

developer   ~0076111

Dear Sergey,

could you please take a look onto the patch with my modifications?

kgv

2018-05-23 08:27

developer   ~0076118

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

git

2018-05-23 10:25

administrator   ~0076127

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

git

2018-05-23 10:54

administrator   ~0076133

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

git

2018-05-23 10:54

administrator   ~0076134

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.

san

2018-05-23 12:15

developer   ~0076154

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.

git

2019-02-28 01:41

administrator   ~0082434

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.

git

2019-02-28 01:43

administrator   ~0082435

Branch CR24437_4 has been updated forcibly by kgv.

SHA-1: b785bfccef195587d0a0863db18e68b191b96e67

git

2019-02-28 15:08

administrator   ~0082458

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.

git

2019-02-28 15:28

administrator   ~0082459

Branch CR24437_5 has been updated forcibly by kgv.

SHA-1: 46fd7d42178c719b5df71c720eb098fa3c5c96f0

kgv

2019-02-28 15:30

developer  

bottle_outlined.png (11,338 bytes)

git

2019-02-28 17:42

administrator   ~0082466

Branch CR24437_5 has been updated forcibly by kgv.

SHA-1: da12c29fc34703665225dd4cab61e360f3dde41b

kgv

2019-02-28 18:48

developer   ~0082471

Please raise the patch.

apn

2019-02-28 20:18

administrator   ~0082475

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

git

2019-03-05 13:46

administrator   ~0082606

Branch CR24437_4 has been deleted by kgv.

SHA-1: b785bfccef195587d0a0863db18e68b191b96e67

git

2019-03-05 13:46

administrator   ~0082607

Branch CR24437_5 has been deleted by kgv.

SHA-1: da12c29fc34703665225dd4cab61e360f3dde41b

git

2019-03-05 13:48

administrator   ~0082653

Branch CR24437 has been deleted by kgv.

SHA-1: 48685e81e952cf88c17dd6465cbf34ddee967800

git

2019-03-05 13:48

administrator   ~0082654

Branch CR24437_1 has been deleted by kgv.

SHA-1: 1d5f48c0f8576b9807144d389076fe542ab7931b

git

2019-03-05 13:48

administrator   ~0082655

Branch CR24437_2 has been deleted by kgv.

SHA-1: 3c723f1fe810a204aeb67162e5b65af7a016cb9e

git

2019-03-05 13:48

administrator   ~0082656

Branch CR24437_3 has been deleted by kgv.

SHA-1: 5ac1eae43c8b5fb2930666faf178e67e6dff7555

Related Changesets

occt: master 6ef0d6f1

2019-02-27 22:36:32

asl


Committer: apn Details Diff
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.
Affected Issues
0024437
mod - src/Graphic3d/Graphic3d_AspectFillArea3d.cxx Diff File
mod - src/Graphic3d/Graphic3d_AspectFillArea3d.hxx Diff File
mod - src/OpenGl/OpenGl_BackgroundArray.cxx Diff File
mod - src/OpenGl/OpenGl_PrimitiveArray.cxx Diff File
mod - src/OpenGl/OpenGl_SetOfShaderPrograms.hxx Diff File
mod - src/OpenGl/OpenGl_ShaderManager.cxx Diff File
mod - src/OpenGl/OpenGl_ShaderManager.hxx Diff File
mod - src/OpenGl/OpenGl_ShaderProgram.cxx Diff File
mod - src/OpenGl/OpenGl_ShaderProgram.hxx Diff File
mod - src/ViewerTest/ViewerTest.cxx Diff File
add - tests/v3d/glsl/outline1 Diff File
add - tests/v3d/glsl/outline2 Diff File

Issue History

Date Modified Username Field Change
2013-12-05 07:44 san New Issue
2013-12-05 07:44 san Assigned To => san
2018-05-10 16:40 git Note Added: 0075928
2018-05-10 18:05 git Note Added: 0075930
2018-05-10 19:53 san Assigned To san => asl
2018-05-10 19:53 san Status new => assigned
2018-05-17 16:07 git Note Added: 0076014
2018-05-17 16:10 git Note Added: 0076015
2018-05-17 17:02 git Note Added: 0076016
2018-05-17 17:32 git Note Added: 0076017
2018-05-18 10:48 git Note Added: 0076030
2018-05-18 10:50 git Note Added: 0076031
2018-05-18 10:56 asl Note Added: 0076033
2018-05-18 10:56 asl Assigned To asl => san
2018-05-18 10:56 asl Status assigned => resolved
2018-05-18 10:56 asl Steps to Reproduce Updated
2018-05-18 11:23 asl Assigned To san => kgv
2018-05-18 12:06 kgv Summary Efficient HLR visualization based on OpenGL and GLSL => Visualization - Efficient HLR visualization based on OpenGL and GLSL
2018-05-18 12:07 kgv Note Added: 0076035
2018-05-18 12:07 kgv Assigned To kgv => asl
2018-05-18 12:07 kgv Priority low => normal
2018-05-18 12:07 kgv Status resolved => feedback
2018-05-18 12:07 kgv Target Version => 7.4.0
2018-05-18 14:49 asl File Added: hlr_1.png
2018-05-18 14:49 asl File Added: hlr_2.png
2018-05-18 14:50 git Note Added: 0076037
2018-05-18 14:51 asl Assigned To asl => kgv
2018-05-18 14:51 asl Status feedback => resolved
2018-05-18 15:39 abv Note Added: 0076038
2018-05-21 09:50 git Note Added: 0076048
2018-05-21 09:52 asl Note Added: 0076049
2018-05-21 09:55 asl File Deleted: hlr_1.png
2018-05-21 09:55 asl File Added: hlr_1.png
2018-05-22 16:19 git Note Added: 0076102
2018-05-22 18:43 git Note Added: 0076104
2018-05-22 20:00 kgv Description Updated
2018-05-22 20:02 kgv Description Updated
2018-05-22 20:16 git Note Added: 0076107
2018-05-22 20:27 git Note Added: 0076108
2018-05-22 21:05 kgv Summary Visualization - Efficient HLR visualization based on OpenGL and GLSL => Visualization - silhouette edges based on OpenGL
2018-05-22 21:37 git Note Added: 0076109
2018-05-22 21:38 kgv File Added: cad_outliuned.png
2018-05-22 21:41 git Note Added: 0076110
2018-05-22 21:42 kgv Note Added: 0076111
2018-05-22 21:42 kgv Assigned To kgv => san
2018-05-23 08:27 kgv Note Added: 0076118
2018-05-23 10:25 git Note Added: 0076127
2018-05-23 10:54 git Note Added: 0076133
2018-05-23 10:54 git Note Added: 0076134
2018-05-23 12:15 san Note Added: 0076154
2018-05-23 12:15 san Assigned To san => asl
2018-05-23 12:15 san Status resolved => feedback
2018-05-23 13:50 kgv File Added: solidworks-heads-up-view-toolbar-display-style-example-window.jpg
2018-05-23 13:50 kgv File Deleted: solidworks-heads-up-view-toolbar-display-style-example-window.jpg
2018-05-23 13:53 kgv Description Updated
2019-02-28 01:41 git Note Added: 0082434
2019-02-28 01:43 git Note Added: 0082435
2019-02-28 15:08 git Note Added: 0082458
2019-02-28 15:28 git Note Added: 0082459
2019-02-28 15:30 kgv File Added: bottle_outlined.png
2019-02-28 17:42 git Note Added: 0082466
2019-02-28 18:48 kgv Note Added: 0082471
2019-02-28 18:48 kgv Assigned To asl => bugmaster
2019-02-28 18:48 kgv Status feedback => reviewed
2019-02-28 19:17 apn Test case number => v3d glsl outline1 outline2
2019-02-28 20:18 apn Note Added: 0082475
2019-02-28 20:18 apn Status reviewed => tested
2019-03-03 21:12 apn Changeset attached => occt master 6ef0d6f1
2019-03-03 21:12 apn Assigned To bugmaster => apn
2019-03-03 21:12 apn Status tested => verified
2019-03-03 21:12 apn Resolution open => fixed
2019-03-05 13:46 git Note Added: 0082606
2019-03-05 13:46 git Note Added: 0082607
2019-03-05 13:48 git Note Added: 0082653
2019-03-05 13:48 git Note Added: 0082654
2019-03-05 13:48 git Note Added: 0082655
2019-03-05 13:48 git Note Added: 0082656