molstar 3.0.0-dev.7 → 3.0.0-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/viewer/index.html +4 -0
- package/build/viewer/molstar.js +1 -1
- package/lib/apps/viewer/index.d.ts +1 -0
- package/lib/apps/viewer/index.html +4 -0
- package/lib/apps/viewer/index.js +2 -0
- package/lib/commonjs/apps/viewer/index.d.ts +1 -0
- package/lib/commonjs/apps/viewer/index.js +2 -0
- package/lib/commonjs/examples/alpha-orbitals/index.js +1 -1
- package/lib/commonjs/extensions/geo-export/mesh-exporter.js +4 -4
- package/lib/commonjs/extensions/rcsb/assembly-symmetry/behavior.d.ts +2 -2
- package/lib/commonjs/mol-canvas3d/canvas3d.d.ts +1 -1
- package/lib/commonjs/mol-canvas3d/canvas3d.js +33 -29
- package/lib/commonjs/mol-canvas3d/passes/draw.d.ts +13 -1
- package/lib/commonjs/mol-canvas3d/passes/draw.js +16 -15
- package/lib/commonjs/mol-canvas3d/passes/image.js +3 -2
- package/lib/commonjs/mol-canvas3d/passes/marking.js +1 -1
- package/lib/commonjs/mol-canvas3d/passes/multi-sample.d.ts +9 -2
- package/lib/commonjs/mol-canvas3d/passes/multi-sample.js +14 -12
- package/lib/commonjs/mol-canvas3d/passes/pick.js +3 -3
- package/lib/commonjs/mol-geo/geometry/color-data.d.ts +1 -1
- package/lib/commonjs/mol-geo/geometry/color-data.js +22 -0
- package/lib/commonjs/mol-geo/geometry/cylinders/cylinders.js +1 -1
- package/lib/commonjs/mol-geo/geometry/direct-volume/direct-volume.d.ts +5 -38
- package/lib/commonjs/mol-geo/geometry/direct-volume/direct-volume.js +21 -66
- package/lib/commonjs/mol-geo/geometry/direct-volume/transfer-function.d.ts +2 -4
- package/lib/commonjs/mol-geo/geometry/direct-volume/transfer-function.js +4 -7
- package/lib/commonjs/mol-geo/geometry/image/image.js +1 -1
- package/lib/commonjs/mol-geo/geometry/lines/lines.js +1 -1
- package/lib/commonjs/mol-geo/geometry/marker-data.js +13 -5
- package/lib/commonjs/mol-geo/geometry/mesh/mesh.js +1 -1
- package/lib/commonjs/mol-geo/geometry/points/points.js +1 -1
- package/lib/commonjs/mol-geo/geometry/size-data.js +5 -5
- package/lib/commonjs/mol-geo/geometry/spheres/spheres.js +1 -1
- package/lib/commonjs/mol-geo/geometry/text/text.js +1 -1
- package/lib/commonjs/mol-geo/geometry/texture-mesh/texture-mesh.js +1 -1
- package/lib/commonjs/mol-gl/compute/histogram-pyramid/sum.js +2 -2
- package/lib/commonjs/mol-gl/compute/marching-cubes/isosurface.d.ts +2 -2
- package/lib/commonjs/mol-gl/compute/marching-cubes/isosurface.js +10 -9
- package/lib/commonjs/mol-gl/renderable/cylinders.d.ts +1 -0
- package/lib/commonjs/mol-gl/renderable/direct-volume.d.ts +6 -10
- package/lib/commonjs/mol-gl/renderable/direct-volume.js +1 -1
- package/lib/commonjs/mol-gl/renderable/image.d.ts +1 -0
- package/lib/commonjs/mol-gl/renderable/lines.d.ts +1 -0
- package/lib/commonjs/mol-gl/renderable/mesh.d.ts +1 -0
- package/lib/commonjs/mol-gl/renderable/points.d.ts +1 -0
- package/lib/commonjs/mol-gl/renderable/schema.d.ts +1 -0
- package/lib/commonjs/mol-gl/renderable/schema.js +2 -2
- package/lib/commonjs/mol-gl/renderable/spheres.d.ts +1 -0
- package/lib/commonjs/mol-gl/renderable/text.d.ts +1 -0
- package/lib/commonjs/mol-gl/renderable/texture-mesh.d.ts +1 -1
- package/lib/commonjs/mol-gl/renderable/texture-mesh.js +1 -1
- package/lib/commonjs/mol-gl/renderer.js +12 -19
- package/lib/commonjs/mol-gl/shader/chunks/assign-color-varying.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/assign-color-varying.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/assign-group.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/assign-group.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/assign-position.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/assign-position.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/assign-size.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/assign-size.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/common.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/common.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/wboit-write.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/wboit-write.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/compute/color-smoothing/accumulate.vert.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/compute/color-smoothing/accumulate.vert.js +1 -1
- package/lib/commonjs/mol-gl/shader/direct-volume.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/direct-volume.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/gaussian-density.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/gaussian-density.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/histogram-pyramid/reduction.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/histogram-pyramid/reduction.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/image.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/image.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/marching-cubes/isosurface.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/marching-cubes/isosurface.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/mesh.vert.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/mesh.vert.js +1 -1
- package/lib/commonjs/mol-gl/shader-code.js +1 -1
- package/lib/commonjs/mol-math/geometry/gaussian-density/gpu.js +2 -2
- package/lib/commonjs/mol-plugin/behavior/dynamic/representation.js +4 -6
- package/lib/commonjs/mol-plugin/config.d.ts +0 -1
- package/lib/commonjs/mol-plugin/config.js +4 -25
- package/lib/commonjs/mol-plugin/features.d.ts +9 -0
- package/lib/commonjs/mol-plugin/features.js +38 -0
- package/lib/commonjs/mol-plugin-state/builder/structure/representation-preset.d.ts +4 -4
- package/lib/commonjs/mol-plugin-state/manager/structure/selection.js +3 -1
- package/lib/commonjs/mol-plugin-state/transforms/representation.js +2 -2
- package/lib/commonjs/mol-repr/structure/complex-representation.js +1 -1
- package/lib/commonjs/mol-repr/structure/complex-visual.d.ts +1 -19
- package/lib/commonjs/mol-repr/structure/params.d.ts +1 -19
- package/lib/commonjs/mol-repr/structure/registry.d.ts +1 -19
- package/lib/commonjs/mol-repr/structure/representation/gaussian-surface.js +1 -1
- package/lib/commonjs/mol-repr/structure/representation/gaussian-volume.d.ts +4 -58
- package/lib/commonjs/mol-repr/structure/representation/gaussian-volume.js +2 -7
- package/lib/commonjs/mol-repr/structure/representation/label.js +1 -1
- package/lib/commonjs/mol-repr/structure/representation/molecular-surface.js +1 -1
- package/lib/commonjs/mol-repr/structure/units-representation.js +1 -1
- package/lib/commonjs/mol-repr/structure/units-visual.d.ts +1 -19
- package/lib/commonjs/mol-repr/structure/visual/gaussian-density-volume.d.ts +2 -38
- package/lib/commonjs/mol-repr/structure/visual/gaussian-density-volume.js +8 -6
- package/lib/commonjs/mol-repr/structure/visual/gaussian-surface-mesh.js +11 -8
- package/lib/commonjs/mol-repr/structure/visual/gaussian-surface-wireframe.js +1 -1
- package/lib/commonjs/mol-repr/structure/visual/label-text.js +1 -2
- package/lib/commonjs/mol-repr/structure/visual/molecular-surface-mesh.js +1 -1
- package/lib/commonjs/mol-repr/structure/visual/molecular-surface-wireframe.js +1 -1
- package/lib/commonjs/mol-repr/structure/visual/util/common.d.ts +3 -2
- package/lib/commonjs/mol-repr/structure/visual/util/common.js +2 -5
- package/lib/commonjs/mol-repr/structure/visual/util/gaussian.d.ts +7 -6
- package/lib/commonjs/mol-repr/structure/visual/util/gaussian.js +12 -12
- package/lib/commonjs/mol-repr/structure/visual/util/molecular-surface.d.ts +2 -1
- package/lib/commonjs/mol-repr/structure/visual/util/molecular-surface.js +4 -4
- package/lib/commonjs/mol-repr/volume/direct-volume.d.ts +3 -57
- package/lib/commonjs/mol-repr/volume/direct-volume.js +8 -12
- package/lib/commonjs/mol-repr/volume/isosurface.js +11 -2
- package/lib/commonjs/mol-repr/volume/registry.d.ts +1 -19
- package/lib/commonjs/mol-repr/volume/slice.js +2 -2
- package/lib/commonjs/mol-repr/volume/util.js +2 -2
- package/lib/commonjs/mol-theme/color/volume-value.d.ts +17 -0
- package/lib/commonjs/mol-theme/color/volume-value.js +57 -0
- package/lib/commonjs/mol-theme/color.d.ts +3 -0
- package/lib/commonjs/mol-theme/color.js +2 -0
- package/lib/commonjs/mol-util/number-packing.d.ts +11 -0
- package/lib/commonjs/mol-util/{float-packing.js → number-packing.js} +10 -19
- package/lib/examples/alpha-orbitals/index.js +1 -1
- package/lib/extensions/geo-export/mesh-exporter.js +4 -4
- package/lib/extensions/rcsb/assembly-symmetry/behavior.d.ts +2 -2
- package/lib/mol-canvas3d/canvas3d.d.ts +1 -1
- package/lib/mol-canvas3d/canvas3d.js +33 -29
- package/lib/mol-canvas3d/passes/draw.d.ts +13 -1
- package/lib/mol-canvas3d/passes/draw.js +16 -15
- package/lib/mol-canvas3d/passes/image.js +3 -2
- package/lib/mol-canvas3d/passes/marking.js +1 -1
- package/lib/mol-canvas3d/passes/multi-sample.d.ts +9 -2
- package/lib/mol-canvas3d/passes/multi-sample.js +14 -12
- package/lib/mol-canvas3d/passes/pick.js +2 -2
- package/lib/mol-geo/geometry/color-data.d.ts +1 -1
- package/lib/mol-geo/geometry/color-data.js +22 -0
- package/lib/mol-geo/geometry/cylinders/cylinders.js +1 -1
- package/lib/mol-geo/geometry/direct-volume/direct-volume.d.ts +5 -38
- package/lib/mol-geo/geometry/direct-volume/direct-volume.js +22 -67
- package/lib/mol-geo/geometry/direct-volume/transfer-function.d.ts +2 -4
- package/lib/mol-geo/geometry/direct-volume/transfer-function.js +4 -7
- package/lib/mol-geo/geometry/image/image.js +1 -1
- package/lib/mol-geo/geometry/lines/lines.js +1 -1
- package/lib/mol-geo/geometry/marker-data.js +13 -5
- package/lib/mol-geo/geometry/mesh/mesh.js +1 -1
- package/lib/mol-geo/geometry/points/points.js +1 -1
- package/lib/mol-geo/geometry/size-data.js +5 -5
- package/lib/mol-geo/geometry/spheres/spheres.js +1 -1
- package/lib/mol-geo/geometry/text/text.js +1 -1
- package/lib/mol-geo/geometry/texture-mesh/texture-mesh.js +1 -1
- package/lib/mol-gl/compute/histogram-pyramid/sum.js +2 -2
- package/lib/mol-gl/compute/marching-cubes/isosurface.d.ts +2 -2
- package/lib/mol-gl/compute/marching-cubes/isosurface.js +10 -9
- package/lib/mol-gl/renderable/cylinders.d.ts +1 -0
- package/lib/mol-gl/renderable/direct-volume.d.ts +6 -10
- package/lib/mol-gl/renderable/direct-volume.js +1 -1
- package/lib/mol-gl/renderable/image.d.ts +1 -0
- package/lib/mol-gl/renderable/lines.d.ts +1 -0
- package/lib/mol-gl/renderable/mesh.d.ts +1 -0
- package/lib/mol-gl/renderable/points.d.ts +1 -0
- package/lib/mol-gl/renderable/schema.d.ts +1 -0
- package/lib/mol-gl/renderable/schema.js +2 -2
- package/lib/mol-gl/renderable/spheres.d.ts +1 -0
- package/lib/mol-gl/renderable/text.d.ts +1 -0
- package/lib/mol-gl/renderable/texture-mesh.d.ts +1 -1
- package/lib/mol-gl/renderable/texture-mesh.js +1 -1
- package/lib/mol-gl/renderer.js +12 -19
- package/lib/mol-gl/shader/chunks/assign-color-varying.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/assign-color-varying.glsl.js +1 -1
- package/lib/mol-gl/shader/chunks/assign-group.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/assign-group.glsl.js +1 -1
- package/lib/mol-gl/shader/chunks/assign-position.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/assign-position.glsl.js +1 -1
- package/lib/mol-gl/shader/chunks/assign-size.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/assign-size.glsl.js +1 -1
- package/lib/mol-gl/shader/chunks/common.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/common.glsl.js +1 -1
- package/lib/mol-gl/shader/chunks/wboit-write.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/wboit-write.glsl.js +1 -1
- package/lib/mol-gl/shader/compute/color-smoothing/accumulate.vert.d.ts +1 -1
- package/lib/mol-gl/shader/compute/color-smoothing/accumulate.vert.js +1 -1
- package/lib/mol-gl/shader/direct-volume.frag.d.ts +1 -1
- package/lib/mol-gl/shader/direct-volume.frag.js +1 -1
- package/lib/mol-gl/shader/gaussian-density.frag.d.ts +1 -1
- package/lib/mol-gl/shader/gaussian-density.frag.js +1 -1
- package/lib/mol-gl/shader/histogram-pyramid/reduction.frag.d.ts +1 -1
- package/lib/mol-gl/shader/histogram-pyramid/reduction.frag.js +1 -1
- package/lib/mol-gl/shader/image.frag.d.ts +1 -1
- package/lib/mol-gl/shader/image.frag.js +1 -1
- package/lib/mol-gl/shader/marching-cubes/isosurface.frag.d.ts +1 -1
- package/lib/mol-gl/shader/marching-cubes/isosurface.frag.js +1 -1
- package/lib/mol-gl/shader/mesh.vert.d.ts +1 -1
- package/lib/mol-gl/shader/mesh.vert.js +1 -1
- package/lib/mol-gl/shader-code.js +1 -1
- package/lib/mol-math/geometry/gaussian-density/gpu.js +2 -2
- package/lib/mol-plugin/behavior/dynamic/representation.js +4 -6
- package/lib/mol-plugin/config.d.ts +0 -1
- package/lib/mol-plugin/config.js +3 -23
- package/lib/mol-plugin/features.d.ts +9 -0
- package/lib/mol-plugin/features.js +35 -0
- package/lib/mol-plugin/version.js +2 -2
- package/lib/mol-plugin-state/builder/structure/representation-preset.d.ts +4 -4
- package/lib/mol-plugin-state/manager/structure/selection.js +3 -1
- package/lib/mol-plugin-state/transforms/representation.js +2 -2
- package/lib/mol-repr/structure/complex-representation.js +1 -1
- package/lib/mol-repr/structure/complex-visual.d.ts +1 -19
- package/lib/mol-repr/structure/params.d.ts +1 -19
- package/lib/mol-repr/structure/registry.d.ts +1 -19
- package/lib/mol-repr/structure/representation/gaussian-surface.js +1 -1
- package/lib/mol-repr/structure/representation/gaussian-volume.d.ts +4 -58
- package/lib/mol-repr/structure/representation/gaussian-volume.js +2 -7
- package/lib/mol-repr/structure/representation/label.js +1 -1
- package/lib/mol-repr/structure/representation/molecular-surface.js +1 -1
- package/lib/mol-repr/structure/units-representation.js +1 -1
- package/lib/mol-repr/structure/units-visual.d.ts +1 -19
- package/lib/mol-repr/structure/visual/gaussian-density-volume.d.ts +2 -38
- package/lib/mol-repr/structure/visual/gaussian-density-volume.js +8 -6
- package/lib/mol-repr/structure/visual/gaussian-surface-mesh.js +11 -8
- package/lib/mol-repr/structure/visual/gaussian-surface-wireframe.js +1 -1
- package/lib/mol-repr/structure/visual/label-text.js +1 -2
- package/lib/mol-repr/structure/visual/molecular-surface-mesh.js +1 -1
- package/lib/mol-repr/structure/visual/molecular-surface-wireframe.js +1 -1
- package/lib/mol-repr/structure/visual/util/common.d.ts +3 -2
- package/lib/mol-repr/structure/visual/util/common.js +2 -5
- package/lib/mol-repr/structure/visual/util/gaussian.d.ts +7 -6
- package/lib/mol-repr/structure/visual/util/gaussian.js +12 -12
- package/lib/mol-repr/structure/visual/util/molecular-surface.d.ts +2 -1
- package/lib/mol-repr/structure/visual/util/molecular-surface.js +4 -4
- package/lib/mol-repr/volume/direct-volume.d.ts +3 -57
- package/lib/mol-repr/volume/direct-volume.js +8 -12
- package/lib/mol-repr/volume/isosurface.js +11 -2
- package/lib/mol-repr/volume/registry.d.ts +1 -19
- package/lib/mol-repr/volume/slice.js +2 -2
- package/lib/mol-repr/volume/util.js +2 -2
- package/lib/mol-theme/color/volume-value.d.ts +17 -0
- package/lib/mol-theme/color/volume-value.js +52 -0
- package/lib/mol-theme/color.d.ts +3 -0
- package/lib/mol-theme/color.js +2 -0
- package/lib/mol-util/number-packing.d.ts +11 -0
- package/lib/mol-util/{float-packing.js → number-packing.js} +7 -14
- package/package.json +1 -1
- package/lib/commonjs/mol-util/float-packing.d.ts +0 -15
- package/lib/mol-util/float-packing.d.ts +0 -15
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.directVolume_frag = void 0;
|
|
10
|
-
exports.directVolume_frag = "\nprecision highp float;\nprecision highp int;\n\n#include common\n#include light_frag_params\n\n#if dClipObjectCount != 0\n uniform int uClipObjectType[dClipObjectCount];\n uniform bool uClipObjectInvert[dClipObjectCount];\n uniform vec3 uClipObjectPosition[dClipObjectCount];\n uniform vec4 uClipObjectRotation[dClipObjectCount];\n uniform vec3 uClipObjectScale[dClipObjectCount];\n#endif\n#include common_clip\n\n#include read_from_texture\n#include texture3d_from_1d_trilinear\n#include texture3d_from_2d_nearest\n#include texture3d_from_2d_linear\n\nuniform mat4 uProjection, uTransform, uModelView, uModel, uView;\nuniform vec3 uCameraDir;\n\nuniform sampler2D tDepth;\nuniform vec2 uDrawingBufferSize;\n\nvarying vec3 vOrigPos;\nvarying float vInstance;\nvarying vec4 vBoundingSphere;\nvarying mat4 vTransform;\n\nuniform mat4 uInvView;\nuniform vec2 uIsoValue;\nuniform vec3 uGridDim;\nuniform vec3 uBboxSize;\nuniform sampler2D tTransferTex;\nuniform float uTransferScale;\nuniform float uStepScale;\nuniform float uJumpLength;\n\nuniform int uObjectId;\nuniform int uVertexCount;\nuniform int uInstanceCount;\nuniform int uGroupCount;\n\nuniform vec3 uHighlightColor;\nuniform vec3 uSelectColor;\nuniform float uHighlightStrength;\nuniform float uSelectStrength;\nuniform int uMarkerPriority;\n\nuniform float uMarker;\nuniform vec2 uMarkerTexDim;\nuniform sampler2D tMarker;\n\nuniform float uMetalness;\nuniform float uRoughness;\n\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\n\nuniform float uAlpha;\nuniform float uPickingAlphaThreshold;\nuniform bool uTransparentBackground;\nuniform float uXrayEdgeFalloff;\n\nuniform float uInteriorDarkening;\nuniform bool uInteriorColorFlag;\nuniform vec3 uInteriorColor;\nbool interior;\n\nuniform bool uRenderWboit;\nuniform bool uDoubleSided;\nuniform int uPickType;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uIsOrtho;\n\nuniform vec3 uCellDim;\nuniform vec3 uCameraPosition;\nuniform mat4 uCartnToUnit;\n\n#if __VERSION__ != 100\n // for webgl1 this is given as a 'define'\n uniform int uMaxSteps;\n#endif\n\n#if defined(dGridTexType_2d)\n precision highp sampler2D;\n uniform sampler2D tGridTex;\n uniform vec3 uGridTexDim;\n#elif defined(dGridTexType_3d)\n precision highp sampler3D;\n uniform sampler3D tGridTex;\n#endif\n\n#if defined(dRenderVariant_color)\n #if defined(dColorType_uniform)\n uniform vec3 uColor;\n #elif defined(dColorType_texture)\n uniform vec2 uColorTexDim;\n uniform sampler2D tColor;\n #endif\n\n #ifdef dOverpaint\n #if defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance)\n uniform vec2 uOverpaintTexDim;\n uniform sampler2D tOverpaint;\n #endif\n #endif\n\n #ifdef dSubstance\n #if defined(dSubstanceType_groupInstance) || defined(dSubstanceType_vertexInstance)\n uniform vec2 uSubstanceTexDim;\n uniform sampler2D tSubstance;\n #endif\n #endif\n#endif\n\n#if defined(dGridTexType_2d)\n vec4 textureVal(vec3 pos) {\n return texture3dFrom2dLinear(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);\n }\n vec4 textureGroup(vec3 pos) {\n return texture3dFrom2dNearest(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);\n }\n#elif defined(dGridTexType_3d)\n vec4 textureVal(vec3 pos) {\n return texture(tGridTex, pos + (vec3(0.5) / uGridDim));\n }\n vec4 textureGroup(vec3 pos) {\n return texelFetch(tGridTex, ivec3(pos * uGridDim), 0);\n }\n#endif\n\nfloat calcDepth(const in vec3 pos) {\n vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw;\n return 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\n\nvec4 transferFunction(float value) {\n return texture2D(tTransferTex, vec2(value, 0.0));\n}\n\nfloat getDepth(const in vec2 coords) {\n #ifdef depthTextureSupport\n if (!uRenderWboit) {\n // in case of opaque volumes (and depth texture support)\n return texture2D(tDepth, coords).r;\n } else {\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n }\n #else\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n #endif\n}\n\nconst float gradOffset = 0.5;\n\nvec3 v3m4(vec3 p, mat4 m) {\n return (m * vec4(p, 1.0)).xyz;\n}\n\nfloat preFogAlphaBlended = 0.0;\n\nvec4 raymarch(vec3 startLoc, vec3 step, vec3 rayDir) {\n #if defined(dRenderVariant_color) && !defined(dIgnoreLight)\n mat3 normalMatrix = transpose3(inverse3(mat3(uModelView * vTransform)));\n #endif\n mat4 cartnToUnit = uCartnToUnit * inverse4(vTransform);\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n mat4 modelTransform = uModel * vTransform * uTransform;\n #endif\n mat4 modelViewTransform = uModelView * vTransform * uTransform;\n\n vec3 scaleVol = vec3(1.0) / uGridDim;\n vec3 pos = startLoc;\n vec4 cell;\n float prevValue = -1.0;\n float value = 0.0;\n vec4 src = vec4(0.0);\n vec4 dst = vec4(0.0);\n bool hit = false;\n float fragmentDepth;\n\n vec3 posMin = vec3(0.0);\n vec3 posMax = vec3(1.0) - vec3(1.0) / uGridDim;\n\n vec3 unitPos;\n vec3 isoPos;\n\n vec3 nextPos;\n float nextValue;\n\n vec3 color = vec3(0.45, 0.55, 0.8);\n vec4 overpaint = vec4(0.0);\n vec3 substance = vec3(0.0);\n float metalness = uMetalness;\n float roughness = uRoughness;\n\n vec3 gradient = vec3(1.0);\n vec3 dx = vec3(gradOffset * scaleVol.x, 0.0, 0.0);\n vec3 dy = vec3(0.0, gradOffset * scaleVol.y, 0.0);\n vec3 dz = vec3(0.0, 0.0, gradOffset * scaleVol.z);\n\n float maxDist = min(vBoundingSphere.w * 2.0, uFar - uNear);\n float maxDistSq = maxDist * maxDist;\n\n for (int i = 0; i < uMaxSteps; ++i) {\n // break when beyond bounding-sphere or far-plane\n vec3 distVec = startLoc - pos;\n if (dot(distVec, distVec) > maxDistSq) break;\n\n unitPos = v3m4(pos, cartnToUnit);\n\n // continue when outside of grid\n if (unitPos.x > posMax.x || unitPos.y > posMax.y || unitPos.z > posMax.z ||\n unitPos.x < posMin.x || unitPos.y < posMin.y || unitPos.z < posMin.z\n ) {\n if (hit) break;\n prevValue = value;\n pos += step;\n continue;\n }\n\n cell = textureVal(unitPos);\n value = cell.a; // current voxel value\n\n if (uJumpLength > 0.0 && value < 0.01) {\n nextPos = pos + rayDir * uJumpLength;\n nextValue = textureVal(v3m4(nextPos, cartnToUnit)).a;\n if (nextValue < 0.01) {\n prevValue = nextValue;\n pos = nextPos;\n continue;\n }\n }\n\n #if defined(dRenderMode_isosurface)\n if (prevValue > 0.0 && ( // there was a prev Value\n (prevValue < uIsoValue.x && value > uIsoValue.x) || // entering isosurface\n (prevValue > uIsoValue.x && value < uIsoValue.x) // leaving isosurface\n )) {\n isoPos = v3m4(mix(pos - step, pos, ((prevValue - uIsoValue.x) / ((prevValue - uIsoValue.x) - (value - uIsoValue.x)))), cartnToUnit);\n\n vec4 mvPosition = modelViewTransform * vec4(isoPos * uGridDim, 1.0);\n\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n vec3 vModelPosition = v3m4(isoPos * uGridDim, modelTransform);\n if (clipTest(vec4(vModelPosition, 0.0), 0)) {\n prevValue = value;\n pos += step;\n continue;\n }\n #endif\n\n float depth = calcDepth(mvPosition.xyz);\n if (depth > getDepth(gl_FragCoord.xy / uDrawingBufferSize))\n break;\n\n #ifdef enabledFragDepth\n if (!hit) {\n gl_FragDepthEXT = depth;\n }\n #endif\n\n #if defined(dRenderVariant_pick)\n if (uPickType == 1) {\n return vec4(encodeFloatRGB(float(uObjectId)), 1.0);\n } else if (uPickType == 2) {\n return vec4(encodeFloatRGB(vInstance), 1.0);\n } else {\n #ifdef dPackedGroup\n return vec4(textureGroup(floor(isoPos * uGridDim + 0.5) / uGridDim).rgb, 1.0);\n #else\n vec3 g = floor(isoPos * uGridDim + 0.5);\n return vec4(encodeFloatRGB(g.z + g.y * uGridDim.z + g.x * uGridDim.z * uGridDim.y), 1.0);\n #endif\n }\n #elif defined(dRenderVariant_depth)\n #ifdef enabledFragDepth\n return packDepthToRGBA(gl_FragDepthEXT);\n #else\n return packDepthToRGBA(depth);\n #endif\n #elif defined(dRenderVariant_color)\n #ifdef dPackedGroup\n float group = decodeFloatRGB(textureGroup(floor(isoPos * uGridDim + 0.5) / uGridDim).rgb);\n #else\n vec3 g = floor(isoPos * uGridDim + 0.5);\n float group = g.z + g.y * uGridDim.z + g.x * uGridDim.z * uGridDim.y;\n #endif\n\n #if defined(dColorType_uniform)\n color = uColor;\n #elif defined(dColorType_instance)\n color = readFromTexture(tColor, vInstance, uColorTexDim).rgb;\n #elif defined(dColorType_group)\n color = readFromTexture(tColor, group, uColorTexDim).rgb;\n #elif defined(dColorType_groupInstance)\n color = readFromTexture(tColor, vInstance * float(uGroupCount) + group, uColorTexDim).rgb;\n #elif defined(dColorType_vertex)\n color = texture3dFrom1dTrilinear(tColor, isoPos, uGridDim, uColorTexDim, 0.0).rgb;\n #elif defined(dColorType_vertexInstance)\n color = texture3dFrom1dTrilinear(tColor, isoPos, uGridDim, uColorTexDim, vInstance * float(uVertexCount)).rgb;\n #endif\n\n #ifdef dOverpaint\n #if defined(dOverpaintType_groupInstance)\n overpaint = readFromTexture(tOverpaint, vInstance * float(uGroupCount) + group, uOverpaintTexDim);\n #elif defined(dOverpaintType_vertexInstance)\n overpaint = texture3dFrom1dTrilinear(tOverpaint, isoPos, uGridDim, uOverpaintTexDim, vInstance * float(uVertexCount));\n #endif\n\n color = mix(color, overpaint.rgb, overpaint.a);\n #endif\n\n // handle flipping and negative isosurfaces\n #ifdef dFlipSided\n bool flipped = value < uIsoValue.y; // flipped\n #else\n bool flipped = value > uIsoValue.y;\n #endif\n interior = value < uIsoValue.x && flipped;\n if (uDoubleSided) {\n if (interior) {\n prevValue = value;\n pos += step;\n continue;\n }\n }\n vec3 vViewPosition = mvPosition.xyz;\n vec4 material = vec4(color, uAlpha);\n\n #ifdef dIgnoreLight\n gl_FragColor = material;\n #else\n #if defined(dFlatShaded)\n // nearest grid point\n isoPos = floor(isoPos * uGridDim + 0.5) / uGridDim;\n #endif\n #ifdef dPackedGroup\n // compute gradient by central differences\n gradient.x = textureVal(isoPos - dx).a - textureVal(isoPos + dx).a;\n gradient.y = textureVal(isoPos - dy).a - textureVal(isoPos + dy).a;\n gradient.z = textureVal(isoPos - dz).a - textureVal(isoPos + dz).a;\n #else\n gradient = textureVal(isoPos).xyz * 2.0 - 1.0;\n #endif\n vec3 normal = -normalize(normalMatrix * normalize(gradient));\n normal = normal * (float(flipped) * 2.0 - 1.0);\n normal = normal * -(float(interior) * 2.0 - 1.0);\n #ifdef dSubstance\n #if defined(dSubstanceType_groupInstance)\n substance = readFromTexture(tSubstance, vInstance * float(uGroupCount) + group, uSubstanceTexDim).rgb;\n #elif defined(dSubstanceType_vertexInstance)\n substance = texture3dFrom1dTrilinear(tSubstance, isoPos, uGridDim, uSubstanceTexDim, vInstance * float(uVertexCount)).rgb;\n #endif\n metalness = mix(metalness, substance.r, substance.b);\n roughness = mix(roughness, substance.g, substance.b);\n #endif\n #include apply_light_color\n #endif\n\n float marker = uMarker;\n if (uMarker == -1.0) {\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n #include apply_interior_color\n #include apply_marker_color\n\n preFogAlphaBlended = (1.0 - preFogAlphaBlended) * gl_FragColor.a + preFogAlphaBlended;\n fragmentDepth = depth;\n #include apply_fog\n\n src = gl_FragColor;\n\n if (!uTransparentBackground) {\n // done in 'apply_fog' otherwise\n src.rgb *= src.a;\n }\n dst = (1.0 - dst.a) * src + dst; // standard blending\n #endif\n\n #ifdef dSingleLayer\n break;\n #endif\n\n hit = true;\n }\n prevValue = value;\n #elif defined(dRenderMode_volume)\n vec4 mvPosition = modelViewTransform * vec4(unitPos * uGridDim, 1.0);\n if (calcDepth(mvPosition.xyz) > getDepth(gl_FragCoord.xy / uDrawingBufferSize))\n break;\n\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n vec3 vModelPosition = v3m4(unitPos * uGridDim, modelTransform);\n if (clipTest(vec4(vModelPosition, 0.0), 0)) {\n prevValue = value;\n pos += step;\n continue;\n }\n #endif\n\n #if defined(dRenderVariant_color)\n vec3 vViewPosition = mvPosition.xyz;\n vec4 material = transferFunction(value);\n\n #ifdef dIgnoreLight\n gl_FragColor.rgb = material.rgb;\n #else\n if (material.a >= 0.01) {\n #ifdef dPackedGroup\n // compute gradient by central differences\n gradient.x = textureVal(unitPos - dx).a - textureVal(unitPos + dx).a;\n gradient.y = textureVal(unitPos - dy).a - textureVal(unitPos + dy).a;\n gradient.z = textureVal(unitPos - dz).a - textureVal(unitPos + dz).a;\n #else\n gradient = cell.xyz * 2.0 - 1.0;\n #endif\n vec3 normal = -normalize(normalMatrix * normalize(gradient));\n #include apply_light_color\n } else {\n gl_FragColor.rgb = material.rgb;\n }\n #endif\n\n gl_FragColor.a = material.a * uAlpha * uTransferScale;\n\n float marker = uMarker;\n if (uMarker == -1.0) {\n #ifdef dPackedGroup\n float group = decodeFloatRGB(textureGroup(floor(unitPos * uGridDim + 0.5) / uGridDim).rgb);\n #else\n vec3 g = floor(unitPos * uGridDim + 0.5);\n float group = g.z + g.y * uGridDim.z + g.x * uGridDim.z * uGridDim.y;\n #endif\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n #include apply_marker_color\n\n preFogAlphaBlended = (1.0 - preFogAlphaBlended) * gl_FragColor.a + preFogAlphaBlended;\n fragmentDepth = calcDepth(mvPosition.xyz);\n #include apply_fog\n\n src = gl_FragColor;\n\n if (!uTransparentBackground) {\n // done in 'apply_fog' otherwise\n src.rgb *= src.a;\n }\n dst = (1.0 - dst.a) * src + dst; // standard blending\n #endif\n #endif\n\n // break if the color is opaque enough\n if (dst.a > 0.95)\n break;\n\n pos += step;\n }\n\n #if defined(dRenderMode_isosurface) && defined(enabledFragDepth)\n // ensure depth is written everywhere\n if (!hit)\n gl_FragDepthEXT = 1.0;\n #endif\n\n return dst;\n}\n\n// TODO: support float texture for higher precision values???\n// TODO: support clipping exclusion texture support\n\nvoid main() {\n if (gl_FrontFacing)\n discard;\n\n #ifdef dRenderVariant_marking\n // not supported\n discard;\n #endif\n\n #if defined(dRenderVariant_pick) || defined(dRenderVariant_depth)\n #if defined(dRenderMode_volume)\n // always ignore pick & depth for volume\n discard;\n #elif defined(dRenderMode_isosurface)\n if (uAlpha < uPickingAlphaThreshold)\n discard; // ignore so the element below can be picked\n #endif\n #endif\n\n vec3 rayDir = mix(normalize(vOrigPos - uCameraPosition), uCameraDir, uIsOrtho);\n vec3 step = rayDir * uStepScale;\n\n float boundingSphereNear = distance(vBoundingSphere.xyz, uCameraPosition) - vBoundingSphere.w;\n float d = max(uNear, boundingSphereNear) - mix(0.0, distance(vOrigPos, uCameraPosition), uIsOrtho);\n vec3 start = mix(uCameraPosition, vOrigPos, uIsOrtho) + (d * rayDir);\n gl_FragColor = raymarch(start, step, rayDir);\n\n #if defined(dRenderVariant_pick) || defined(dRenderVariant_depth)\n // discard when nothing was hit\n if (gl_FragColor == vec4(0.0))\n discard;\n #endif\n\n #if defined(dRenderVariant_color)\n #if defined(dRenderMode_isosurface) && defined(enabledFragDepth)\n float fragmentDepth = gl_FragDepthEXT;\n #else\n float fragmentDepth = calcDepth((uModelView * vec4(start, 1.0)).xyz);\n #endif\n float preFogAlpha = clamp(preFogAlphaBlended, 0.0, 1.0);\n interior = false;\n #include wboit_write\n #endif\n}\n";
|
|
10
|
+
exports.directVolume_frag = "\nprecision highp float;\nprecision highp int;\n\n#include common\n#include light_frag_params\n\n#if dClipObjectCount != 0\n uniform int uClipObjectType[dClipObjectCount];\n uniform bool uClipObjectInvert[dClipObjectCount];\n uniform vec3 uClipObjectPosition[dClipObjectCount];\n uniform vec4 uClipObjectRotation[dClipObjectCount];\n uniform vec3 uClipObjectScale[dClipObjectCount];\n#endif\n#include common_clip\n\n#include read_from_texture\n#include texture3d_from_1d_trilinear\n#include texture3d_from_2d_nearest\n#include texture3d_from_2d_linear\n\nuniform mat4 uProjection, uTransform, uModelView, uModel, uView;\nuniform vec3 uCameraDir;\n\nuniform sampler2D tDepth;\nuniform vec2 uDrawingBufferSize;\n\nvarying vec3 vOrigPos;\nvarying float vInstance;\nvarying vec4 vBoundingSphere;\nvarying mat4 vTransform;\n\nuniform mat4 uInvView;\nuniform vec3 uGridDim;\nuniform vec3 uBboxSize;\nuniform sampler2D tTransferTex;\nuniform float uTransferScale;\nuniform float uStepScale;\nuniform float uJumpLength;\n\nuniform int uObjectId;\nuniform int uVertexCount;\nuniform int uInstanceCount;\nuniform int uGroupCount;\n\nuniform vec3 uHighlightColor;\nuniform vec3 uSelectColor;\nuniform float uHighlightStrength;\nuniform float uSelectStrength;\nuniform int uMarkerPriority;\n\nuniform float uMarker;\nuniform vec2 uMarkerTexDim;\nuniform sampler2D tMarker;\n\nuniform float uMetalness;\nuniform float uRoughness;\n\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\n\nuniform float uAlpha;\nuniform float uPickingAlphaThreshold;\nuniform bool uTransparentBackground;\nuniform float uXrayEdgeFalloff;\n\nuniform float uInteriorDarkening;\nuniform bool uInteriorColorFlag;\nuniform vec3 uInteriorColor;\n\nuniform bool uRenderWboit;\nuniform bool uDoubleSided;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uIsOrtho;\n\nuniform vec3 uCellDim;\nuniform vec3 uCameraPosition;\nuniform mat4 uCartnToUnit;\n\n#if __VERSION__ != 100\n // for webgl1 this is given as a 'define'\n uniform int uMaxSteps;\n#endif\n\n#if defined(dGridTexType_2d)\n precision highp sampler2D;\n uniform sampler2D tGridTex;\n uniform vec3 uGridTexDim;\n#elif defined(dGridTexType_3d)\n precision highp sampler3D;\n uniform sampler3D tGridTex;\n#endif\n\n#if defined(dColorType_uniform)\n uniform vec3 uColor;\n#elif defined(dColorType_texture)\n uniform vec2 uColorTexDim;\n uniform sampler2D tColor;\n#endif\n\n#ifdef dOverpaint\n #if defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance)\n uniform vec2 uOverpaintTexDim;\n uniform sampler2D tOverpaint;\n #endif\n#endif\n\n#ifdef dUsePalette\n uniform sampler2D tPalette;\n#endif\n\n#if defined(dGridTexType_2d)\n vec4 textureVal(vec3 pos) {\n return texture3dFrom2dLinear(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);\n }\n vec4 textureGroup(vec3 pos) {\n return texture3dFrom2dNearest(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);\n }\n#elif defined(dGridTexType_3d)\n vec4 textureVal(vec3 pos) {\n return texture(tGridTex, pos + (vec3(0.5) / uGridDim));\n }\n vec4 textureGroup(vec3 pos) {\n return texelFetch(tGridTex, ivec3(pos * uGridDim), 0);\n }\n#endif\n\nfloat calcDepth(const in vec3 pos) {\n vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw;\n return 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\n\nfloat transferFunction(float value) {\n return texture2D(tTransferTex, vec2(value, 0.0)).a;\n}\n\nfloat getDepth(const in vec2 coords) {\n #ifdef depthTextureSupport\n if (!uRenderWboit) {\n // in case of opaque volumes (and depth texture support)\n return texture2D(tDepth, coords).r;\n } else {\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n }\n #else\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n #endif\n}\n\nconst float gradOffset = 0.5;\n\nvec3 v3m4(vec3 p, mat4 m) {\n return (m * vec4(p, 1.0)).xyz;\n}\n\nfloat preFogAlphaBlended = 0.0;\n\nvec4 raymarch(vec3 startLoc, vec3 step, vec3 rayDir) {\n #if !defined(dIgnoreLight)\n mat3 normalMatrix = transpose3(inverse3(mat3(uModelView * vTransform)));\n #endif\n mat4 cartnToUnit = uCartnToUnit * inverse4(vTransform);\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n mat4 modelTransform = uModel * vTransform * uTransform;\n #endif\n mat4 modelViewTransform = uModelView * vTransform * uTransform;\n\n vec3 scaleVol = vec3(1.0) / uGridDim;\n vec3 pos = startLoc;\n vec4 cell;\n float prevValue = -1.0;\n float value = 0.0;\n vec4 src = vec4(0.0);\n vec4 dst = vec4(0.0);\n float fragmentDepth;\n\n vec3 posMin = vec3(0.0);\n vec3 posMax = vec3(1.0) - vec3(1.0) / uGridDim;\n\n vec3 unitPos;\n\n vec3 nextPos;\n float nextValue;\n\n vec4 material;\n vec4 overpaint;\n float metalness = uMetalness;\n float roughness = uRoughness;\n\n vec3 gradient = vec3(1.0);\n vec3 dx = vec3(gradOffset * scaleVol.x, 0.0, 0.0);\n vec3 dy = vec3(0.0, gradOffset * scaleVol.y, 0.0);\n vec3 dz = vec3(0.0, 0.0, gradOffset * scaleVol.z);\n\n float maxDist = min(vBoundingSphere.w * 2.0, uFar - uNear);\n float maxDistSq = maxDist * maxDist;\n\n for (int i = 0; i < uMaxSteps; ++i) {\n // break when beyond bounding-sphere or far-plane\n vec3 distVec = startLoc - pos;\n if (dot(distVec, distVec) > maxDistSq) break;\n\n unitPos = v3m4(pos, cartnToUnit);\n\n // continue when outside of grid\n if (unitPos.x > posMax.x || unitPos.y > posMax.y || unitPos.z > posMax.z ||\n unitPos.x < posMin.x || unitPos.y < posMin.y || unitPos.z < posMin.z\n ) {\n prevValue = value;\n pos += step;\n continue;\n }\n\n cell = textureVal(unitPos);\n value = cell.a; // current voxel value\n\n if (uJumpLength > 0.0 && value < 0.01) {\n nextPos = pos + rayDir * uJumpLength;\n nextValue = textureVal(v3m4(nextPos, cartnToUnit)).a;\n if (nextValue < 0.01) {\n prevValue = nextValue;\n pos = nextPos;\n continue;\n }\n }\n\n vec4 mvPosition = modelViewTransform * vec4(unitPos * uGridDim, 1.0);\n if (calcDepth(mvPosition.xyz) > getDepth(gl_FragCoord.xy / uDrawingBufferSize))\n break;\n\n #if defined(dClipVariant_pixel) && dClipObjectCount != 0\n vec3 vModelPosition = v3m4(unitPos * uGridDim, modelTransform);\n if (clipTest(vec4(vModelPosition, 0.0), 0)) {\n prevValue = value;\n pos += step;\n continue;\n }\n #endif\n\n vec3 vViewPosition = mvPosition.xyz;\n material.a = transferFunction(value);\n\n #ifdef dPackedGroup\n float group = unpackRGBToInt(textureGroup(floor(unitPos * uGridDim + 0.5) / uGridDim).rgb);\n #else\n vec3 g = floor(unitPos * uGridDim + 0.5);\n // note that we swap x and z because the texture is flipped around y\n #if defined(dAxisOrder_012)\n float group = g.z + g.y * uGridDim.z + g.x * uGridDim.z * uGridDim.y; // 210\n #elif defined(dAxisOrder_021)\n float group = g.y + g.z * uGridDim.y + g.x * uGridDim.y * uGridDim.z; // 120\n #elif defined(dAxisOrder_102)\n float group = g.z + g.x * uGridDim.z + g.y * uGridDim.z * uGridDim.x; // 201\n #elif defined(dAxisOrder_120)\n float group = g.x + g.z * uGridDim.x + g.y * uGridDim.x * uGridDim.z; // 021\n #elif defined(dAxisOrder_201)\n float group = g.y + g.x * uGridDim.y + g.z * uGridDim.y * uGridDim.x; // 102\n #elif defined(dAxisOrder_210)\n float group = g.x + g.y * uGridDim.x + g.z * uGridDim.x * uGridDim.y; // 012\n #endif\n #endif\n\n #if defined(dColorType_direct) && defined(dUsePalette)\n material.rgb = texture2D(tPalette, vec2(value, 0.0)).rgb;\n #elif defined(dColorType_uniform)\n material.rgb = uColor;\n #elif defined(dColorType_instance)\n material.rgb = readFromTexture(tColor, vInstance, uColorTexDim).rgb;\n #elif defined(dColorType_group)\n material.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;\n #elif defined(dColorType_groupInstance)\n material.rgb = readFromTexture(tColor, vInstance * float(uGroupCount) + group, uColorTexDim).rgb;\n #elif defined(dColorType_vertex)\n material.rgb = texture3dFrom1dTrilinear(tColor, isoPos, uGridDim, uColorTexDim, 0.0).rgb;\n #elif defined(dColorType_vertexInstance)\n material.rgb = texture3dFrom1dTrilinear(tColor, isoPos, uGridDim, uColorTexDim, vInstance * float(uVertexCount)).rgb;\n #endif\n\n #ifdef dOverpaint\n #if defined(dOverpaintType_groupInstance)\n overpaint = readFromTexture(tOverpaint, vInstance * float(uGroupCount) + group, uOverpaintTexDim);\n #elif defined(dOverpaintType_vertexInstance)\n overpaint = texture3dFrom1dTrilinear(tOverpaint, isoPos, uGridDim, uOverpaintTexDim, vInstance * float(uVertexCount));\n #endif\n\n material.rgb = mix(material.rgb, overpaint.rgb, overpaint.a);\n #endif\n\n #ifdef dIgnoreLight\n gl_FragColor.rgb = material.rgb;\n #else\n if (material.a >= 0.01) {\n #ifdef dPackedGroup\n // compute gradient by central differences\n gradient.x = textureVal(unitPos - dx).a - textureVal(unitPos + dx).a;\n gradient.y = textureVal(unitPos - dy).a - textureVal(unitPos + dy).a;\n gradient.z = textureVal(unitPos - dz).a - textureVal(unitPos + dz).a;\n #else\n gradient = cell.xyz * 2.0 - 1.0;\n #endif\n vec3 normal = -normalize(normalMatrix * normalize(gradient));\n #include apply_light_color\n } else {\n gl_FragColor.rgb = material.rgb;\n }\n #endif\n\n gl_FragColor.a = material.a * uAlpha * uTransferScale;\n\n float marker = uMarker;\n if (uMarker == -1.0) {\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n #include apply_marker_color\n\n preFogAlphaBlended = (1.0 - preFogAlphaBlended) * gl_FragColor.a + preFogAlphaBlended;\n fragmentDepth = calcDepth(mvPosition.xyz);\n #include apply_fog\n\n src = gl_FragColor;\n\n if (!uTransparentBackground) {\n // done in 'apply_fog' otherwise\n src.rgb *= src.a;\n }\n dst = (1.0 - dst.a) * src + dst; // standard blending\n\n // break if the color is opaque enough\n if (dst.a > 0.95)\n break;\n\n pos += step;\n }\n\n return dst;\n}\n\n// TODO: support float texture for higher precision values???\n// TODO: support clipping exclusion texture support\n\nvoid main() {\n if (gl_FrontFacing)\n discard;\n\n vec3 rayDir = mix(normalize(vOrigPos - uCameraPosition), uCameraDir, uIsOrtho);\n vec3 step = rayDir * uStepScale;\n\n float boundingSphereNear = distance(vBoundingSphere.xyz, uCameraPosition) - vBoundingSphere.w;\n float d = max(uNear, boundingSphereNear) - mix(0.0, distance(vOrigPos, uCameraPosition), uIsOrtho);\n vec3 start = mix(uCameraPosition, vOrigPos, uIsOrtho) + (d * rayDir);\n gl_FragColor = raymarch(start, step, rayDir);\n\n float fragmentDepth = calcDepth((uModelView * vec4(start, 1.0)).xyz);\n float preFogAlpha = clamp(preFogAlphaBlended, 0.0, 1.0);\n bool interior = false;\n #include wboit_write\n}\n";
|
|
11
11
|
//# sourceMappingURL=direct-volume.frag.js.map
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
5
5
|
* @author Michael Krone <michael.krone@uni-tuebingen.de>
|
|
6
6
|
*/
|
|
7
|
-
export declare const gaussianDensity_frag = "\nprecision highp float;\n\nvarying vec3 vPosition;\nvarying float vRadiusSqInv;\n#if defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n precision highp sampler2D;\n uniform sampler2D tMinDistanceTex;\n uniform vec3 uGridTexDim;\n #elif defined(dGridTexType_3d)\n precision highp sampler3D;\n uniform sampler3D tMinDistanceTex;\n #endif\n varying float vGroup;\n#endif\n\n#include common\n\nuniform vec3 uGridDim;\nuniform vec2 uGridTexScale;\nuniform float uCurrentSlice;\nuniform float uCurrentX;\nuniform float uCurrentY;\nuniform float uAlpha;\nuniform float uResolution;\nuniform float uRadiusFactorInv;\n\nvoid main() {\n vec2 v = gl_FragCoord.xy - vec2(uCurrentX, uCurrentY) - 0.5;\n vec3 fragPos = vec3(v.x, v.y, uCurrentSlice);\n float dist = distance(fragPos, vPosition) * uResolution;\n\n #if defined(dCalcType_density)\n float density = exp(-uAlpha * ((dist * dist) * vRadiusSqInv));\n gl_FragColor.a = density * uRadiusFactorInv;\n #elif defined(dCalcType_minDistance)\n gl_FragColor.a = 1.0 - dist * uRadiusFactorInv;\n #elif defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n float minDistance = 1.0 - texture2D(tMinDistanceTex, (gl_FragCoord.xy) / (uGridTexDim.xy / uGridTexScale)).a;\n #elif defined(dGridTexType_3d)\n float minDistance = 1.0 - texelFetch(tMinDistanceTex, ivec3(gl_FragCoord.xy, uCurrentSlice), 0).a;\n #endif\n if (dist * uRadiusFactorInv > minDistance + uResolution * 0.05)\n discard;\n gl_FragColor.rgb =
|
|
7
|
+
export declare const gaussianDensity_frag = "\nprecision highp float;\n\nvarying vec3 vPosition;\nvarying float vRadiusSqInv;\n#if defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n precision highp sampler2D;\n uniform sampler2D tMinDistanceTex;\n uniform vec3 uGridTexDim;\n #elif defined(dGridTexType_3d)\n precision highp sampler3D;\n uniform sampler3D tMinDistanceTex;\n #endif\n varying float vGroup;\n#endif\n\n#include common\n\nuniform vec3 uGridDim;\nuniform vec2 uGridTexScale;\nuniform float uCurrentSlice;\nuniform float uCurrentX;\nuniform float uCurrentY;\nuniform float uAlpha;\nuniform float uResolution;\nuniform float uRadiusFactorInv;\n\nvoid main() {\n vec2 v = gl_FragCoord.xy - vec2(uCurrentX, uCurrentY) - 0.5;\n vec3 fragPos = vec3(v.x, v.y, uCurrentSlice);\n float dist = distance(fragPos, vPosition) * uResolution;\n\n #if defined(dCalcType_density)\n float density = exp(-uAlpha * ((dist * dist) * vRadiusSqInv));\n gl_FragColor.a = density * uRadiusFactorInv;\n #elif defined(dCalcType_minDistance)\n gl_FragColor.a = 1.0 - dist * uRadiusFactorInv;\n #elif defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n float minDistance = 1.0 - texture2D(tMinDistanceTex, (gl_FragCoord.xy) / (uGridTexDim.xy / uGridTexScale)).a;\n #elif defined(dGridTexType_3d)\n float minDistance = 1.0 - texelFetch(tMinDistanceTex, ivec3(gl_FragCoord.xy, uCurrentSlice), 0).a;\n #endif\n if (dist * uRadiusFactorInv > minDistance + uResolution * 0.05)\n discard;\n gl_FragColor.rgb = packIntToRGB(vGroup);\n #endif\n}\n";
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.gaussianDensity_frag = void 0;
|
|
10
|
-
exports.gaussianDensity_frag = "\nprecision highp float;\n\nvarying vec3 vPosition;\nvarying float vRadiusSqInv;\n#if defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n precision highp sampler2D;\n uniform sampler2D tMinDistanceTex;\n uniform vec3 uGridTexDim;\n #elif defined(dGridTexType_3d)\n precision highp sampler3D;\n uniform sampler3D tMinDistanceTex;\n #endif\n varying float vGroup;\n#endif\n\n#include common\n\nuniform vec3 uGridDim;\nuniform vec2 uGridTexScale;\nuniform float uCurrentSlice;\nuniform float uCurrentX;\nuniform float uCurrentY;\nuniform float uAlpha;\nuniform float uResolution;\nuniform float uRadiusFactorInv;\n\nvoid main() {\n vec2 v = gl_FragCoord.xy - vec2(uCurrentX, uCurrentY) - 0.5;\n vec3 fragPos = vec3(v.x, v.y, uCurrentSlice);\n float dist = distance(fragPos, vPosition) * uResolution;\n\n #if defined(dCalcType_density)\n float density = exp(-uAlpha * ((dist * dist) * vRadiusSqInv));\n gl_FragColor.a = density * uRadiusFactorInv;\n #elif defined(dCalcType_minDistance)\n gl_FragColor.a = 1.0 - dist * uRadiusFactorInv;\n #elif defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n float minDistance = 1.0 - texture2D(tMinDistanceTex, (gl_FragCoord.xy) / (uGridTexDim.xy / uGridTexScale)).a;\n #elif defined(dGridTexType_3d)\n float minDistance = 1.0 - texelFetch(tMinDistanceTex, ivec3(gl_FragCoord.xy, uCurrentSlice), 0).a;\n #endif\n if (dist * uRadiusFactorInv > minDistance + uResolution * 0.05)\n discard;\n gl_FragColor.rgb =
|
|
10
|
+
exports.gaussianDensity_frag = "\nprecision highp float;\n\nvarying vec3 vPosition;\nvarying float vRadiusSqInv;\n#if defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n precision highp sampler2D;\n uniform sampler2D tMinDistanceTex;\n uniform vec3 uGridTexDim;\n #elif defined(dGridTexType_3d)\n precision highp sampler3D;\n uniform sampler3D tMinDistanceTex;\n #endif\n varying float vGroup;\n#endif\n\n#include common\n\nuniform vec3 uGridDim;\nuniform vec2 uGridTexScale;\nuniform float uCurrentSlice;\nuniform float uCurrentX;\nuniform float uCurrentY;\nuniform float uAlpha;\nuniform float uResolution;\nuniform float uRadiusFactorInv;\n\nvoid main() {\n vec2 v = gl_FragCoord.xy - vec2(uCurrentX, uCurrentY) - 0.5;\n vec3 fragPos = vec3(v.x, v.y, uCurrentSlice);\n float dist = distance(fragPos, vPosition) * uResolution;\n\n #if defined(dCalcType_density)\n float density = exp(-uAlpha * ((dist * dist) * vRadiusSqInv));\n gl_FragColor.a = density * uRadiusFactorInv;\n #elif defined(dCalcType_minDistance)\n gl_FragColor.a = 1.0 - dist * uRadiusFactorInv;\n #elif defined(dCalcType_groupId)\n #if defined(dGridTexType_2d)\n float minDistance = 1.0 - texture2D(tMinDistanceTex, (gl_FragCoord.xy) / (uGridTexDim.xy / uGridTexScale)).a;\n #elif defined(dGridTexType_3d)\n float minDistance = 1.0 - texelFetch(tMinDistanceTex, ivec3(gl_FragCoord.xy, uCurrentSlice), 0).a;\n #endif\n if (dist * uRadiusFactorInv > minDistance + uResolution * 0.05)\n discard;\n gl_FragColor.rgb = packIntToRGB(vGroup);\n #endif\n}\n";
|
|
11
11
|
//# sourceMappingURL=gaussian-density.frag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const reduction_frag = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tInputLevel;\n\n// previous level used to evaluate the new level\n#if __VERSION__ == 100\n uniform sampler2D tPreviousLevel;\n#else\n precision highp isampler2D;\n uniform isampler2D tPreviousLevel;\n#endif\n\n// inverted size of the previous level texture.\nuniform float uSize;\nuniform float uTexSize;\nuniform bool uFirst;\n\n#include common\n\nvoid main(void) {\n float k = 0.5 * uSize;\n vec2 position = floor((gl_FragCoord.xy / uTexSize) / uSize) * uSize;\n\n #if __VERSION__ == 100\n float a, b, c, d;\n\n if (uFirst) {\n a = texture2D(tInputLevel, position).r * 255.0;\n b = texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0;\n c = texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0;\n d = texture2D(tInputLevel, position + vec2(k, k)).r * 255.0;\n } else {\n a =
|
|
1
|
+
export declare const reduction_frag = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tInputLevel;\n\n// previous level used to evaluate the new level\n#if __VERSION__ == 100\n uniform sampler2D tPreviousLevel;\n#else\n precision highp isampler2D;\n uniform isampler2D tPreviousLevel;\n#endif\n\n// inverted size of the previous level texture.\nuniform float uSize;\nuniform float uTexSize;\nuniform bool uFirst;\n\n#include common\n\nvoid main(void) {\n float k = 0.5 * uSize;\n vec2 position = floor((gl_FragCoord.xy / uTexSize) / uSize) * uSize;\n\n #if __VERSION__ == 100\n float a, b, c, d;\n\n if (uFirst) {\n a = texture2D(tInputLevel, position).r * 255.0;\n b = texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0;\n c = texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0;\n d = texture2D(tInputLevel, position + vec2(k, k)).r * 255.0;\n } else {\n a = unpackRGBToInt(texture2D(tPreviousLevel, position).rgb);\n b = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, 0.0)).rgb);\n c = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(0.0, k)).rgb);\n d = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, k)).rgb);\n }\n gl_FragColor = vec4(packIntToRGB(a + b + c + d), 1.0);\n #else\n int a, b, c, d;\n\n if (uFirst) {\n a = int(texture2D(tInputLevel, position).r * 255.0);\n b = int(texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0);\n c = int(texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0);\n d = int(texture2D(tInputLevel, position + vec2(k, k)).r * 255.0);\n } else {\n a = texture2D(tPreviousLevel, position).r;\n b = texture2D(tPreviousLevel, position + vec2(k, 0.0)).r;\n c = texture2D(tPreviousLevel, position + vec2(0.0, k)).r;\n d = texture2D(tPreviousLevel, position + vec2(k, k)).r;\n }\n gl_FragColor = ivec4(a + b + c + d);\n #endif\n}\n";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reduction_frag = void 0;
|
|
4
|
-
exports.reduction_frag = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tInputLevel;\n\n// previous level used to evaluate the new level\n#if __VERSION__ == 100\n uniform sampler2D tPreviousLevel;\n#else\n precision highp isampler2D;\n uniform isampler2D tPreviousLevel;\n#endif\n\n// inverted size of the previous level texture.\nuniform float uSize;\nuniform float uTexSize;\nuniform bool uFirst;\n\n#include common\n\nvoid main(void) {\n float k = 0.5 * uSize;\n vec2 position = floor((gl_FragCoord.xy / uTexSize) / uSize) * uSize;\n\n #if __VERSION__ == 100\n float a, b, c, d;\n\n if (uFirst) {\n a = texture2D(tInputLevel, position).r * 255.0;\n b = texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0;\n c = texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0;\n d = texture2D(tInputLevel, position + vec2(k, k)).r * 255.0;\n } else {\n a =
|
|
4
|
+
exports.reduction_frag = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nuniform sampler2D tInputLevel;\n\n// previous level used to evaluate the new level\n#if __VERSION__ == 100\n uniform sampler2D tPreviousLevel;\n#else\n precision highp isampler2D;\n uniform isampler2D tPreviousLevel;\n#endif\n\n// inverted size of the previous level texture.\nuniform float uSize;\nuniform float uTexSize;\nuniform bool uFirst;\n\n#include common\n\nvoid main(void) {\n float k = 0.5 * uSize;\n vec2 position = floor((gl_FragCoord.xy / uTexSize) / uSize) * uSize;\n\n #if __VERSION__ == 100\n float a, b, c, d;\n\n if (uFirst) {\n a = texture2D(tInputLevel, position).r * 255.0;\n b = texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0;\n c = texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0;\n d = texture2D(tInputLevel, position + vec2(k, k)).r * 255.0;\n } else {\n a = unpackRGBToInt(texture2D(tPreviousLevel, position).rgb);\n b = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, 0.0)).rgb);\n c = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(0.0, k)).rgb);\n d = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, k)).rgb);\n }\n gl_FragColor = vec4(packIntToRGB(a + b + c + d), 1.0);\n #else\n int a, b, c, d;\n\n if (uFirst) {\n a = int(texture2D(tInputLevel, position).r * 255.0);\n b = int(texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0);\n c = int(texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0);\n d = int(texture2D(tInputLevel, position + vec2(k, k)).r * 255.0);\n } else {\n a = texture2D(tPreviousLevel, position).r;\n b = texture2D(tPreviousLevel, position + vec2(k, 0.0)).r;\n c = texture2D(tPreviousLevel, position + vec2(0.0, k)).r;\n d = texture2D(tPreviousLevel, position + vec2(k, k)).r;\n }\n gl_FragColor = ivec4(a + b + c + d);\n #endif\n}\n";
|
|
5
5
|
//# sourceMappingURL=reduction.frag.js.map
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
5
5
|
*/
|
|
6
|
-
export declare const image_frag = "\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_frag_params\n#include common_clip\n\nuniform vec2 uImageTexDim;\nuniform sampler2D tImageTex;\nuniform sampler2D tGroupTex;\n\nuniform vec2 uMarkerTexDim;\nuniform sampler2D tMarker;\n\nvarying vec2 vUv;\nvarying float vInstance;\n\n#if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell) || defined(dInterpolation_bspline)\n #define dInterpolation_cubic\n#endif\n\n#if defined(dInterpolation_cubic)\n #if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell)\n #if defined(dInterpolation_catmulrom)\n const float B = 0.0;\n const float C = 0.5;\n #elif defined(dInterpolation_mitchell)\n const float B = 0.333;\n const float C = 0.333;\n #endif\n\n float cubicFilter(float x){\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f < 1.0) {\n return ((12.0 - 9.0 * B - 6.0 * C) * (f * f * f) +\n (-18.0 + 12.0 * B + 6.0 * C) * (f * f) +\n (6.0 - 2.0 * B)) / 6.0;\n }else if (f >= 1.0 && f < 2.0){\n return ((-B - 6.0 * C) * ( f * f * f)\n + (6.0 * B + 30.0 * C) * (f * f) +\n (-(12.0 * B) - 48.0 * C) * f +\n 8.0 * B + 24.0 * C) / 6.0;\n }else{\n return 0.0;\n }\n }\n #elif defined(dInterpolation_bspline)\n float cubicFilter(float x) {\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f >= 0.0 && f <= 1.0){\n return (2.0 / 3.0) + (0.5) * (f * f * f) - (f * f);\n } else if (f > 1.0 && f <= 2.0) {\n return 1.0 / 6.0 * pow((2.0 - f), 3.0);\n }\n return 1.0;\n }\n #endif\n\n vec4 biCubic(sampler2D tex, vec2 texCoord) {\n vec2 texelSize = 1.0 / uImageTexDim;\n texCoord -= texelSize / 2.0;\n vec4 nSum = vec4(0.0);\n float nDenom = 0.0;\n vec2 cell = fract(texCoord * uImageTexDim);\n for (float m = -1.0; m <= 2.0; ++m) {\n for (float n = -1.0; n <= 2.0; ++n) {\n vec4 vecData = texture2D(tex, texCoord + texelSize * vec2(m, n));\n float c = cubicFilter(m - cell.x) * cubicFilter(-n + cell.y);\n nSum += vecData * c;\n nDenom += c;\n }\n }\n return nSum / nDenom;\n }\n#endif\n\nvoid main() {\n #include clip_pixel\n\n #if defined(dInterpolation_cubic)\n vec4 imageData = biCubic(tImageTex, vUv);\n #else\n vec4 imageData = texture2D(tImageTex, vUv);\n #endif\n imageData.a = clamp(imageData.a, 0.0, 1.0);\n if (imageData.a > 0.9) imageData.a = 1.0;\n\n float fragmentDepth = gl_FragCoord.z;\n bool interior = false;\n\n #if defined(dRenderVariant_pick)\n if (imageData.a < 0.3)\n discard;\n if (uPickType == 1) {\n gl_FragColor = vec4(
|
|
6
|
+
export declare const image_frag = "\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_frag_params\n#include common_clip\n\nuniform vec2 uImageTexDim;\nuniform sampler2D tImageTex;\nuniform sampler2D tGroupTex;\n\nuniform vec2 uMarkerTexDim;\nuniform sampler2D tMarker;\n\nvarying vec2 vUv;\nvarying float vInstance;\n\n#if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell) || defined(dInterpolation_bspline)\n #define dInterpolation_cubic\n#endif\n\n#if defined(dInterpolation_cubic)\n #if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell)\n #if defined(dInterpolation_catmulrom)\n const float B = 0.0;\n const float C = 0.5;\n #elif defined(dInterpolation_mitchell)\n const float B = 0.333;\n const float C = 0.333;\n #endif\n\n float cubicFilter(float x){\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f < 1.0) {\n return ((12.0 - 9.0 * B - 6.0 * C) * (f * f * f) +\n (-18.0 + 12.0 * B + 6.0 * C) * (f * f) +\n (6.0 - 2.0 * B)) / 6.0;\n }else if (f >= 1.0 && f < 2.0){\n return ((-B - 6.0 * C) * ( f * f * f)\n + (6.0 * B + 30.0 * C) * (f * f) +\n (-(12.0 * B) - 48.0 * C) * f +\n 8.0 * B + 24.0 * C) / 6.0;\n }else{\n return 0.0;\n }\n }\n #elif defined(dInterpolation_bspline)\n float cubicFilter(float x) {\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f >= 0.0 && f <= 1.0){\n return (2.0 / 3.0) + (0.5) * (f * f * f) - (f * f);\n } else if (f > 1.0 && f <= 2.0) {\n return 1.0 / 6.0 * pow((2.0 - f), 3.0);\n }\n return 1.0;\n }\n #endif\n\n vec4 biCubic(sampler2D tex, vec2 texCoord) {\n vec2 texelSize = 1.0 / uImageTexDim;\n texCoord -= texelSize / 2.0;\n vec4 nSum = vec4(0.0);\n float nDenom = 0.0;\n vec2 cell = fract(texCoord * uImageTexDim);\n for (float m = -1.0; m <= 2.0; ++m) {\n for (float n = -1.0; n <= 2.0; ++n) {\n vec4 vecData = texture2D(tex, texCoord + texelSize * vec2(m, n));\n float c = cubicFilter(m - cell.x) * cubicFilter(-n + cell.y);\n nSum += vecData * c;\n nDenom += c;\n }\n }\n return nSum / nDenom;\n }\n#endif\n\nvoid main() {\n #include clip_pixel\n\n #if defined(dInterpolation_cubic)\n vec4 imageData = biCubic(tImageTex, vUv);\n #else\n vec4 imageData = texture2D(tImageTex, vUv);\n #endif\n imageData.a = clamp(imageData.a, 0.0, 1.0);\n if (imageData.a > 0.9) imageData.a = 1.0;\n\n float fragmentDepth = gl_FragCoord.z;\n bool interior = false;\n\n #if defined(dRenderVariant_pick)\n if (imageData.a < 0.3)\n discard;\n if (uPickType == 1) {\n gl_FragColor = vec4(packIntToRGB(float(uObjectId)), 1.0);\n } else if (uPickType == 2) {\n gl_FragColor = vec4(packIntToRGB(vInstance), 1.0);\n } else {\n gl_FragColor = vec4(texture2D(tGroupTex, vUv).rgb, 1.0);\n }\n #elif defined(dRenderVariant_depth)\n if (imageData.a < 0.05)\n discard;\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n #elif defined(dRenderVariant_marking)\n float marker = uMarker;\n if (uMarker == -1.0) {\n float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n if (uMarkingType == 1) {\n if (marker > 0.0 || imageData.a < 0.05)\n discard;\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n } else {\n if (marker == 0.0 || imageData.a < 0.05)\n discard;\n float depthTest = 1.0;\n if (uMarkingDepthTest) {\n depthTest = (fragmentDepth >= getDepth(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;\n }\n bool isHighlight = intMod(marker, 2.0) > 0.1;\n gl_FragColor = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0);\n }\n #elif defined(dRenderVariant_color)\n if (imageData.a < 0.05)\n discard;\n gl_FragColor = imageData;\n gl_FragColor.a *= uAlpha;\n\n float marker = uMarker;\n if (uMarker == -1.0) {\n float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #endif\n}\n";
|
|
@@ -6,5 +6,5 @@ exports.image_frag = void 0;
|
|
|
6
6
|
*
|
|
7
7
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
8
8
|
*/
|
|
9
|
-
exports.image_frag = "\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_frag_params\n#include common_clip\n\nuniform vec2 uImageTexDim;\nuniform sampler2D tImageTex;\nuniform sampler2D tGroupTex;\n\nuniform vec2 uMarkerTexDim;\nuniform sampler2D tMarker;\n\nvarying vec2 vUv;\nvarying float vInstance;\n\n#if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell) || defined(dInterpolation_bspline)\n #define dInterpolation_cubic\n#endif\n\n#if defined(dInterpolation_cubic)\n #if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell)\n #if defined(dInterpolation_catmulrom)\n const float B = 0.0;\n const float C = 0.5;\n #elif defined(dInterpolation_mitchell)\n const float B = 0.333;\n const float C = 0.333;\n #endif\n\n float cubicFilter(float x){\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f < 1.0) {\n return ((12.0 - 9.0 * B - 6.0 * C) * (f * f * f) +\n (-18.0 + 12.0 * B + 6.0 * C) * (f * f) +\n (6.0 - 2.0 * B)) / 6.0;\n }else if (f >= 1.0 && f < 2.0){\n return ((-B - 6.0 * C) * ( f * f * f)\n + (6.0 * B + 30.0 * C) * (f * f) +\n (-(12.0 * B) - 48.0 * C) * f +\n 8.0 * B + 24.0 * C) / 6.0;\n }else{\n return 0.0;\n }\n }\n #elif defined(dInterpolation_bspline)\n float cubicFilter(float x) {\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f >= 0.0 && f <= 1.0){\n return (2.0 / 3.0) + (0.5) * (f * f * f) - (f * f);\n } else if (f > 1.0 && f <= 2.0) {\n return 1.0 / 6.0 * pow((2.0 - f), 3.0);\n }\n return 1.0;\n }\n #endif\n\n vec4 biCubic(sampler2D tex, vec2 texCoord) {\n vec2 texelSize = 1.0 / uImageTexDim;\n texCoord -= texelSize / 2.0;\n vec4 nSum = vec4(0.0);\n float nDenom = 0.0;\n vec2 cell = fract(texCoord * uImageTexDim);\n for (float m = -1.0; m <= 2.0; ++m) {\n for (float n = -1.0; n <= 2.0; ++n) {\n vec4 vecData = texture2D(tex, texCoord + texelSize * vec2(m, n));\n float c = cubicFilter(m - cell.x) * cubicFilter(-n + cell.y);\n nSum += vecData * c;\n nDenom += c;\n }\n }\n return nSum / nDenom;\n }\n#endif\n\nvoid main() {\n #include clip_pixel\n\n #if defined(dInterpolation_cubic)\n vec4 imageData = biCubic(tImageTex, vUv);\n #else\n vec4 imageData = texture2D(tImageTex, vUv);\n #endif\n imageData.a = clamp(imageData.a, 0.0, 1.0);\n if (imageData.a > 0.9) imageData.a = 1.0;\n\n float fragmentDepth = gl_FragCoord.z;\n bool interior = false;\n\n #if defined(dRenderVariant_pick)\n if (imageData.a < 0.3)\n discard;\n if (uPickType == 1) {\n gl_FragColor = vec4(
|
|
9
|
+
exports.image_frag = "\nprecision highp float;\nprecision highp int;\n\n#include common\n#include read_from_texture\n#include common_frag_params\n#include common_clip\n\nuniform vec2 uImageTexDim;\nuniform sampler2D tImageTex;\nuniform sampler2D tGroupTex;\n\nuniform vec2 uMarkerTexDim;\nuniform sampler2D tMarker;\n\nvarying vec2 vUv;\nvarying float vInstance;\n\n#if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell) || defined(dInterpolation_bspline)\n #define dInterpolation_cubic\n#endif\n\n#if defined(dInterpolation_cubic)\n #if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell)\n #if defined(dInterpolation_catmulrom)\n const float B = 0.0;\n const float C = 0.5;\n #elif defined(dInterpolation_mitchell)\n const float B = 0.333;\n const float C = 0.333;\n #endif\n\n float cubicFilter(float x){\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f < 1.0) {\n return ((12.0 - 9.0 * B - 6.0 * C) * (f * f * f) +\n (-18.0 + 12.0 * B + 6.0 * C) * (f * f) +\n (6.0 - 2.0 * B)) / 6.0;\n }else if (f >= 1.0 && f < 2.0){\n return ((-B - 6.0 * C) * ( f * f * f)\n + (6.0 * B + 30.0 * C) * (f * f) +\n (-(12.0 * B) - 48.0 * C) * f +\n 8.0 * B + 24.0 * C) / 6.0;\n }else{\n return 0.0;\n }\n }\n #elif defined(dInterpolation_bspline)\n float cubicFilter(float x) {\n float f = x;\n if (f < 0.0) {\n f = -f;\n }\n if (f >= 0.0 && f <= 1.0){\n return (2.0 / 3.0) + (0.5) * (f * f * f) - (f * f);\n } else if (f > 1.0 && f <= 2.0) {\n return 1.0 / 6.0 * pow((2.0 - f), 3.0);\n }\n return 1.0;\n }\n #endif\n\n vec4 biCubic(sampler2D tex, vec2 texCoord) {\n vec2 texelSize = 1.0 / uImageTexDim;\n texCoord -= texelSize / 2.0;\n vec4 nSum = vec4(0.0);\n float nDenom = 0.0;\n vec2 cell = fract(texCoord * uImageTexDim);\n for (float m = -1.0; m <= 2.0; ++m) {\n for (float n = -1.0; n <= 2.0; ++n) {\n vec4 vecData = texture2D(tex, texCoord + texelSize * vec2(m, n));\n float c = cubicFilter(m - cell.x) * cubicFilter(-n + cell.y);\n nSum += vecData * c;\n nDenom += c;\n }\n }\n return nSum / nDenom;\n }\n#endif\n\nvoid main() {\n #include clip_pixel\n\n #if defined(dInterpolation_cubic)\n vec4 imageData = biCubic(tImageTex, vUv);\n #else\n vec4 imageData = texture2D(tImageTex, vUv);\n #endif\n imageData.a = clamp(imageData.a, 0.0, 1.0);\n if (imageData.a > 0.9) imageData.a = 1.0;\n\n float fragmentDepth = gl_FragCoord.z;\n bool interior = false;\n\n #if defined(dRenderVariant_pick)\n if (imageData.a < 0.3)\n discard;\n if (uPickType == 1) {\n gl_FragColor = vec4(packIntToRGB(float(uObjectId)), 1.0);\n } else if (uPickType == 2) {\n gl_FragColor = vec4(packIntToRGB(vInstance), 1.0);\n } else {\n gl_FragColor = vec4(texture2D(tGroupTex, vUv).rgb, 1.0);\n }\n #elif defined(dRenderVariant_depth)\n if (imageData.a < 0.05)\n discard;\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n #elif defined(dRenderVariant_marking)\n float marker = uMarker;\n if (uMarker == -1.0) {\n float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n if (uMarkingType == 1) {\n if (marker > 0.0 || imageData.a < 0.05)\n discard;\n gl_FragColor = packDepthToRGBA(gl_FragCoord.z);\n } else {\n if (marker == 0.0 || imageData.a < 0.05)\n discard;\n float depthTest = 1.0;\n if (uMarkingDepthTest) {\n depthTest = (fragmentDepth >= getDepth(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;\n }\n bool isHighlight = intMod(marker, 2.0) > 0.1;\n gl_FragColor = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0);\n }\n #elif defined(dRenderVariant_color)\n if (imageData.a < 0.05)\n discard;\n gl_FragColor = imageData;\n gl_FragColor.a *= uAlpha;\n\n float marker = uMarker;\n if (uMarker == -1.0) {\n float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);\n marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;\n marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n\n #include apply_marker_color\n #include apply_fog\n #include wboit_write\n #endif\n}\n";
|
|
10
10
|
//# sourceMappingURL=image.frag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isosurface_frag = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#if __VERSION__ == 100\n uniform sampler2D tActiveVoxelsPyramid;\n#else\n precision highp isampler2D;\n uniform isampler2D tActiveVoxelsPyramid;\n#endif\n\nuniform sampler2D tActiveVoxelsBase;\nuniform sampler2D tVolumeData;\nuniform sampler2D tTriIndices;\n\nuniform float uIsoValue;\nuniform float uLevels;\nuniform float uSize;\nuniform float uCount;\nuniform bool uInvert;\n\nuniform vec3 uGridDim;\nuniform vec3 uGridTexDim;\nuniform mat4 uGridTransform;\n\n// scale to volume data coord\nuniform vec2 uScale;\n\n#include common\n\n// cube corners (excluding origin)\nconst vec3 c1 = vec3(1., 0., 0.);\nconst vec3 c2 = vec3(1., 1., 0.);\nconst vec3 c3 = vec3(0., 1., 0.);\nconst vec3 c4 = vec3(0., 0., 1.);\nconst vec3 c5 = vec3(1., 0., 1.);\nconst vec3 c6 = vec3(1., 1., 1.);\nconst vec3 c7 = vec3(0., 1., 1.);\n\nvec3 index3dFrom2d(vec2 coord) {\n vec2 gridTexPos = coord * uGridTexDim.xy;\n vec2 columnRow = ivec2Div(gridTexPos, uGridDim.xy);\n vec2 posXY = gridTexPos - columnRow * uGridDim.xy;\n float posZ = columnRow.y * intDiv(uGridTexDim.x, uGridDim.x) + columnRow.x;\n return vec3(posXY, posZ);\n}\n\nvec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {\n float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice\n float column = intDiv(intMod(zSlice * gridDim.x, texDim.x), gridDim.x);\n float row = intDiv(zSlice * gridDim.x, texDim.x);\n vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / (texDim / uScale);\n return texture2D(tex, coord + 0.5 / (texDim / uScale));\n}\n\nvec4 voxel(vec3 pos) {\n pos = min(max(vec3(0.0), pos), uGridDim - vec3(1.0));\n return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);\n}\n\nvec4 voxelPadded(vec3 pos) {\n pos = min(max(vec3(0.0), pos), uGridDim - vec3(vec2(2.0), 1.0)); // remove xy padding\n return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);\n}\n\nint idot2(const in ivec2 a, const in ivec2 b) {\n return a.x * b.x + a.y * b.y;\n}\n\nint idot4(const in ivec4 a, const in ivec4 b) {\n return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;\n}\n\n#if __VERSION__ == 100\n int pyramidVoxel(vec2 pos) {\n return int(decodeFloatRGB(texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).rgb));\n }\n#else\n int pyramidVoxel(vec2 pos) {\n return texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).r;\n }\n#endif\n\nvec4 baseVoxel(vec2 pos) {\n return texture2D(tActiveVoxelsBase, pos / uSize);\n}\n\nvoid main(void) {\n // get 1D index\n int vI = int(gl_FragCoord.x) + int(gl_FragCoord.y) * int(uSize);\n\n // ignore 1D indices outside of the grid\n if(vI >= int(uCount)) discard;\n\n ivec2 offset = ivec2(int(uSize) - 2, 0);\n\n int start = 0;\n ivec4 starts = ivec4(0);\n ivec4 ends = ivec4(0);\n int diff = 2;\n ivec4 m = ivec4(0);\n ivec2 position = ivec2(0);\n ivec4 vI4 = ivec4(vI);\n\n ivec2 relativePosition = ivec2(0);\n int end = 0;\n ivec2 pos1 = ivec2(0);\n ivec2 pos2 = ivec2(0);\n ivec2 pos3 = ivec2(0);\n ivec2 pos4 = ivec2(0);\n ivec3 vI3 = ivec3(vI);\n ivec3 mask = ivec3(0);\n\n // traverse the different levels of the pyramid\n for(int i = 1; i < 14; i++) {\n if(float(i) >= uLevels) break;\n\n offset.x -= diff;\n diff *= 2;\n relativePosition = position + offset;\n\n end = start + pyramidVoxel(vec2(relativePosition));\n pos1 = ivec2(relativePosition);\n starts.x = start;\n ends.x = end;\n pos2 = ivec2(relativePosition + ivec2(1, 0));\n starts.y = ends.x;\n ends.y = ends.x + pyramidVoxel(vec2(pos2));\n pos3 = relativePosition + ivec2(0, 1);\n starts.z = ends.y;\n ends.z = ends.y + pyramidVoxel(vec2(pos3));\n pos4 = relativePosition + ivec2(1, 1);\n starts.w = ends.z;\n mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));\n m = ivec4(mask, 1 - int(any(bvec3(mask))));\n\n relativePosition = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;\n start = idot4(m, starts);\n position = 2 * (relativePosition - offset);\n }\n\n end = start + int(baseVoxel(vec2(position)).r * 255.0);\n pos1 = position;\n starts.x = start;\n ends.x = end;\n pos2 = position + ivec2(1, 0);\n starts.y = ends.x;\n ends.y = ends.x + int(baseVoxel(vec2(pos2)).r * 255.0);\n pos3 = position + ivec2(0, 1);\n starts.z = ends.y;\n ends.z = ends.y + int(baseVoxel(vec2(pos3)).r * 255.0);\n pos4 = position + ivec2(1, 1);\n starts.w = ends.z;\n mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));\n m = ivec4(mask, 1 - int(any(bvec3(mask))));\n position = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;\n\n vec2 coord2d = (vec2(position) / uSize) / uScale;\n vec3 coord3d = floor(index3dFrom2d(coord2d) + 0.5);\n\n float edgeIndex = floor(baseVoxel(vec2(position)).a * 255.0 + 0.5);\n\n // current vertex for the up to 15 MC cases\n int currentVertex = vI - idot4(m, starts);\n\n // ensure winding-order is the same for negative and positive iso-levels\n if (uInvert) {\n int v = imod(currentVertex + 1, 3);\n if (v == 1) currentVertex += 2;\n else if (v == 0) currentVertex -= 2;\n }\n\n // get index into triIndices table\n int mcIndex = 16 * int(edgeIndex) + currentVertex;\n vec4 mcData = texture2D(tTriIndices, vec2(imod(mcIndex, 64), mcIndex / 64) / 64.);\n\n // bit mask to avoid conditionals (see comment below) for getting MC case corner\n vec4 m0 = vec4(floor(mcData.a * 255.0 + 0.5));\n\n // get edge value masks\n vec4 m1 = vec4(equal(m0, vec4(0., 1., 2., 3.)));\n vec4 m2 = vec4(equal(m0, vec4(4., 5., 6., 7.)));\n vec4 m3 = vec4(equal(m0, vec4(8., 9., 10., 11.)));\n\n // apply bit masks\n vec3 b0 = coord3d +\n m1.y * c1 +\n m1.z * c2 +\n m1.w * c3 +\n m2.x * c4 +\n m2.y * c5 +\n m2.z * c6 +\n m2.w * c7 +\n m3.y * c1 +\n m3.z * c2 +\n m3.w * c3;\n vec3 b1 = coord3d +\n m1.x * c1 +\n m1.y * c2 +\n m1.z * c3 +\n m2.x * c5 +\n m2.y * c6 +\n m2.z * c7 +\n m2.w * c4 +\n m3.x * c4 +\n m3.y * c5 +\n m3.z * c6 +\n m3.w * c7;\n\n // the conditionals that are avoided by above bitmasks\n // vec3 b0 = coord3d;\n // vec3 b1 = coord3d;\n // if (mcIndex == 0.0) {\n // b1 += c1;\n // } else if (mcIndex == 1.0) {\n // b0 += c1; b1 += c2;\n // } else if (mcIndex == 2.0) {\n // b0 += c2; b1 += c3;\n // } else if (mcIndex == 3.0) {\n // b0 += c3;\n // } else if (mcIndex == 4.0) {\n // b0 += c4; b1 += c5;\n // } else if (mcIndex == 5.0) {\n // b0 += c5; b1 += c6;\n // } else if (mcIndex == 6.0) {\n // b0 += c6; b1 += c7;\n // } else if (mcIndex == 7.0) {\n // b0 += c7; b1 += c4;\n // } else if (mcIndex == 8.0) {\n // b1 += c4;\n // } else if (mcIndex == 9.0) {\n // b0 += c1; b1 += c5;\n // } else if (mcIndex == 10.0) {\n // b0 += c2; b1 += c6;\n // } else if (mcIndex == 11.0) {\n // b0 += c3; b1 += c7;\n // }\n // b0 = floor(b0 + 0.5);\n // b1 = floor(b1 + 0.5);\n\n vec4 d0 = voxel(b0);\n vec4 d1 = voxel(b1);\n\n float v0 = d0.a;\n float v1 = d1.a;\n\n float t = (uIsoValue - v0) / (v0 - v1);\n gl_FragData[0].xyz = (uGridTransform * vec4(b0 + t * (b0 - b1), 1.0)).xyz;\n\n // group id\n #if __VERSION__ == 100\n // webgl1 does not support 'flat' interpolation (i.e. no interpolation)\n // so we ensure a constant group id per triangle here\n #ifdef dPackedGroup\n gl_FragData[1] = vec4(voxel(coord3d).rgb, 1.0);\n #else\n vec3 gridDim = uGridDim - vec3(1.0, 1.0, 0.0); // remove xy padding\n float group = coord3d.z + coord3d.y * gridDim.z + coord3d.x * gridDim.z * gridDim.y;\n gl_FragData[1] = vec4(group > 16777215.5 ? vec3(1.0) : encodeFloatRGB(group), 1.0);\n #endif\n #else\n #ifdef dPackedGroup\n gl_FragData[1] = vec4(t < 0.5 ? d0.rgb : d1.rgb, 1.0);\n #else\n vec3 b = t < 0.5 ? b0 : b1;\n vec3 gridDim = uGridDim - vec3(1.0, 1.0, 0.0); // remove xy padding\n float group = b.z + b.y * gridDim.z + b.x * gridDim.z * gridDim.y;\n gl_FragData[1] = vec4(group > 16777215.5 ? vec3(1.0) : encodeFloatRGB(group), 1.0);\n #endif\n #endif\n\n // normals from gradients\n vec3 n0 = -normalize(vec3(\n voxelPadded(b0 - c1).a - voxelPadded(b0 + c1).a,\n voxelPadded(b0 - c3).a - voxelPadded(b0 + c3).a,\n voxelPadded(b0 - c4).a - voxelPadded(b0 + c4).a\n ));\n vec3 n1 = -normalize(vec3(\n voxelPadded(b1 - c1).a - voxelPadded(b1 + c1).a,\n voxelPadded(b1 - c3).a - voxelPadded(b1 + c3).a,\n voxelPadded(b1 - c4).a - voxelPadded(b1 + c4).a\n ));\n gl_FragData[2].xyz = -vec3(\n n0.x + t * (n0.x - n1.x),\n n0.y + t * (n0.y - n1.y),\n n0.z + t * (n0.z - n1.z)\n );\n\n // ensure normal-direction is the same for negative and positive iso-levels\n if (uInvert) {\n gl_FragData[2].xyz *= -1.0;\n }\n\n // apply normal matrix\n gl_FragData[2].xyz *= transpose3(inverse3(mat3(uGridTransform)));\n}\n";
|
|
1
|
+
export declare const isosurface_frag = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#if __VERSION__ == 100\n uniform sampler2D tActiveVoxelsPyramid;\n#else\n precision highp isampler2D;\n uniform isampler2D tActiveVoxelsPyramid;\n#endif\n\nuniform sampler2D tActiveVoxelsBase;\nuniform sampler2D tVolumeData;\nuniform sampler2D tTriIndices;\n\nuniform float uIsoValue;\nuniform float uLevels;\nuniform float uSize;\nuniform float uCount;\nuniform bool uInvert;\n\nuniform vec3 uGridDim;\nuniform vec3 uGridTexDim;\nuniform mat4 uGridTransform;\n\n// scale to volume data coord\nuniform vec2 uScale;\n\n#include common\n\n// cube corners (excluding origin)\nconst vec3 c1 = vec3(1., 0., 0.);\nconst vec3 c2 = vec3(1., 1., 0.);\nconst vec3 c3 = vec3(0., 1., 0.);\nconst vec3 c4 = vec3(0., 0., 1.);\nconst vec3 c5 = vec3(1., 0., 1.);\nconst vec3 c6 = vec3(1., 1., 1.);\nconst vec3 c7 = vec3(0., 1., 1.);\n\nvec3 index3dFrom2d(vec2 coord) {\n vec2 gridTexPos = coord * uGridTexDim.xy;\n vec2 columnRow = ivec2Div(gridTexPos, uGridDim.xy);\n vec2 posXY = gridTexPos - columnRow * uGridDim.xy;\n float posZ = columnRow.y * intDiv(uGridTexDim.x, uGridDim.x) + columnRow.x;\n return vec3(posXY, posZ);\n}\n\nvec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {\n float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice\n float column = intDiv(intMod(zSlice * gridDim.x, texDim.x), gridDim.x);\n float row = intDiv(zSlice * gridDim.x, texDim.x);\n vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / (texDim / uScale);\n return texture2D(tex, coord + 0.5 / (texDim / uScale));\n}\n\nvec4 voxel(vec3 pos) {\n pos = min(max(vec3(0.0), pos), uGridDim - vec3(1.0));\n return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);\n}\n\nvec4 voxelPadded(vec3 pos) {\n pos = min(max(vec3(0.0), pos), uGridDim - vec3(vec2(2.0), 1.0)); // remove xy padding\n return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);\n}\n\nint idot2(const in ivec2 a, const in ivec2 b) {\n return a.x * b.x + a.y * b.y;\n}\n\nint idot4(const in ivec4 a, const in ivec4 b) {\n return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;\n}\n\n#if __VERSION__ == 100\n int pyramidVoxel(vec2 pos) {\n return int(unpackRGBToInt(texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).rgb));\n }\n#else\n int pyramidVoxel(vec2 pos) {\n return texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).r;\n }\n#endif\n\nvec4 baseVoxel(vec2 pos) {\n return texture2D(tActiveVoxelsBase, pos / uSize);\n}\n\nvec4 getGroup(const in vec3 p) {\n vec3 gridDim = uGridDim - vec3(1.0, 1.0, 0.0); // remove xy padding\n // note that we swap x and z because the texture is flipped around y\n #if defined(dAxisOrder_012)\n float group = p.z + p.y * gridDim.z + p.x * gridDim.z * gridDim.y; // 210\n #elif defined(dAxisOrder_021)\n float group = p.y + p.z * gridDim.y + p.x * gridDim.y * gridDim.z; // 120\n #elif defined(dAxisOrder_102)\n float group = p.z + p.x * gridDim.z + p.y * gridDim.z * gridDim.x; // 201\n #elif defined(dAxisOrder_120)\n float group = p.x + p.z * gridDim.x + p.y * gridDim.x * gridDim.z; // 021\n #elif defined(dAxisOrder_201)\n float group = p.y + p.x * gridDim.y + p.z * gridDim.y * gridDim.x; // 102\n #elif defined(dAxisOrder_210)\n float group = p.x + p.y * gridDim.x + p.z * gridDim.x * gridDim.y; // 012\n #endif\n return vec4(group > 16777215.5 ? vec3(1.0) : packIntToRGB(group), 1.0);\n}\n\nvoid main(void) {\n // get 1D index\n int vI = int(gl_FragCoord.x) + int(gl_FragCoord.y) * int(uSize);\n\n // ignore 1D indices outside of the grid\n if(vI >= int(uCount)) discard;\n\n ivec2 offset = ivec2(int(uSize) - 2, 0);\n\n int start = 0;\n ivec4 starts = ivec4(0);\n ivec4 ends = ivec4(0);\n int diff = 2;\n ivec4 m = ivec4(0);\n ivec2 position = ivec2(0);\n ivec4 vI4 = ivec4(vI);\n\n ivec2 relativePosition = ivec2(0);\n int end = 0;\n ivec2 pos1 = ivec2(0);\n ivec2 pos2 = ivec2(0);\n ivec2 pos3 = ivec2(0);\n ivec2 pos4 = ivec2(0);\n ivec3 vI3 = ivec3(vI);\n ivec3 mask = ivec3(0);\n\n // traverse the different levels of the pyramid\n for(int i = 1; i < 14; i++) {\n if(float(i) >= uLevels) break;\n\n offset.x -= diff;\n diff *= 2;\n relativePosition = position + offset;\n\n end = start + pyramidVoxel(vec2(relativePosition));\n pos1 = ivec2(relativePosition);\n starts.x = start;\n ends.x = end;\n pos2 = ivec2(relativePosition + ivec2(1, 0));\n starts.y = ends.x;\n ends.y = ends.x + pyramidVoxel(vec2(pos2));\n pos3 = relativePosition + ivec2(0, 1);\n starts.z = ends.y;\n ends.z = ends.y + pyramidVoxel(vec2(pos3));\n pos4 = relativePosition + ivec2(1, 1);\n starts.w = ends.z;\n mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));\n m = ivec4(mask, 1 - int(any(bvec3(mask))));\n\n relativePosition = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;\n start = idot4(m, starts);\n position = 2 * (relativePosition - offset);\n }\n\n end = start + int(baseVoxel(vec2(position)).r * 255.0);\n pos1 = position;\n starts.x = start;\n ends.x = end;\n pos2 = position + ivec2(1, 0);\n starts.y = ends.x;\n ends.y = ends.x + int(baseVoxel(vec2(pos2)).r * 255.0);\n pos3 = position + ivec2(0, 1);\n starts.z = ends.y;\n ends.z = ends.y + int(baseVoxel(vec2(pos3)).r * 255.0);\n pos4 = position + ivec2(1, 1);\n starts.w = ends.z;\n mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));\n m = ivec4(mask, 1 - int(any(bvec3(mask))));\n position = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;\n\n vec2 coord2d = (vec2(position) / uSize) / uScale;\n vec3 coord3d = floor(index3dFrom2d(coord2d) + 0.5);\n\n float edgeIndex = floor(baseVoxel(vec2(position)).a * 255.0 + 0.5);\n\n // current vertex for the up to 15 MC cases\n int currentVertex = vI - idot4(m, starts);\n\n // ensure winding-order is the same for negative and positive iso-levels\n if (uInvert) {\n int v = imod(currentVertex + 1, 3);\n if (v == 1) currentVertex += 2;\n else if (v == 0) currentVertex -= 2;\n }\n\n // get index into triIndices table\n int mcIndex = 16 * int(edgeIndex) + currentVertex;\n vec4 mcData = texture2D(tTriIndices, vec2(imod(mcIndex, 64), mcIndex / 64) / 64.);\n\n // bit mask to avoid conditionals (see comment below) for getting MC case corner\n vec4 m0 = vec4(floor(mcData.a * 255.0 + 0.5));\n\n // get edge value masks\n vec4 m1 = vec4(equal(m0, vec4(0., 1., 2., 3.)));\n vec4 m2 = vec4(equal(m0, vec4(4., 5., 6., 7.)));\n vec4 m3 = vec4(equal(m0, vec4(8., 9., 10., 11.)));\n\n // apply bit masks\n vec3 b0 = coord3d +\n m1.y * c1 +\n m1.z * c2 +\n m1.w * c3 +\n m2.x * c4 +\n m2.y * c5 +\n m2.z * c6 +\n m2.w * c7 +\n m3.y * c1 +\n m3.z * c2 +\n m3.w * c3;\n vec3 b1 = coord3d +\n m1.x * c1 +\n m1.y * c2 +\n m1.z * c3 +\n m2.x * c5 +\n m2.y * c6 +\n m2.z * c7 +\n m2.w * c4 +\n m3.x * c4 +\n m3.y * c5 +\n m3.z * c6 +\n m3.w * c7;\n\n // the conditionals that are avoided by above bitmasks\n // vec3 b0 = coord3d;\n // vec3 b1 = coord3d;\n // if (mcIndex == 0.0) {\n // b1 += c1;\n // } else if (mcIndex == 1.0) {\n // b0 += c1; b1 += c2;\n // } else if (mcIndex == 2.0) {\n // b0 += c2; b1 += c3;\n // } else if (mcIndex == 3.0) {\n // b0 += c3;\n // } else if (mcIndex == 4.0) {\n // b0 += c4; b1 += c5;\n // } else if (mcIndex == 5.0) {\n // b0 += c5; b1 += c6;\n // } else if (mcIndex == 6.0) {\n // b0 += c6; b1 += c7;\n // } else if (mcIndex == 7.0) {\n // b0 += c7; b1 += c4;\n // } else if (mcIndex == 8.0) {\n // b1 += c4;\n // } else if (mcIndex == 9.0) {\n // b0 += c1; b1 += c5;\n // } else if (mcIndex == 10.0) {\n // b0 += c2; b1 += c6;\n // } else if (mcIndex == 11.0) {\n // b0 += c3; b1 += c7;\n // }\n // b0 = floor(b0 + 0.5);\n // b1 = floor(b1 + 0.5);\n\n vec4 d0 = voxel(b0);\n vec4 d1 = voxel(b1);\n\n float v0 = d0.a;\n float v1 = d1.a;\n\n float t = (uIsoValue - v0) / (v0 - v1);\n gl_FragData[0].xyz = (uGridTransform * vec4(b0 + t * (b0 - b1), 1.0)).xyz;\n\n // group id\n #if __VERSION__ == 100\n // webgl1 does not support 'flat' interpolation (i.e. no interpolation)\n // so we ensure a constant group id per triangle here\n #ifdef dPackedGroup\n gl_FragData[1] = vec4(voxel(coord3d).rgb, 1.0);\n #else\n gl_FragData[1] = getGroup(coord3d);\n #endif\n #else\n #ifdef dPackedGroup\n gl_FragData[1] = vec4(t < 0.5 ? d0.rgb : d1.rgb, 1.0);\n #else\n gl_FragData[1] = getGroup(t < 0.5 ? b0 : b1);\n #endif\n #endif\n\n // normals from gradients\n vec3 n0 = -normalize(vec3(\n voxelPadded(b0 - c1).a - voxelPadded(b0 + c1).a,\n voxelPadded(b0 - c3).a - voxelPadded(b0 + c3).a,\n voxelPadded(b0 - c4).a - voxelPadded(b0 + c4).a\n ));\n vec3 n1 = -normalize(vec3(\n voxelPadded(b1 - c1).a - voxelPadded(b1 + c1).a,\n voxelPadded(b1 - c3).a - voxelPadded(b1 + c3).a,\n voxelPadded(b1 - c4).a - voxelPadded(b1 + c4).a\n ));\n gl_FragData[2].xyz = -vec3(\n n0.x + t * (n0.x - n1.x),\n n0.y + t * (n0.y - n1.y),\n n0.z + t * (n0.z - n1.z)\n );\n\n // ensure normal-direction is the same for negative and positive iso-levels\n if (uInvert) {\n gl_FragData[2].xyz *= -1.0;\n }\n\n // apply normal matrix\n gl_FragData[2].xyz *= transpose3(inverse3(mat3(uGridTransform)));\n}\n";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isosurface_frag = void 0;
|
|
4
|
-
exports.isosurface_frag = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#if __VERSION__ == 100\n uniform sampler2D tActiveVoxelsPyramid;\n#else\n precision highp isampler2D;\n uniform isampler2D tActiveVoxelsPyramid;\n#endif\n\nuniform sampler2D tActiveVoxelsBase;\nuniform sampler2D tVolumeData;\nuniform sampler2D tTriIndices;\n\nuniform float uIsoValue;\nuniform float uLevels;\nuniform float uSize;\nuniform float uCount;\nuniform bool uInvert;\n\nuniform vec3 uGridDim;\nuniform vec3 uGridTexDim;\nuniform mat4 uGridTransform;\n\n// scale to volume data coord\nuniform vec2 uScale;\n\n#include common\n\n// cube corners (excluding origin)\nconst vec3 c1 = vec3(1., 0., 0.);\nconst vec3 c2 = vec3(1., 1., 0.);\nconst vec3 c3 = vec3(0., 1., 0.);\nconst vec3 c4 = vec3(0., 0., 1.);\nconst vec3 c5 = vec3(1., 0., 1.);\nconst vec3 c6 = vec3(1., 1., 1.);\nconst vec3 c7 = vec3(0., 1., 1.);\n\nvec3 index3dFrom2d(vec2 coord) {\n vec2 gridTexPos = coord * uGridTexDim.xy;\n vec2 columnRow = ivec2Div(gridTexPos, uGridDim.xy);\n vec2 posXY = gridTexPos - columnRow * uGridDim.xy;\n float posZ = columnRow.y * intDiv(uGridTexDim.x, uGridDim.x) + columnRow.x;\n return vec3(posXY, posZ);\n}\n\nvec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {\n float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice\n float column = intDiv(intMod(zSlice * gridDim.x, texDim.x), gridDim.x);\n float row = intDiv(zSlice * gridDim.x, texDim.x);\n vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / (texDim / uScale);\n return texture2D(tex, coord + 0.5 / (texDim / uScale));\n}\n\nvec4 voxel(vec3 pos) {\n pos = min(max(vec3(0.0), pos), uGridDim - vec3(1.0));\n return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);\n}\n\nvec4 voxelPadded(vec3 pos) {\n pos = min(max(vec3(0.0), pos), uGridDim - vec3(vec2(2.0), 1.0)); // remove xy padding\n return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);\n}\n\nint idot2(const in ivec2 a, const in ivec2 b) {\n return a.x * b.x + a.y * b.y;\n}\n\nint idot4(const in ivec4 a, const in ivec4 b) {\n return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;\n}\n\n#if __VERSION__ == 100\n int pyramidVoxel(vec2 pos) {\n return int(decodeFloatRGB(texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).rgb));\n }\n#else\n int pyramidVoxel(vec2 pos) {\n return texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).r;\n }\n#endif\n\nvec4 baseVoxel(vec2 pos) {\n return texture2D(tActiveVoxelsBase, pos / uSize);\n}\n\nvoid main(void) {\n // get 1D index\n int vI = int(gl_FragCoord.x) + int(gl_FragCoord.y) * int(uSize);\n\n // ignore 1D indices outside of the grid\n if(vI >= int(uCount)) discard;\n\n ivec2 offset = ivec2(int(uSize) - 2, 0);\n\n int start = 0;\n ivec4 starts = ivec4(0);\n ivec4 ends = ivec4(0);\n int diff = 2;\n ivec4 m = ivec4(0);\n ivec2 position = ivec2(0);\n ivec4 vI4 = ivec4(vI);\n\n ivec2 relativePosition = ivec2(0);\n int end = 0;\n ivec2 pos1 = ivec2(0);\n ivec2 pos2 = ivec2(0);\n ivec2 pos3 = ivec2(0);\n ivec2 pos4 = ivec2(0);\n ivec3 vI3 = ivec3(vI);\n ivec3 mask = ivec3(0);\n\n // traverse the different levels of the pyramid\n for(int i = 1; i < 14; i++) {\n if(float(i) >= uLevels) break;\n\n offset.x -= diff;\n diff *= 2;\n relativePosition = position + offset;\n\n end = start + pyramidVoxel(vec2(relativePosition));\n pos1 = ivec2(relativePosition);\n starts.x = start;\n ends.x = end;\n pos2 = ivec2(relativePosition + ivec2(1, 0));\n starts.y = ends.x;\n ends.y = ends.x + pyramidVoxel(vec2(pos2));\n pos3 = relativePosition + ivec2(0, 1);\n starts.z = ends.y;\n ends.z = ends.y + pyramidVoxel(vec2(pos3));\n pos4 = relativePosition + ivec2(1, 1);\n starts.w = ends.z;\n mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));\n m = ivec4(mask, 1 - int(any(bvec3(mask))));\n\n relativePosition = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;\n start = idot4(m, starts);\n position = 2 * (relativePosition - offset);\n }\n\n end = start + int(baseVoxel(vec2(position)).r * 255.0);\n pos1 = position;\n starts.x = start;\n ends.x = end;\n pos2 = position + ivec2(1, 0);\n starts.y = ends.x;\n ends.y = ends.x + int(baseVoxel(vec2(pos2)).r * 255.0);\n pos3 = position + ivec2(0, 1);\n starts.z = ends.y;\n ends.z = ends.y + int(baseVoxel(vec2(pos3)).r * 255.0);\n pos4 = position + ivec2(1, 1);\n starts.w = ends.z;\n mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));\n m = ivec4(mask, 1 - int(any(bvec3(mask))));\n position = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;\n\n vec2 coord2d = (vec2(position) / uSize) / uScale;\n vec3 coord3d = floor(index3dFrom2d(coord2d) + 0.5);\n\n float edgeIndex = floor(baseVoxel(vec2(position)).a * 255.0 + 0.5);\n\n // current vertex for the up to 15 MC cases\n int currentVertex = vI - idot4(m, starts);\n\n // ensure winding-order is the same for negative and positive iso-levels\n if (uInvert) {\n int v = imod(currentVertex + 1, 3);\n if (v == 1) currentVertex += 2;\n else if (v == 0) currentVertex -= 2;\n }\n\n // get index into triIndices table\n int mcIndex = 16 * int(edgeIndex) + currentVertex;\n vec4 mcData = texture2D(tTriIndices, vec2(imod(mcIndex, 64), mcIndex / 64) / 64.);\n\n // bit mask to avoid conditionals (see comment below) for getting MC case corner\n vec4 m0 = vec4(floor(mcData.a * 255.0 + 0.5));\n\n // get edge value masks\n vec4 m1 = vec4(equal(m0, vec4(0., 1., 2., 3.)));\n vec4 m2 = vec4(equal(m0, vec4(4., 5., 6., 7.)));\n vec4 m3 = vec4(equal(m0, vec4(8., 9., 10., 11.)));\n\n // apply bit masks\n vec3 b0 = coord3d +\n m1.y * c1 +\n m1.z * c2 +\n m1.w * c3 +\n m2.x * c4 +\n m2.y * c5 +\n m2.z * c6 +\n m2.w * c7 +\n m3.y * c1 +\n m3.z * c2 +\n m3.w * c3;\n vec3 b1 = coord3d +\n m1.x * c1 +\n m1.y * c2 +\n m1.z * c3 +\n m2.x * c5 +\n m2.y * c6 +\n m2.z * c7 +\n m2.w * c4 +\n m3.x * c4 +\n m3.y * c5 +\n m3.z * c6 +\n m3.w * c7;\n\n // the conditionals that are avoided by above bitmasks\n // vec3 b0 = coord3d;\n // vec3 b1 = coord3d;\n // if (mcIndex == 0.0) {\n // b1 += c1;\n // } else if (mcIndex == 1.0) {\n // b0 += c1; b1 += c2;\n // } else if (mcIndex == 2.0) {\n // b0 += c2; b1 += c3;\n // } else if (mcIndex == 3.0) {\n // b0 += c3;\n // } else if (mcIndex == 4.0) {\n // b0 += c4; b1 += c5;\n // } else if (mcIndex == 5.0) {\n // b0 += c5; b1 += c6;\n // } else if (mcIndex == 6.0) {\n // b0 += c6; b1 += c7;\n // } else if (mcIndex == 7.0) {\n // b0 += c7; b1 += c4;\n // } else if (mcIndex == 8.0) {\n // b1 += c4;\n // } else if (mcIndex == 9.0) {\n // b0 += c1; b1 += c5;\n // } else if (mcIndex == 10.0) {\n // b0 += c2; b1 += c6;\n // } else if (mcIndex == 11.0) {\n // b0 += c3; b1 += c7;\n // }\n // b0 = floor(b0 + 0.5);\n // b1 = floor(b1 + 0.5);\n\n vec4 d0 = voxel(b0);\n vec4 d1 = voxel(b1);\n\n float v0 = d0.a;\n float v1 = d1.a;\n\n float t = (uIsoValue - v0) / (v0 - v1);\n gl_FragData[0].xyz = (uGridTransform * vec4(b0 + t * (b0 - b1), 1.0)).xyz;\n\n // group id\n #if __VERSION__ == 100\n // webgl1 does not support 'flat' interpolation (i.e. no interpolation)\n // so we ensure a constant group id per triangle here\n #ifdef dPackedGroup\n gl_FragData[1] = vec4(voxel(coord3d).rgb, 1.0);\n #else\n vec3 gridDim = uGridDim - vec3(1.0, 1.0, 0.0); // remove xy padding\n float group = coord3d.z + coord3d.y * gridDim.z + coord3d.x * gridDim.z * gridDim.y;\n gl_FragData[1] = vec4(group > 16777215.5 ? vec3(1.0) : encodeFloatRGB(group), 1.0);\n #endif\n #else\n #ifdef dPackedGroup\n gl_FragData[1] = vec4(t < 0.5 ? d0.rgb : d1.rgb, 1.0);\n #else\n vec3 b = t < 0.5 ? b0 : b1;\n vec3 gridDim = uGridDim - vec3(1.0, 1.0, 0.0); // remove xy padding\n float group = b.z + b.y * gridDim.z + b.x * gridDim.z * gridDim.y;\n gl_FragData[1] = vec4(group > 16777215.5 ? vec3(1.0) : encodeFloatRGB(group), 1.0);\n #endif\n #endif\n\n // normals from gradients\n vec3 n0 = -normalize(vec3(\n voxelPadded(b0 - c1).a - voxelPadded(b0 + c1).a,\n voxelPadded(b0 - c3).a - voxelPadded(b0 + c3).a,\n voxelPadded(b0 - c4).a - voxelPadded(b0 + c4).a\n ));\n vec3 n1 = -normalize(vec3(\n voxelPadded(b1 - c1).a - voxelPadded(b1 + c1).a,\n voxelPadded(b1 - c3).a - voxelPadded(b1 + c3).a,\n voxelPadded(b1 - c4).a - voxelPadded(b1 + c4).a\n ));\n gl_FragData[2].xyz = -vec3(\n n0.x + t * (n0.x - n1.x),\n n0.y + t * (n0.y - n1.y),\n n0.z + t * (n0.z - n1.z)\n );\n\n // ensure normal-direction is the same for negative and positive iso-levels\n if (uInvert) {\n gl_FragData[2].xyz *= -1.0;\n }\n\n // apply normal matrix\n gl_FragData[2].xyz *= transpose3(inverse3(mat3(uGridTransform)));\n}\n";
|
|
4
|
+
exports.isosurface_frag = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#if __VERSION__ == 100\n uniform sampler2D tActiveVoxelsPyramid;\n#else\n precision highp isampler2D;\n uniform isampler2D tActiveVoxelsPyramid;\n#endif\n\nuniform sampler2D tActiveVoxelsBase;\nuniform sampler2D tVolumeData;\nuniform sampler2D tTriIndices;\n\nuniform float uIsoValue;\nuniform float uLevels;\nuniform float uSize;\nuniform float uCount;\nuniform bool uInvert;\n\nuniform vec3 uGridDim;\nuniform vec3 uGridTexDim;\nuniform mat4 uGridTransform;\n\n// scale to volume data coord\nuniform vec2 uScale;\n\n#include common\n\n// cube corners (excluding origin)\nconst vec3 c1 = vec3(1., 0., 0.);\nconst vec3 c2 = vec3(1., 1., 0.);\nconst vec3 c3 = vec3(0., 1., 0.);\nconst vec3 c4 = vec3(0., 0., 1.);\nconst vec3 c5 = vec3(1., 0., 1.);\nconst vec3 c6 = vec3(1., 1., 1.);\nconst vec3 c7 = vec3(0., 1., 1.);\n\nvec3 index3dFrom2d(vec2 coord) {\n vec2 gridTexPos = coord * uGridTexDim.xy;\n vec2 columnRow = ivec2Div(gridTexPos, uGridDim.xy);\n vec2 posXY = gridTexPos - columnRow * uGridDim.xy;\n float posZ = columnRow.y * intDiv(uGridTexDim.x, uGridDim.x) + columnRow.x;\n return vec3(posXY, posZ);\n}\n\nvec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {\n float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice\n float column = intDiv(intMod(zSlice * gridDim.x, texDim.x), gridDim.x);\n float row = intDiv(zSlice * gridDim.x, texDim.x);\n vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / (texDim / uScale);\n return texture2D(tex, coord + 0.5 / (texDim / uScale));\n}\n\nvec4 voxel(vec3 pos) {\n pos = min(max(vec3(0.0), pos), uGridDim - vec3(1.0));\n return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);\n}\n\nvec4 voxelPadded(vec3 pos) {\n pos = min(max(vec3(0.0), pos), uGridDim - vec3(vec2(2.0), 1.0)); // remove xy padding\n return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);\n}\n\nint idot2(const in ivec2 a, const in ivec2 b) {\n return a.x * b.x + a.y * b.y;\n}\n\nint idot4(const in ivec4 a, const in ivec4 b) {\n return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;\n}\n\n#if __VERSION__ == 100\n int pyramidVoxel(vec2 pos) {\n return int(unpackRGBToInt(texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).rgb));\n }\n#else\n int pyramidVoxel(vec2 pos) {\n return texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).r;\n }\n#endif\n\nvec4 baseVoxel(vec2 pos) {\n return texture2D(tActiveVoxelsBase, pos / uSize);\n}\n\nvec4 getGroup(const in vec3 p) {\n vec3 gridDim = uGridDim - vec3(1.0, 1.0, 0.0); // remove xy padding\n // note that we swap x and z because the texture is flipped around y\n #if defined(dAxisOrder_012)\n float group = p.z + p.y * gridDim.z + p.x * gridDim.z * gridDim.y; // 210\n #elif defined(dAxisOrder_021)\n float group = p.y + p.z * gridDim.y + p.x * gridDim.y * gridDim.z; // 120\n #elif defined(dAxisOrder_102)\n float group = p.z + p.x * gridDim.z + p.y * gridDim.z * gridDim.x; // 201\n #elif defined(dAxisOrder_120)\n float group = p.x + p.z * gridDim.x + p.y * gridDim.x * gridDim.z; // 021\n #elif defined(dAxisOrder_201)\n float group = p.y + p.x * gridDim.y + p.z * gridDim.y * gridDim.x; // 102\n #elif defined(dAxisOrder_210)\n float group = p.x + p.y * gridDim.x + p.z * gridDim.x * gridDim.y; // 012\n #endif\n return vec4(group > 16777215.5 ? vec3(1.0) : packIntToRGB(group), 1.0);\n}\n\nvoid main(void) {\n // get 1D index\n int vI = int(gl_FragCoord.x) + int(gl_FragCoord.y) * int(uSize);\n\n // ignore 1D indices outside of the grid\n if(vI >= int(uCount)) discard;\n\n ivec2 offset = ivec2(int(uSize) - 2, 0);\n\n int start = 0;\n ivec4 starts = ivec4(0);\n ivec4 ends = ivec4(0);\n int diff = 2;\n ivec4 m = ivec4(0);\n ivec2 position = ivec2(0);\n ivec4 vI4 = ivec4(vI);\n\n ivec2 relativePosition = ivec2(0);\n int end = 0;\n ivec2 pos1 = ivec2(0);\n ivec2 pos2 = ivec2(0);\n ivec2 pos3 = ivec2(0);\n ivec2 pos4 = ivec2(0);\n ivec3 vI3 = ivec3(vI);\n ivec3 mask = ivec3(0);\n\n // traverse the different levels of the pyramid\n for(int i = 1; i < 14; i++) {\n if(float(i) >= uLevels) break;\n\n offset.x -= diff;\n diff *= 2;\n relativePosition = position + offset;\n\n end = start + pyramidVoxel(vec2(relativePosition));\n pos1 = ivec2(relativePosition);\n starts.x = start;\n ends.x = end;\n pos2 = ivec2(relativePosition + ivec2(1, 0));\n starts.y = ends.x;\n ends.y = ends.x + pyramidVoxel(vec2(pos2));\n pos3 = relativePosition + ivec2(0, 1);\n starts.z = ends.y;\n ends.z = ends.y + pyramidVoxel(vec2(pos3));\n pos4 = relativePosition + ivec2(1, 1);\n starts.w = ends.z;\n mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));\n m = ivec4(mask, 1 - int(any(bvec3(mask))));\n\n relativePosition = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;\n start = idot4(m, starts);\n position = 2 * (relativePosition - offset);\n }\n\n end = start + int(baseVoxel(vec2(position)).r * 255.0);\n pos1 = position;\n starts.x = start;\n ends.x = end;\n pos2 = position + ivec2(1, 0);\n starts.y = ends.x;\n ends.y = ends.x + int(baseVoxel(vec2(pos2)).r * 255.0);\n pos3 = position + ivec2(0, 1);\n starts.z = ends.y;\n ends.z = ends.y + int(baseVoxel(vec2(pos3)).r * 255.0);\n pos4 = position + ivec2(1, 1);\n starts.w = ends.z;\n mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));\n m = ivec4(mask, 1 - int(any(bvec3(mask))));\n position = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;\n\n vec2 coord2d = (vec2(position) / uSize) / uScale;\n vec3 coord3d = floor(index3dFrom2d(coord2d) + 0.5);\n\n float edgeIndex = floor(baseVoxel(vec2(position)).a * 255.0 + 0.5);\n\n // current vertex for the up to 15 MC cases\n int currentVertex = vI - idot4(m, starts);\n\n // ensure winding-order is the same for negative and positive iso-levels\n if (uInvert) {\n int v = imod(currentVertex + 1, 3);\n if (v == 1) currentVertex += 2;\n else if (v == 0) currentVertex -= 2;\n }\n\n // get index into triIndices table\n int mcIndex = 16 * int(edgeIndex) + currentVertex;\n vec4 mcData = texture2D(tTriIndices, vec2(imod(mcIndex, 64), mcIndex / 64) / 64.);\n\n // bit mask to avoid conditionals (see comment below) for getting MC case corner\n vec4 m0 = vec4(floor(mcData.a * 255.0 + 0.5));\n\n // get edge value masks\n vec4 m1 = vec4(equal(m0, vec4(0., 1., 2., 3.)));\n vec4 m2 = vec4(equal(m0, vec4(4., 5., 6., 7.)));\n vec4 m3 = vec4(equal(m0, vec4(8., 9., 10., 11.)));\n\n // apply bit masks\n vec3 b0 = coord3d +\n m1.y * c1 +\n m1.z * c2 +\n m1.w * c3 +\n m2.x * c4 +\n m2.y * c5 +\n m2.z * c6 +\n m2.w * c7 +\n m3.y * c1 +\n m3.z * c2 +\n m3.w * c3;\n vec3 b1 = coord3d +\n m1.x * c1 +\n m1.y * c2 +\n m1.z * c3 +\n m2.x * c5 +\n m2.y * c6 +\n m2.z * c7 +\n m2.w * c4 +\n m3.x * c4 +\n m3.y * c5 +\n m3.z * c6 +\n m3.w * c7;\n\n // the conditionals that are avoided by above bitmasks\n // vec3 b0 = coord3d;\n // vec3 b1 = coord3d;\n // if (mcIndex == 0.0) {\n // b1 += c1;\n // } else if (mcIndex == 1.0) {\n // b0 += c1; b1 += c2;\n // } else if (mcIndex == 2.0) {\n // b0 += c2; b1 += c3;\n // } else if (mcIndex == 3.0) {\n // b0 += c3;\n // } else if (mcIndex == 4.0) {\n // b0 += c4; b1 += c5;\n // } else if (mcIndex == 5.0) {\n // b0 += c5; b1 += c6;\n // } else if (mcIndex == 6.0) {\n // b0 += c6; b1 += c7;\n // } else if (mcIndex == 7.0) {\n // b0 += c7; b1 += c4;\n // } else if (mcIndex == 8.0) {\n // b1 += c4;\n // } else if (mcIndex == 9.0) {\n // b0 += c1; b1 += c5;\n // } else if (mcIndex == 10.0) {\n // b0 += c2; b1 += c6;\n // } else if (mcIndex == 11.0) {\n // b0 += c3; b1 += c7;\n // }\n // b0 = floor(b0 + 0.5);\n // b1 = floor(b1 + 0.5);\n\n vec4 d0 = voxel(b0);\n vec4 d1 = voxel(b1);\n\n float v0 = d0.a;\n float v1 = d1.a;\n\n float t = (uIsoValue - v0) / (v0 - v1);\n gl_FragData[0].xyz = (uGridTransform * vec4(b0 + t * (b0 - b1), 1.0)).xyz;\n\n // group id\n #if __VERSION__ == 100\n // webgl1 does not support 'flat' interpolation (i.e. no interpolation)\n // so we ensure a constant group id per triangle here\n #ifdef dPackedGroup\n gl_FragData[1] = vec4(voxel(coord3d).rgb, 1.0);\n #else\n gl_FragData[1] = getGroup(coord3d);\n #endif\n #else\n #ifdef dPackedGroup\n gl_FragData[1] = vec4(t < 0.5 ? d0.rgb : d1.rgb, 1.0);\n #else\n gl_FragData[1] = getGroup(t < 0.5 ? b0 : b1);\n #endif\n #endif\n\n // normals from gradients\n vec3 n0 = -normalize(vec3(\n voxelPadded(b0 - c1).a - voxelPadded(b0 + c1).a,\n voxelPadded(b0 - c3).a - voxelPadded(b0 + c3).a,\n voxelPadded(b0 - c4).a - voxelPadded(b0 + c4).a\n ));\n vec3 n1 = -normalize(vec3(\n voxelPadded(b1 - c1).a - voxelPadded(b1 + c1).a,\n voxelPadded(b1 - c3).a - voxelPadded(b1 + c3).a,\n voxelPadded(b1 - c4).a - voxelPadded(b1 + c4).a\n ));\n gl_FragData[2].xyz = -vec3(\n n0.x + t * (n0.x - n1.x),\n n0.y + t * (n0.y - n1.y),\n n0.z + t * (n0.z - n1.z)\n );\n\n // ensure normal-direction is the same for negative and positive iso-levels\n if (uInvert) {\n gl_FragData[2].xyz *= -1.0;\n }\n\n // apply normal matrix\n gl_FragData[2].xyz *= transpose3(inverse3(mat3(uGridTransform)));\n}\n";
|
|
5
5
|
//# sourceMappingURL=isosurface.frag.js.map
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
5
5
|
*/
|
|
6
|
-
export declare const mesh_vert = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include common_clip\n#include texture3d_from_2d_linear\n\n#ifdef
|
|
6
|
+
export declare const mesh_vert = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include common_clip\n#include texture3d_from_2d_linear\n\n#ifdef dGeometryType_textureMesh\n uniform vec2 uGeoTexDim;\n uniform sampler2D tPosition;\n uniform sampler2D tGroup;\n uniform sampler2D tNormal;\n#else\n attribute vec3 aPosition;\n attribute float aGroup;\n attribute vec3 aNormal;\n#endif\nattribute mat4 aTransform;\nattribute float aInstance;\n\nvarying vec3 vNormal;\n\nvoid main(){\n #include assign_group\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_position\n #include assign_color_varying\n #include clip_instance\n\n #ifdef dGeometryType_textureMesh\n vec3 normal = readFromTexture(tNormal, VertexID, uGeoTexDim).xyz;\n #else\n vec3 normal = aNormal;\n #endif\n mat3 normalMatrix = transpose3(inverse3(mat3(modelView)));\n vec3 transformedNormal = normalize(normalMatrix * normalize(normal));\n #if defined(dFlipSided)\n if (!uDoubleSided) { // TODO checking uDoubleSided should not be required, ASR\n transformedNormal = -transformedNormal;\n }\n #endif\n vNormal = transformedNormal;\n}\n";
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.mesh_vert = void 0;
|
|
9
|
-
exports.mesh_vert = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include common_clip\n#include texture3d_from_2d_linear\n\n#ifdef
|
|
9
|
+
exports.mesh_vert = "\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\n#include common\n#include read_from_texture\n#include common_vert_params\n#include color_vert_params\n#include common_clip\n#include texture3d_from_2d_linear\n\n#ifdef dGeometryType_textureMesh\n uniform vec2 uGeoTexDim;\n uniform sampler2D tPosition;\n uniform sampler2D tGroup;\n uniform sampler2D tNormal;\n#else\n attribute vec3 aPosition;\n attribute float aGroup;\n attribute vec3 aNormal;\n#endif\nattribute mat4 aTransform;\nattribute float aInstance;\n\nvarying vec3 vNormal;\n\nvoid main(){\n #include assign_group\n #include assign_marker_varying\n #include assign_clipping_varying\n #include assign_position\n #include assign_color_varying\n #include clip_instance\n\n #ifdef dGeometryType_textureMesh\n vec3 normal = readFromTexture(tNormal, VertexID, uGeoTexDim).xyz;\n #else\n vec3 normal = aNormal;\n #endif\n mat3 normalMatrix = transpose3(inverse3(mat3(modelView)));\n vec3 transformedNormal = normalize(normalMatrix * normalize(normal));\n #if defined(dFlipSided)\n if (!uDoubleSided) { // TODO checking uDoubleSided should not be required, ASR\n transformedNormal = -transformedNormal;\n }\n #endif\n vNormal = transformedNormal;\n}\n";
|
|
10
10
|
//# sourceMappingURL=mesh.vert.js.map
|
|
@@ -164,7 +164,7 @@ var mesh_frag_1 = require("./shader/mesh.frag");
|
|
|
164
164
|
exports.MeshShaderCode = ShaderCode('mesh', mesh_vert_1.mesh_vert, mesh_frag_1.mesh_frag, { drawBuffers: 'optional' }, {}, ignoreDefine);
|
|
165
165
|
var direct_volume_vert_1 = require("./shader/direct-volume.vert");
|
|
166
166
|
var direct_volume_frag_1 = require("./shader/direct-volume.frag");
|
|
167
|
-
exports.DirectVolumeShaderCode = ShaderCode('direct-volume', direct_volume_vert_1.directVolume_vert, direct_volume_frag_1.directVolume_frag, { fragDepth: 'optional', drawBuffers: 'optional' });
|
|
167
|
+
exports.DirectVolumeShaderCode = ShaderCode('direct-volume', direct_volume_vert_1.directVolume_vert, direct_volume_frag_1.directVolume_frag, { fragDepth: 'optional', drawBuffers: 'optional' }, {}, ignoreDefine);
|
|
168
168
|
var image_vert_1 = require("./shader/image.vert");
|
|
169
169
|
var image_frag_1 = require("./shader/image.frag");
|
|
170
170
|
exports.ImageShaderCode = ShaderCode('image', image_vert_1.image_vert, image_frag_1.image_frag, { drawBuffers: 'optional' }, {}, ignoreDefineUnlit);
|
|
@@ -13,7 +13,7 @@ var int_1 = require("../../../mol-data/int");
|
|
|
13
13
|
var linear_algebra_1 = require("../../linear-algebra");
|
|
14
14
|
var mol_util_1 = require("../../../mol-util");
|
|
15
15
|
var renderable_1 = require("../../../mol-gl/renderable");
|
|
16
|
-
var
|
|
16
|
+
var number_packing_1 = require("../../../mol-util/number-packing");
|
|
17
17
|
var shader_code_1 = require("../../../mol-gl/shader-code");
|
|
18
18
|
var render_item_1 = require("../../../mol-gl/webgl/render-item");
|
|
19
19
|
var schema_1 = require("../../../mol-gl/renderable/schema");
|
|
@@ -378,7 +378,7 @@ function fieldFromTexture2d(ctx, texture, dim, texDim) {
|
|
|
378
378
|
for (var ix = 0; ix < dx; ++ix) {
|
|
379
379
|
var idx = 4 * (tmpCol * dx + (iy + tmpRow) * width + ix);
|
|
380
380
|
data[j] = image[idx + 3] / 255;
|
|
381
|
-
idData[j] = (0,
|
|
381
|
+
idData[j] = (0, number_packing_1.unpackRGBToInt)(image[idx], image[idx + 1], image[idx + 2]);
|
|
382
382
|
j++;
|
|
383
383
|
}
|
|
384
384
|
}
|
|
@@ -56,12 +56,11 @@ exports.HighlightLoci = behavior_1.PluginBehavior.create({
|
|
|
56
56
|
class_1.prototype.register = function () {
|
|
57
57
|
var _this = this;
|
|
58
58
|
this.subscribeObservable(this.ctx.behaviors.interaction.hover, function (_a) {
|
|
59
|
-
var _b;
|
|
60
59
|
var current = _a.current, buttons = _a.buttons, modifiers = _a.modifiers;
|
|
61
60
|
if (!_this.ctx.canvas3d || _this.ctx.isBusy)
|
|
62
61
|
return;
|
|
63
62
|
var loci = _this.getLoci(current.loci);
|
|
64
|
-
if (
|
|
63
|
+
if (_this.params.ignore.includes(loci.kind)) {
|
|
65
64
|
_this.ctx.managers.interactivity.lociHighlights.highlightOnly({ repr: current.repr, loci: loci_1.EmptyLoci });
|
|
66
65
|
return;
|
|
67
66
|
}
|
|
@@ -159,16 +158,15 @@ exports.SelectLoci = behavior_1.PluginBehavior.create({
|
|
|
159
158
|
return l - k;
|
|
160
159
|
});
|
|
161
160
|
this.subscribeObservable(this.ctx.behaviors.interaction.click, function (_a) {
|
|
162
|
-
var _b;
|
|
163
161
|
var current = _a.current, button = _a.button, modifiers = _a.modifiers;
|
|
164
162
|
if (!_this.ctx.canvas3d || _this.ctx.isBusy || !_this.ctx.selectionMode)
|
|
165
163
|
return;
|
|
166
164
|
var loci = _this.getLoci(current.loci);
|
|
167
|
-
if (
|
|
165
|
+
if (_this.params.ignore.includes(loci.kind))
|
|
168
166
|
return;
|
|
169
167
|
// only trigger the 1st action that matches
|
|
170
168
|
for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) {
|
|
171
|
-
var
|
|
169
|
+
var _b = actions_1[_i], binding = _b[0], action = _b[1], condition = _b[2];
|
|
172
170
|
if (binding_1.Binding.match(_this.params.bindings[binding], button, modifiers) && (!condition || condition(loci))) {
|
|
173
171
|
action({ repr: current.repr, loci: loci });
|
|
174
172
|
break;
|
|
@@ -192,7 +190,7 @@ exports.SelectLoci = behavior_1.PluginBehavior.create({
|
|
|
192
190
|
structure_1.Structure.areEquivalent(structure, oldStructure) &&
|
|
193
191
|
structure_1.Structure.areHierarchiesEqual(structure, oldStructure))
|
|
194
192
|
return;
|
|
195
|
-
var reprs = _this.ctx.state.data.select(mol_state_1.StateSelection.
|
|
193
|
+
var reprs = _this.ctx.state.data.select(mol_state_1.StateSelection.children(ref).ofType(objects_1.PluginStateObject.Molecule.Structure.Representation3D));
|
|
196
194
|
for (var _i = 0, reprs_1 = reprs; _i < reprs_1.length; _i++) {
|
|
197
195
|
var repr = reprs_1[_i];
|
|
198
196
|
_this.applySelectMark(repr.transform.ref, true);
|
|
@@ -16,7 +16,6 @@ export declare class PluginConfigItem<T = any> {
|
|
|
16
16
|
constructor(key: string, defaultValue?: T | undefined);
|
|
17
17
|
}
|
|
18
18
|
declare function item<T>(key: string, defaultValue?: T): PluginConfigItem<T>;
|
|
19
|
-
export declare function preferWebGl1(): boolean;
|
|
20
19
|
export declare const PluginConfig: {
|
|
21
20
|
item: typeof item;
|
|
22
21
|
General: {
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.PluginConfigManager = exports.PluginConfig = exports.
|
|
9
|
+
exports.PluginConfigManager = exports.PluginConfig = exports.PluginConfigItem = void 0;
|
|
10
10
|
var structure_1 = require("../mol-model/structure");
|
|
11
|
+
var features_1 = require("./features");
|
|
11
12
|
var PluginConfigItem = /** @class */ (function () {
|
|
12
13
|
function PluginConfigItem(key, defaultValue) {
|
|
13
14
|
this.key = key;
|
|
@@ -19,28 +20,6 @@ var PluginConfigItem = /** @class */ (function () {
|
|
|
19
20
|
}());
|
|
20
21
|
exports.PluginConfigItem = PluginConfigItem;
|
|
21
22
|
function item(key, defaultValue) { return new PluginConfigItem(key, defaultValue); }
|
|
22
|
-
function preferWebGl1() {
|
|
23
|
-
if (typeof navigator === 'undefined' || typeof window === 'undefined')
|
|
24
|
-
return false;
|
|
25
|
-
// WebGL2 isn't working in MacOS 12.0.1 Safari 15.1, 15.2. It is working in Safari 15.4 tech preview, so disabling all versions before that.
|
|
26
|
-
// prefer webgl 1 based on the userAgent substring
|
|
27
|
-
var unpportedSafariVersions = [
|
|
28
|
-
'Version/15.1 Safari',
|
|
29
|
-
'Version/15.2 Safari',
|
|
30
|
-
'Version/15.3 Safari'
|
|
31
|
-
];
|
|
32
|
-
if (unpportedSafariVersions.some(function (v) { return navigator.userAgent.indexOf(v) > 0; })) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
// Check for iOS device which enabled WebGL2 recently but it doesn't seem
|
|
36
|
-
// to be full up to speed yet.
|
|
37
|
-
// adapted from https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
|
|
38
|
-
var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
39
|
-
var isAppleDevice = navigator.userAgent.includes('Macintosh');
|
|
40
|
-
var isTouchScreen = navigator.maxTouchPoints >= 4; // true for iOS 13 (and hopefully beyond)
|
|
41
|
-
return !window.MSStream && (isIOS || (isAppleDevice && isTouchScreen));
|
|
42
|
-
}
|
|
43
|
-
exports.preferWebGl1 = preferWebGl1;
|
|
44
23
|
exports.PluginConfig = {
|
|
45
24
|
item: item,
|
|
46
25
|
General: {
|
|
@@ -50,10 +29,10 @@ exports.PluginConfig = {
|
|
|
50
29
|
PixelScale: item('plugin-config.pixel-scale', 1),
|
|
51
30
|
PickScale: item('plugin-config.pick-scale', 0.25),
|
|
52
31
|
PickPadding: item('plugin-config.pick-padding', 3),
|
|
53
|
-
EnableWboit: item('plugin-config.enable-wboit',
|
|
32
|
+
EnableWboit: item('plugin-config.enable-wboit', features_1.PluginFeatureDetection.wboit),
|
|
54
33
|
// as of Oct 1 2021, WebGL 2 doesn't work on iOS 15.
|
|
55
34
|
// TODO: check back in a few weeks to see if it was fixed
|
|
56
|
-
PreferWebGl1: item('plugin-config.prefer-webgl1', preferWebGl1
|
|
35
|
+
PreferWebGl1: item('plugin-config.prefer-webgl1', features_1.PluginFeatureDetection.preferWebGl1),
|
|
57
36
|
},
|
|
58
37
|
State: {
|
|
59
38
|
DefaultServer: item('plugin-state.server', 'https://webchem.ncbr.muni.cz/molstar-state'),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
3
|
+
*
|
|
4
|
+
* @author David Sehnal <david.sehnal@gmail.com>
|
|
5
|
+
*/
|
|
6
|
+
export declare const PluginFeatureDetection: {
|
|
7
|
+
readonly preferWebGl1: boolean;
|
|
8
|
+
readonly wboit: boolean;
|
|
9
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
4
|
+
*
|
|
5
|
+
* @author David Sehnal <david.sehnal@gmail.com>
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.PluginFeatureDetection = void 0;
|
|
9
|
+
exports.PluginFeatureDetection = {
|
|
10
|
+
get preferWebGl1() {
|
|
11
|
+
if (typeof navigator === 'undefined' || typeof window === 'undefined')
|
|
12
|
+
return false;
|
|
13
|
+
// WebGL2 isn't working in MacOS 12.0.1 Safari 15.1, 15.2. It is working in Safari 15.4 tech preview, so disabling all versions before that.
|
|
14
|
+
// prefer webgl 1 based on the userAgent substring
|
|
15
|
+
var unpportedSafariVersions = [
|
|
16
|
+
'Version/15.1 Safari',
|
|
17
|
+
'Version/15.2 Safari',
|
|
18
|
+
'Version/15.3 Safari'
|
|
19
|
+
];
|
|
20
|
+
if (unpportedSafariVersions.some(function (v) { return navigator.userAgent.indexOf(v) > 0; })) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
// Check for iOS device which enabled WebGL2 recently but it doesn't seem
|
|
24
|
+
// to be full up to speed yet.
|
|
25
|
+
// adapted from https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
|
|
26
|
+
var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
27
|
+
var isAppleDevice = navigator.userAgent.includes('Macintosh');
|
|
28
|
+
var isTouchScreen = navigator.maxTouchPoints >= 4; // true for iOS 13 (and hopefully beyond)
|
|
29
|
+
return !window.MSStream && (isIOS || (isAppleDevice && isTouchScreen));
|
|
30
|
+
},
|
|
31
|
+
get wboit() {
|
|
32
|
+
if (typeof navigator === 'undefined' || typeof window === 'undefined')
|
|
33
|
+
return true;
|
|
34
|
+
// disable Wboit in Safari 15
|
|
35
|
+
return !/Version\/15.\d Safari/.test(navigator.userAgent);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=features.js.map
|
|
@@ -31,9 +31,9 @@ export declare namespace StructureRepresentationPresetProvider {
|
|
|
31
31
|
ignoreHydrogens: PD.Base<boolean | undefined>;
|
|
32
32
|
quality: PD.Base<"auto" | "medium" | "high" | "low" | "custom" | "highest" | "higher" | "lower" | "lowest" | undefined>;
|
|
33
33
|
theme: PD.Base<PD.Normalize<{
|
|
34
|
-
globalName: "uniform" | "occupancy" | "element-index" | "element-symbol" | "shape-group" | "uncertainty" | "carbohydrate-symbol" | "chain-id" | "operator-name" | "molecule-type" | "polymer-id" | "polymer-index" | "residue-name" | "secondary-structure" | "sequence-id" | "unit-index" | "entity-source" | "illustrative" | "hydrophobicity" | "model-index" | "operator-hkl" | "partial-charge" | "atom-id" | "entity-id" | undefined;
|
|
34
|
+
globalName: "uniform" | "occupancy" | "element-index" | "element-symbol" | "shape-group" | "uncertainty" | "carbohydrate-symbol" | "chain-id" | "operator-name" | "molecule-type" | "polymer-id" | "polymer-index" | "residue-name" | "secondary-structure" | "sequence-id" | "unit-index" | "entity-source" | "illustrative" | "hydrophobicity" | "model-index" | "operator-hkl" | "partial-charge" | "atom-id" | "entity-id" | "volume-value" | undefined;
|
|
35
35
|
carbonColor: "element-symbol" | "chain-id" | "operator-name" | undefined;
|
|
36
|
-
symmetryColor: "uniform" | "occupancy" | "element-index" | "element-symbol" | "shape-group" | "uncertainty" | "carbohydrate-symbol" | "chain-id" | "operator-name" | "molecule-type" | "polymer-id" | "polymer-index" | "residue-name" | "secondary-structure" | "sequence-id" | "unit-index" | "entity-source" | "illustrative" | "hydrophobicity" | "model-index" | "operator-hkl" | "partial-charge" | "atom-id" | "entity-id" | undefined;
|
|
36
|
+
symmetryColor: "uniform" | "occupancy" | "element-index" | "element-symbol" | "shape-group" | "uncertainty" | "carbohydrate-symbol" | "chain-id" | "operator-name" | "molecule-type" | "polymer-id" | "polymer-index" | "residue-name" | "secondary-structure" | "sequence-id" | "unit-index" | "entity-source" | "illustrative" | "hydrophobicity" | "model-index" | "operator-hkl" | "partial-charge" | "atom-id" | "entity-id" | "volume-value" | undefined;
|
|
37
37
|
focus: PD.Normalize<{
|
|
38
38
|
name: any;
|
|
39
39
|
params: any;
|
|
@@ -44,8 +44,8 @@ export declare namespace StructureRepresentationPresetProvider {
|
|
|
44
44
|
function reprBuilder(plugin: PluginContext, params: CommonParams, structure?: Structure): {
|
|
45
45
|
update: import("../../../mol-state/state/builder").StateBuilder.Root;
|
|
46
46
|
builder: import("./representation").StructureRepresentationBuilder;
|
|
47
|
-
color: "uniform" | "occupancy" | "element-index" | "element-symbol" | "shape-group" | "uncertainty" | "carbohydrate-symbol" | "chain-id" | "operator-name" | "molecule-type" | "polymer-id" | "polymer-index" | "residue-name" | "secondary-structure" | "sequence-id" | "unit-index" | "entity-source" | "illustrative" | "hydrophobicity" | "model-index" | "operator-hkl" | "partial-charge" | "atom-id" | "entity-id" | undefined;
|
|
48
|
-
symmetryColor: "uniform" | "occupancy" | "element-index" | "element-symbol" | "shape-group" | "uncertainty" | "carbohydrate-symbol" | "chain-id" | "operator-name" | "molecule-type" | "polymer-id" | "polymer-index" | "residue-name" | "secondary-structure" | "sequence-id" | "unit-index" | "entity-source" | "illustrative" | "hydrophobicity" | "model-index" | "operator-hkl" | "partial-charge" | "atom-id" | "entity-id" | undefined;
|
|
47
|
+
color: "uniform" | "occupancy" | "element-index" | "element-symbol" | "shape-group" | "uncertainty" | "carbohydrate-symbol" | "chain-id" | "operator-name" | "molecule-type" | "polymer-id" | "polymer-index" | "residue-name" | "secondary-structure" | "sequence-id" | "unit-index" | "entity-source" | "illustrative" | "hydrophobicity" | "model-index" | "operator-hkl" | "partial-charge" | "atom-id" | "entity-id" | "volume-value" | undefined;
|
|
48
|
+
symmetryColor: "uniform" | "occupancy" | "element-index" | "element-symbol" | "shape-group" | "uncertainty" | "carbohydrate-symbol" | "chain-id" | "operator-name" | "molecule-type" | "polymer-id" | "polymer-index" | "residue-name" | "secondary-structure" | "sequence-id" | "unit-index" | "entity-source" | "illustrative" | "hydrophobicity" | "model-index" | "operator-hkl" | "partial-charge" | "atom-id" | "entity-id" | "volume-value" | undefined;
|
|
49
49
|
typeParams: {
|
|
50
50
|
quality: "auto" | "medium" | "high" | "low" | "custom" | "highest" | "higher" | "lower" | "lowest";
|
|
51
51
|
ignoreHydrogens: boolean;
|
|
@@ -250,7 +250,9 @@ var StructureSelectionManager = /** @class */ (function (_super) {
|
|
|
250
250
|
var cell = this.plugin.helpers.substructureParent.get(obj.data, true);
|
|
251
251
|
if (!cell)
|
|
252
252
|
return;
|
|
253
|
-
|
|
253
|
+
// only need to update the root
|
|
254
|
+
if (ref !== cell.transform.ref)
|
|
255
|
+
return;
|
|
254
256
|
if (!this.entries.has(ref))
|
|
255
257
|
return;
|
|
256
258
|
// use structure from last decorator as reference
|
|
@@ -75,7 +75,7 @@ var StructureRepresentation3D = objects_1.PluginStateTransform.BuiltIn({
|
|
|
75
75
|
return ({
|
|
76
76
|
type: param_definition_1.ParamDefinition.Mapped(registry.default.name, registry.getApplicableTypes(a.data), function (name) { return param_definition_1.ParamDefinition.Group(registry.get(name).getParams(themeCtx, a.data)); }),
|
|
77
77
|
colorTheme: param_definition_1.ParamDefinition.Mapped(type.defaultColorTheme.name, themeCtx.colorThemeRegistry.getApplicableTypes(dataCtx), function (name) { return param_definition_1.ParamDefinition.Group(themeCtx.colorThemeRegistry.get(name).getParams(dataCtx)); }, colorThemeInfo),
|
|
78
|
-
sizeTheme: param_definition_1.ParamDefinition.Mapped(type.defaultSizeTheme.name, themeCtx.sizeThemeRegistry.
|
|
78
|
+
sizeTheme: param_definition_1.ParamDefinition.Mapped(type.defaultSizeTheme.name, themeCtx.sizeThemeRegistry.getApplicableTypes(dataCtx), function (name) { return param_definition_1.ParamDefinition.Group(themeCtx.sizeThemeRegistry.get(name).getParams(dataCtx)); })
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
})({
|
|
@@ -801,7 +801,7 @@ var VolumeRepresentation3D = objects_1.PluginStateTransform.BuiltIn({
|
|
|
801
801
|
return ({
|
|
802
802
|
type: param_definition_1.ParamDefinition.Mapped(registry.default.name, registry.types, function (name) { return param_definition_1.ParamDefinition.Group(registry.get(name).getParams(themeCtx, a.data)); }),
|
|
803
803
|
colorTheme: param_definition_1.ParamDefinition.Mapped(type.defaultColorTheme.name, themeCtx.colorThemeRegistry.getApplicableTypes(dataCtx), function (name) { return param_definition_1.ParamDefinition.Group(themeCtx.colorThemeRegistry.get(name).getParams(dataCtx)); }),
|
|
804
|
-
sizeTheme: param_definition_1.ParamDefinition.Mapped(type.defaultSizeTheme.name, themeCtx.sizeThemeRegistry.
|
|
804
|
+
sizeTheme: param_definition_1.ParamDefinition.Mapped(type.defaultSizeTheme.name, themeCtx.sizeThemeRegistry.getApplicableTypes(dataCtx), function (name) { return param_definition_1.ParamDefinition.Group(themeCtx.sizeThemeRegistry.get(name).getParams(dataCtx)); })
|
|
805
805
|
});
|
|
806
806
|
}
|
|
807
807
|
})({
|