mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0024437: Efficient HLR visualization based on OpenGL and GLSL
Patch for HLR presentation
This commit is contained in:
@@ -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);
|
||||
|
@@ -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" }"
|
||||
EOL" else"
|
||||
EOL" {"
|
||||
EOL" vec4 pos = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * vertex;"
|
||||
EOL" delta = normal.xyz * aShift * pos.w;"
|
||||
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" }"
|
||||
EOL" else"
|
||||
EOL" {"
|
||||
EOL" if (occIsSilhouettePass > 0.1)"
|
||||
EOL" {"
|
||||
EOL" vec4 pos = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * vertex;"
|
||||
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;"
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user