diff --git a/src/mol-gl/renderer.ts b/src/mol-gl/renderer.ts index a05756c6392b7fc26cc37d3f4c7aa408f33ef6a0..7c6831489246a6aebe4c38633518c05a211fe5f4 100644 --- a/src/mol-gl/renderer.ts +++ b/src/mol-gl/renderer.ts @@ -177,7 +177,7 @@ namespace Renderer { gl.depthMask(true) for (let i = 0, il = renderables.length; i < il; ++i) { const r = renderables[i] - if (r.state.opaque && !r.values.dTransparency.ref.value) renderObject(r, variant) + if (r.state.opaque) renderObject(r, variant) } gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA) @@ -185,7 +185,7 @@ namespace Renderer { for (let i = 0, il = renderables.length; i < il; ++i) { const r = renderables[i] gl.depthMask(r.values.uAlpha.ref.value === 1.0) - if (!r.state.opaque || r.values.dTransparency.ref.value) renderObject(r, variant) + if (!r.state.opaque) renderObject(r, variant) } } else { // picking diff --git a/src/mol-gl/shader/chunks/assign-color-varying.glsl b/src/mol-gl/shader/chunks/assign-color-varying.glsl index 3aff425ffe42230481d5b75bdf3da9d0577a6802..8f829fce5238a73f8c48b76f0c731288b76161fa 100644 --- a/src/mol-gl/shader/chunks/assign-color-varying.glsl +++ b/src/mol-gl/shader/chunks/assign-color-varying.glsl @@ -19,5 +19,6 @@ #endif #ifdef dTransparency + vGroup = aGroup; vTransparency = readFromTexture(tTransparency, aInstance * float(uGroupCount) + aGroup, uTransparencyTexDim).a; #endif \ No newline at end of file diff --git a/src/mol-gl/shader/chunks/assign-material-color.glsl b/src/mol-gl/shader/chunks/assign-material-color.glsl index 56e406dcedb22bc3b379ab39d045f9e925ad1255..76b82ed1c87d2faac3fad83a1857335cd63d4742 100644 --- a/src/mol-gl/shader/chunks/assign-material-color.glsl +++ b/src/mol-gl/shader/chunks/assign-material-color.glsl @@ -24,29 +24,31 @@ // ); // float at = thresholdMatrix[pixelCoord.x % 4][pixelCoord.y % 4]; - // https://research.nvidia.com/publication/hashed-alpha-testing - // Find the discretized derivatives of our coordinates - float maxDeriv = max(length(dFdx(vViewPosition)), length(dFdy(vViewPosition))); - float pixScale = 1.0 / maxDeriv; - // Find two nearest log-discretized noise scales - vec2 pixScales = vec2(exp2(floor(log2(pixScale))), exp2(ceil(log2(pixScale)))); - // Compute alpha thresholds at our two noise scales - vec2 alpha = vec2(hash3d(floor(pixScales.x * vViewPosition)), hash3d(floor(pixScales.y * vViewPosition))); - // Factor to interpolate lerp with - float lerpFactor = fract(log2(pixScale)); - // Interpolate alpha threshold from noise at two scales - float x = (1.0 - lerpFactor) * alpha.x + lerpFactor * alpha.y; - // Pass into CDF to compute uniformly distrib threshold - float a = min(lerpFactor, 1.0 - lerpFactor); - vec3 cases = vec3( - x * x / (2.0 * a * (1.0 - a)), - (x - 0.5 * a) / (1.0 - a), - 1.0 - ((1.0 - x) * (1.0 - x) / (2.0 * a * (1.0 - a))) - ); - // Find our final, uniformly distributed alpha threshold - float at = (x < (1.0 - a)) ? ((x < a) ? cases.x : cases.y) : cases.z; - // Avoids ατ == 0. Could also do - at = clamp(at, 1.0e-6, 1.0); + // // https://research.nvidia.com/publication/hashed-alpha-testing + // // Find the discretized derivatives of our coordinates + // float maxDeriv = max(length(dFdx(vViewPosition)), length(dFdy(vViewPosition))); + // float pixScale = 1.0 / maxDeriv; + // // Find two nearest log-discretized noise scales + // vec2 pixScales = vec2(exp2(floor(log2(pixScale))), exp2(ceil(log2(pixScale)))); + // // Compute alpha thresholds at our two noise scales + // vec2 alpha = vec2(hash3d(floor(pixScales.x * vViewPosition)), hash3d(floor(pixScales.y * vViewPosition))); + // // Factor to interpolate lerp with + // float lerpFactor = fract(log2(pixScale)); + // // Interpolate alpha threshold from noise at two scales + // float x = (1.0 - lerpFactor) * alpha.x + lerpFactor * alpha.y; + // // Pass into CDF to compute uniformly distrib threshold + // float a = min(lerpFactor, 1.0 - lerpFactor); + // vec3 cases = vec3( + // x * x / (2.0 * a * (1.0 - a)), + // (x - 0.5 * a) / (1.0 - a), + // 1.0 - ((1.0 - x) * (1.0 - x) / (2.0 * a * (1.0 - a))) + // ); + // // Find our final, uniformly distributed alpha threshold + // float at = (x < (1.0 - a)) ? ((x < a) ? cases.x : cases.y) : cases.z; + // // Avoids ατ == 0. Could also do + // at = clamp(at, 1.0e-6, 1.0); + + float at = fract(dot(vec3(gl_FragCoord.xy, vGroup + 0.5), vec3(2.0, 7.0, 23.0) / 17.0f)); if (ma < 0.99 && (ma < 0.01 || ma < at)) discard; #endif \ No newline at end of file diff --git a/src/mol-gl/shader/chunks/color-frag-params.glsl b/src/mol-gl/shader/chunks/color-frag-params.glsl index 8e3a16e29296e76b4c4ed3588b70304eaa760fea..8b3e905b4c5134ede7f3e9d69b5b2aae658b4f71 100644 --- a/src/mol-gl/shader/chunks/color-frag-params.glsl +++ b/src/mol-gl/shader/chunks/color-frag-params.glsl @@ -15,5 +15,6 @@ #endif #ifdef dTransparency + varying float vGroup; varying float vTransparency; #endif \ No newline at end of file diff --git a/src/mol-gl/shader/chunks/color-vert-params.glsl b/src/mol-gl/shader/chunks/color-vert-params.glsl index 31066d58bd9bbeb357cc6e17d4b3bcae4f46f5e7..3daf743fe42366c229372b9767c532e18f4390e8 100644 --- a/src/mol-gl/shader/chunks/color-vert-params.glsl +++ b/src/mol-gl/shader/chunks/color-vert-params.glsl @@ -23,6 +23,7 @@ #endif #ifdef dTransparency + varying float vGroup; varying float vTransparency; uniform vec2 uTransparencyTexDim; uniform sampler2D tTransparency;