From c425264ff812ffb5b3504de7103cd74ae44ef0e6 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 6 Jun 2018 08:25:35 +0300 Subject: [PATCH] 0024437: Efficient HLR visualization based on OpenGL and GLSL Patch for HLR presentation --- src/OpenGl/OpenGl_PrimitiveArray.cxx | 2 +- src/OpenGl/OpenGl_ShaderManager.cxx | 33 ++++++++++++++++++++-------- tests/bugs/vis/bug24437 | 14 ++++++++++-- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index 8804b51bcc..f6937deeaf 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -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); diff --git a/src/OpenGl/OpenGl_ShaderManager.cxx b/src/OpenGl/OpenGl_ShaderManager.cxx index 2c8c74d5fa..d5c29a6a52 100644 --- a/src/OpenGl/OpenGl_ShaderManager.cxx +++ b/src/OpenGl/OpenGl_ShaderManager.cxx @@ -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;" diff --git a/tests/bugs/vis/bug24437 b/tests/bugs/vis/bug24437 index 84f7e8ed99..4b2ac3a834 100644 --- a/tests/bugs/vis/bug24437 +++ b/tests/bugs/vis/bug24437 @@ -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 -- 2.39.5