]> OCCT Git - occt-copy.git/commitdiff
0024437: Efficient HLR visualization based on OpenGL and GLSL
authorasl <asl@opencascade.com>
Wed, 6 Jun 2018 05:25:35 +0000 (08:25 +0300)
committerasl <asl@opencascade.com>
Wed, 6 Jun 2018 05:45:54 +0000 (08:45 +0300)
Patch for HLR presentation

src/OpenGl/OpenGl_PrimitiveArray.cxx
src/OpenGl/OpenGl_ShaderManager.cxx
tests/bugs/vis/bug24437

index 8804b51bcc4d659b6809a622bcfbbfb7fd88d598..f6937deeaf3d2bdf8589044119c0a4955174c928 100644 (file)
@@ -828,7 +828,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
           theWorkspace->View()->Window()->Size(aViewWidth, aViewHeight);
           Standard_Integer aMin = aViewWidth < aViewHeight ? aViewWidth : aViewHeight;
 
-          Standard_ShortReal anEdgeWidth = (Standard_ShortReal)anAspectFace->Aspect()->EdgeWidth() / (Standard_ShortReal)aMin;
+          Standard_ShortReal anEdgeWidth = 2*(Standard_ShortReal)anAspectFace->Aspect()->EdgeWidth() / (Standard_ShortReal)aMin;
           aCtx->SetSilhouetteThickness(anEdgeWidth);
 
           aCtx->SetIsSilhouettePass(Standard_True);
index 2c8c74d5fa327f5bd494058b1a0163b9337e2a59..d5c29a6a5285c3213a3de98dac54f3bf6f0cf461 100644 (file)
@@ -1609,29 +1609,44 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
       EOL"uniform float occOrthoScale;"
       EOL"uniform float occIsSilhouettePass;"
       EOL"uniform float occSilhouetteThickness;"
-      EOL""
-      EOL"THE_SHADER_IN  vec4 normal;"
       ;
 
     aSrcVertExtraMain +=
       EOL"  vec3 delta = vec3(0.0, 0.0, 0.0);"
-      EOL"  if (occIsSilhouettePass > 0.1)"
+      EOL"  vec3 pdelta = vec3(0.0, 0.0, 0.0);"
+      EOL"  vec4 proj_normal = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * vec4(occNormal, 0.0);"
+      EOL""
+      EOL"  float aShift = occSilhouetteThickness / 2.0;"
+      EOL"  if (occOrthoScale > 0.0)"
       EOL"  {"
-      EOL"    float aShift = occSilhouetteThickness;"
-      EOL"    if (occOrthoScale > 0.0)"
+      EOL"    if (abs(proj_normal[2]) < 0.1)"
       EOL"    {"
-      EOL"      aShift *= occOrthoScale;"
-      EOL"      delta = normal.xyz * aShift;"
+      EOL"      float k = 1.0;"
+      EOL"      if (occIsSilhouettePass < 0.1)"
+      EOL"        k = -1.0;"
+      EOL"                 "
+      EOL"      //aShift *= occOrthoScale;"
+      EOL"      vec3 pn = normalize(vec3(proj_normal.xy, 0.0));"
+      EOL"      //delta = k * occNormal * aShift;"
+      EOL"      pdelta = k * pn * aShift;"
       EOL"    }"
-      EOL"    else"
+      EOL"  }"
+      EOL"  else"
+      EOL"  {"
+      EOL"    if (occIsSilhouettePass > 0.1)"
       EOL"    {"
       EOL"      vec4 pos = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * vertex;"
-      EOL"      delta = normal.xyz * aShift * pos.w;"
+      EOL"      delta = occNormal.xyz * aShift * pos.w;"
       EOL"    }"
       EOL"  }"
+      EOL"  "
       EOL"  vertex += vec4(delta, 0.0);"
       ;
 
+    aSrcVertEndMain +=
+      EOL"gl_Position += vec4(pdelta.xy, 0.0, 0.0);"
+      ;
+
     aSrcFragExtraOut +=
       EOL"uniform float occIsSilhouettePass;"
       EOL"uniform vec3 occBackgroundColor;"
index 84f7e8ed99eef2a0b78e2e8ff027e7dc5ef60a8a..4b2ac3a834e78faa71e7255c7199a3d18bf40497 100644 (file)
@@ -10,17 +10,27 @@ vinit View1
 vsetcolorbg 220 220 220
 
 psphere sph 1.0
+
 box b 1 2 3
 ttranslate b 2 -2 -2
 
+pcylinder cyl 1.0 1.0
+ttranslate cyl 4.2 0 0 
+
 vdisplay -dispMode 1 b
 vsetinteriorstyle b outline
-vshowfaceboundary b 1 255 0 0 1.0
+vshowfaceboundary b 1 255 0 0 1
 vsetedgetype b -color 255 0 0
 vfit
 
 vdisplay -dispMode 1 sph
 vsetinteriorstyle sph outline
-vshowfaceboundary sph 1 255 0 0 1.0
+vshowfaceboundary sph 1 255 0 0 1
 vsetedgetype sph -color 255 0 0
 vfit
+
+vdisplay -dispMode 1 cyl
+vsetinteriorstyle cyl outline
+vshowfaceboundary cyl 1 255 0 0 1
+vsetedgetype cyl -color 255 0 0
+vfit