Browse Source

take fog into account for picking visibility

Alexander Rose 5 years ago
parent
commit
63823698c7

+ 2 - 0
src/mol-gl/shader-code.ts

@@ -39,6 +39,7 @@ import assign_material_color from './shader/chunks/assign-material-color.glsl'
 import assign_normal from './shader/chunks/assign-normal.glsl'
 import assign_position from './shader/chunks/assign-position.glsl'
 import assign_size from './shader/chunks/assign-size.glsl'
+import check_picking_alpha from './shader/chunks/check-picking-alpha.glsl'
 import color_frag_params from './shader/chunks/color-frag-params.glsl'
 import color_vert_params from './shader/chunks/color-vert-params.glsl'
 import common_frag_params from './shader/chunks/common-frag-params.glsl'
@@ -63,6 +64,7 @@ const ShaderChunks: { [k: string]: string } = {
     assign_normal,
     assign_position,
     assign_size,
+    check_picking_alpha,
     color_frag_params,
     color_vert_params,
     common_frag_params,

+ 7 - 0
src/mol-gl/shader/chunks/check-picking-alpha.glsl.ts

@@ -0,0 +1,7 @@
+export default `
+float depth = length(vViewPosition);
+float fogFactor = smoothstep(uFogNear, uFogFar, depth);
+float alpha = (1.0 - fogFactor) * uAlpha;
+if (uAlpha < uPickingAlphaThreshold || alpha < 0.1)
+    discard; // ignore so the element below can be picked
+`

+ 1 - 2
src/mol-gl/shader/lines.frag.ts

@@ -16,8 +16,7 @@ void main(){
     #include assign_material_color
 
     #if defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
-        if (uAlpha < uPickingAlphaThreshold)
-            discard; // ignore so the element below can be picked
+        #include check_picking_alpha
         gl_FragColor = material;
     #elif defined(dColorType_depth)
         gl_FragColor = material;

+ 1 - 2
src/mol-gl/shader/mesh.frag.ts

@@ -18,8 +18,7 @@ void main() {
     #include assign_material_color
 
     #if defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
-        if (uAlpha < uPickingAlphaThreshold)
-            discard; // ignore so the element below can be picked
+        #include check_picking_alpha
         gl_FragColor = material;
     #elif defined(dColorType_depth)
         gl_FragColor = material;

+ 1 - 2
src/mol-gl/shader/points.frag.ts

@@ -23,8 +23,7 @@ void main(){
     #include assign_material_color
 
     #if defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
-        if (uAlpha < uPickingAlphaThreshold)
-            discard; // ignore so the element below can be picked
+        #include check_picking_alpha
         gl_FragColor = material;
     #elif defined(dColorType_depth)
         gl_FragColor = material;

+ 1 - 2
src/mol-gl/shader/spheres.frag.ts

@@ -118,8 +118,7 @@ void main(void){
     #include assign_material_color
 
     #if defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
-        if (uAlpha < uPickingAlphaThreshold)
-            discard; // ignore so the element below can be picked
+        #include check_picking_alpha
         gl_FragColor = material;
     #elif defined(dColorType_depth)
         gl_FragColor = material;

+ 1 - 2
src/mol-gl/shader/text.frag.ts

@@ -57,8 +57,7 @@ void main(){
     }
 
     #if defined(dColorType_objectPicking) || defined(dColorType_instancePicking) || defined(dColorType_groupPicking)
-        if (uAlpha < uPickingAlphaThreshold)
-            discard; // ignore so the element below can be picked
+        #include check_picking_alpha
     #elif defined(dColorType_depth)
         gl_FragColor = material;
     #else