molstar 3.7.0 → 3.8.0
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/LICENSE +20 -20
- package/README.md +202 -202
- package/build/viewer/embedded.html +43 -43
- package/build/viewer/index.html +106 -106
- package/build/viewer/molstar.js +1 -1
- package/build/viewer/molstar.js.LICENSE.txt +0 -15
- package/lib/apps/docking-viewer/index.html +36 -36
- package/lib/apps/viewer/embedded.html +43 -43
- package/lib/apps/viewer/index.html +106 -106
- package/lib/cli/chem-comp-dict/create-ions.d.ts +2 -1
- package/lib/cli/chem-comp-dict/create-ions.js +3 -2
- package/lib/cli/cifschema/index.js +1 -1
- package/lib/cli/cifschema/util/cif-dic.js +1 -0
- package/lib/commonjs/cli/chem-comp-dict/create-ions.d.ts +2 -1
- package/lib/commonjs/cli/chem-comp-dict/create-ions.js +3 -2
- package/lib/commonjs/cli/cifschema/index.js +1 -1
- package/lib/commonjs/cli/cifschema/util/cif-dic.js +1 -0
- package/lib/commonjs/examples/proteopedia-wrapper/coloring.d.ts +20 -5
- package/lib/commonjs/extensions/rcsb/graphql/types.d.ts +284 -0
- package/lib/commonjs/mol-canvas3d/passes/draw.d.ts +0 -2
- package/lib/commonjs/mol-canvas3d/passes/draw.js +35 -70
- package/lib/commonjs/mol-canvas3d/passes/pick.d.ts +1 -1
- package/lib/commonjs/mol-canvas3d/passes/pick.js +1 -1
- package/lib/commonjs/mol-canvas3d/passes/postprocessing.d.ts +1 -0
- package/lib/commonjs/mol-canvas3d/passes/postprocessing.js +16 -11
- package/lib/commonjs/mol-geo/geometry/color-data.d.ts +5 -2
- package/lib/commonjs/mol-geo/geometry/color-data.js +7 -17
- package/lib/commonjs/mol-geo/geometry/cylinders/cylinders.d.ts +1 -1
- package/lib/commonjs/mol-geo/geometry/cylinders/cylinders.js +2 -2
- package/lib/commonjs/mol-geo/geometry/lines/lines.d.ts +1 -0
- package/lib/commonjs/mol-geo/geometry/mesh/mesh.js +2 -2
- package/lib/commonjs/mol-geo/geometry/points/points.d.ts +1 -1
- package/lib/commonjs/mol-geo/geometry/spheres/spheres.js +2 -2
- package/lib/commonjs/mol-geo/geometry/texture-mesh/texture-mesh.js +2 -2
- package/lib/commonjs/mol-geo/geometry/transparency-data.d.ts +1 -1
- package/lib/commonjs/mol-geo/geometry/transparency-data.js +3 -1
- package/lib/commonjs/mol-gl/renderable/cylinders.d.ts +1 -1
- package/lib/commonjs/mol-gl/renderable/cylinders.js +1 -1
- package/lib/commonjs/mol-gl/renderable/mesh.d.ts +1 -1
- package/lib/commonjs/mol-gl/renderable/mesh.js +1 -1
- package/lib/commonjs/mol-gl/renderable/schema.d.ts +2 -2
- package/lib/commonjs/mol-gl/renderable/schema.js +2 -2
- package/lib/commonjs/mol-gl/renderable/spheres.d.ts +1 -1
- package/lib/commonjs/mol-gl/renderable/spheres.js +1 -1
- 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.d.ts +5 -5
- package/lib/commonjs/mol-gl/renderer.js +64 -45
- package/lib/commonjs/mol-gl/scene.d.ts +1 -0
- package/lib/commonjs/mol-gl/scene.js +26 -1
- package/lib/commonjs/mol-gl/shader/chunks/apply-interior-color.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/apply-interior-color.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/assign-material-color.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/assign-material-color.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/check-picking-alpha.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/check-picking-alpha.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/common-frag-params.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/common-frag-params.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/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/image.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/image.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/outlines.frag.d.ts +3 -2
- package/lib/commonjs/mol-gl/shader/outlines.frag.js +3 -2
- package/lib/commonjs/mol-gl/shader/postprocessing.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/postprocessing.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/ssao.frag.d.ts +2 -2
- package/lib/commonjs/mol-gl/shader/ssao.frag.js +2 -2
- package/lib/commonjs/mol-gl/webgl/render-target.d.ts +3 -1
- package/lib/commonjs/mol-gl/webgl/render-target.js +3 -1
- package/lib/commonjs/mol-gl/webgl/renderbuffer.d.ts +2 -1
- package/lib/commonjs/mol-gl/webgl/renderbuffer.js +8 -1
- package/lib/commonjs/mol-gl/webgl/state.d.ts +7 -1
- package/lib/commonjs/mol-gl/webgl/state.js +28 -1
- package/lib/commonjs/mol-gl/webgl/texture.js +3 -0
- package/lib/commonjs/mol-io/reader/cif/schema/bird.d.ts +1 -1
- package/lib/commonjs/mol-io/reader/cif/schema/bird.js +1 -1
- package/lib/commonjs/mol-io/reader/cif/schema/ccd.d.ts +1 -1
- package/lib/commonjs/mol-io/reader/cif/schema/ccd.js +1 -1
- package/lib/commonjs/mol-io/reader/cif/schema/cif-core.d.ts +1 -1
- package/lib/commonjs/mol-io/reader/cif/schema/cif-core.js +1 -1
- package/lib/commonjs/mol-io/reader/cif/schema/mmcif.d.ts +3 -4
- package/lib/commonjs/mol-io/reader/cif/schema/mmcif.js +2 -3
- package/lib/commonjs/mol-io/reader/dx/parser.js +1 -1
- package/lib/commonjs/mol-math/geometry/lookup3d/grid.d.ts +1 -1
- package/lib/commonjs/mol-math/geometry/lookup3d/grid.js +3 -3
- package/lib/commonjs/mol-model/structure/model/properties/seconday-structure.d.ts +4 -2
- package/lib/commonjs/mol-model/structure/model/properties/seconday-structure.js +2 -1
- package/lib/commonjs/mol-model/structure/model/types/ions.d.ts +2 -2
- package/lib/commonjs/mol-model/structure/model/types/ions.js +2 -2
- package/lib/commonjs/mol-model/structure/model/types/saccharides.js +1 -1
- package/lib/commonjs/mol-model/structure/model/types.d.ts +1 -1
- package/lib/commonjs/mol-model/structure/model/types.js +43 -41
- package/lib/commonjs/mol-model-formats/structure/common/property.js +2 -0
- package/lib/commonjs/mol-model-formats/structure/property/secondary-structure.d.ts +1 -1
- package/lib/commonjs/mol-model-formats/structure/property/secondary-structure.js +2 -2
- package/lib/commonjs/mol-plugin/behavior/dynamic/volume-streaming/model.d.ts +3 -2
- package/lib/commonjs/mol-plugin-state/helpers/root-structure.js +3 -1
- package/lib/commonjs/mol-repr/volume/slice.js +1 -1
- package/lib/commonjs/mol-script/language/builder.d.ts +0 -1
- package/lib/commonjs/mol-theme/color/volume-value.d.ts +3 -2
- package/lib/commonjs/mol-theme/color/volume-value.js +1 -3
- package/lib/commonjs/mol-theme/color.d.ts +47 -38
- package/lib/commonjs/mol-theme/theme.d.ts +8 -7
- package/lib/commonjs/mol-theme/theme.js +1 -1
- package/lib/examples/alpha-orbitals/index.html +61 -61
- package/lib/examples/basic-wrapper/index.html +137 -137
- package/lib/examples/lighting/index.html +88 -88
- package/lib/examples/proteopedia-wrapper/coloring.d.ts +20 -5
- package/lib/examples/proteopedia-wrapper/index.html +236 -236
- package/lib/extensions/rcsb/graphql/types.d.ts +284 -0
- package/lib/mol-canvas3d/passes/draw.d.ts +0 -2
- package/lib/mol-canvas3d/passes/draw.js +32 -67
- package/lib/mol-canvas3d/passes/pick.d.ts +1 -1
- package/lib/mol-canvas3d/passes/pick.js +1 -1
- package/lib/mol-canvas3d/passes/postprocessing.d.ts +1 -0
- package/lib/mol-canvas3d/passes/postprocessing.js +16 -11
- package/lib/mol-geo/geometry/color-data.d.ts +5 -2
- package/lib/mol-geo/geometry/color-data.js +7 -17
- package/lib/mol-geo/geometry/cylinders/cylinders.d.ts +1 -1
- package/lib/mol-geo/geometry/cylinders/cylinders.js +2 -2
- package/lib/mol-geo/geometry/lines/lines.d.ts +1 -0
- package/lib/mol-geo/geometry/mesh/mesh.js +2 -2
- package/lib/mol-geo/geometry/points/points.d.ts +1 -1
- package/lib/mol-geo/geometry/spheres/spheres.js +2 -2
- package/lib/mol-geo/geometry/texture-mesh/texture-mesh.js +2 -2
- package/lib/mol-geo/geometry/transparency-data.d.ts +1 -1
- package/lib/mol-geo/geometry/transparency-data.js +3 -1
- package/lib/mol-gl/renderable/cylinders.d.ts +1 -1
- package/lib/mol-gl/renderable/cylinders.js +1 -1
- package/lib/mol-gl/renderable/mesh.d.ts +1 -1
- package/lib/mol-gl/renderable/mesh.js +1 -1
- package/lib/mol-gl/renderable/schema.d.ts +2 -2
- package/lib/mol-gl/renderable/schema.js +2 -2
- package/lib/mol-gl/renderable/spheres.d.ts +1 -1
- package/lib/mol-gl/renderable/spheres.js +1 -1
- 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.d.ts +5 -5
- package/lib/mol-gl/renderer.js +64 -45
- package/lib/mol-gl/scene.d.ts +1 -0
- package/lib/mol-gl/scene.js +26 -1
- package/lib/mol-gl/shader/chunks/apply-interior-color.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/apply-interior-color.glsl.js +1 -1
- package/lib/mol-gl/shader/chunks/assign-material-color.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/assign-material-color.glsl.js +1 -1
- package/lib/mol-gl/shader/chunks/check-picking-alpha.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/check-picking-alpha.glsl.js +1 -1
- package/lib/mol-gl/shader/chunks/common-frag-params.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/common-frag-params.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/direct-volume.frag.d.ts +1 -1
- package/lib/mol-gl/shader/direct-volume.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/outlines.frag.d.ts +3 -2
- package/lib/mol-gl/shader/outlines.frag.js +3 -2
- package/lib/mol-gl/shader/postprocessing.frag.d.ts +1 -1
- package/lib/mol-gl/shader/postprocessing.frag.js +1 -1
- package/lib/mol-gl/shader/ssao.frag.d.ts +2 -2
- package/lib/mol-gl/shader/ssao.frag.js +2 -2
- package/lib/mol-gl/webgl/render-target.d.ts +3 -1
- package/lib/mol-gl/webgl/render-target.js +3 -1
- package/lib/mol-gl/webgl/renderbuffer.d.ts +2 -1
- package/lib/mol-gl/webgl/renderbuffer.js +8 -1
- package/lib/mol-gl/webgl/state.d.ts +7 -1
- package/lib/mol-gl/webgl/state.js +28 -1
- package/lib/mol-gl/webgl/texture.js +3 -0
- package/lib/mol-io/reader/cif/schema/bird.d.ts +1 -1
- package/lib/mol-io/reader/cif/schema/bird.js +1 -1
- package/lib/mol-io/reader/cif/schema/ccd.d.ts +1 -1
- package/lib/mol-io/reader/cif/schema/ccd.js +1 -1
- package/lib/mol-io/reader/cif/schema/cif-core.d.ts +1 -1
- package/lib/mol-io/reader/cif/schema/cif-core.js +1 -1
- package/lib/mol-io/reader/cif/schema/mmcif.d.ts +3 -4
- package/lib/mol-io/reader/cif/schema/mmcif.js +2 -3
- package/lib/mol-io/reader/dx/parser.js +1 -1
- package/lib/mol-math/geometry/lookup3d/grid.d.ts +1 -1
- package/lib/mol-math/geometry/lookup3d/grid.js +3 -3
- package/lib/mol-model/structure/model/properties/seconday-structure.d.ts +4 -2
- package/lib/mol-model/structure/model/properties/seconday-structure.js +2 -1
- package/lib/mol-model/structure/model/types/ions.d.ts +2 -2
- package/lib/mol-model/structure/model/types/ions.js +2 -2
- package/lib/mol-model/structure/model/types/saccharides.js +1 -1
- package/lib/mol-model/structure/model/types.d.ts +1 -1
- package/lib/mol-model/structure/model/types.js +43 -41
- package/lib/mol-model-formats/structure/common/property.js +2 -0
- package/lib/mol-model-formats/structure/property/secondary-structure.d.ts +1 -1
- package/lib/mol-model-formats/structure/property/secondary-structure.js +2 -2
- package/lib/mol-plugin/behavior/dynamic/volume-streaming/model.d.ts +3 -2
- package/lib/mol-plugin/version.js +2 -2
- package/lib/mol-plugin-state/helpers/root-structure.js +3 -1
- package/lib/mol-plugin-ui/skin/base/base.scss +32 -32
- package/lib/mol-plugin-ui/skin/base/components/controls-base.scss +333 -333
- package/lib/mol-plugin-ui/skin/base/components/controls.scss +418 -418
- package/lib/mol-plugin-ui/skin/base/components/help.scss +27 -27
- package/lib/mol-plugin-ui/skin/base/components/line-graph.scss +67 -67
- package/lib/mol-plugin-ui/skin/base/components/log.scss +100 -100
- package/lib/mol-plugin-ui/skin/base/components/misc.scss +643 -643
- package/lib/mol-plugin-ui/skin/base/components/sequence.scss +125 -125
- package/lib/mol-plugin-ui/skin/base/components/slider.scss +165 -165
- package/lib/mol-plugin-ui/skin/base/components/tasks.scss +99 -99
- package/lib/mol-plugin-ui/skin/base/components/toast.scss +83 -83
- package/lib/mol-plugin-ui/skin/base/components/transformer.scss +163 -163
- package/lib/mol-plugin-ui/skin/base/components/viewport.scss +128 -128
- package/lib/mol-plugin-ui/skin/base/layout/common.scss +71 -71
- package/lib/mol-plugin-ui/skin/base/layout/controls-landscape.scss +89 -89
- package/lib/mol-plugin-ui/skin/base/layout/controls-outside.scss +98 -98
- package/lib/mol-plugin-ui/skin/base/layout/controls-portrait.scss +108 -108
- package/lib/mol-plugin-ui/skin/base/layout.scss +40 -40
- package/lib/mol-plugin-ui/skin/base/logo.scss +12 -12
- package/lib/mol-plugin-ui/skin/base/normalize.scss +209 -209
- package/lib/mol-plugin-ui/skin/base/ui.scss +40 -40
- package/lib/mol-plugin-ui/skin/base/variables.scss +85 -85
- package/lib/mol-plugin-ui/skin/blue.scss +1 -1
- package/lib/mol-plugin-ui/skin/colors/blue.scss +23 -23
- package/lib/mol-plugin-ui/skin/colors/dark.scss +23 -23
- package/lib/mol-plugin-ui/skin/colors/light.scss +29 -29
- package/lib/mol-plugin-ui/skin/dark.scss +1 -1
- package/lib/mol-plugin-ui/skin/light.scss +1 -1
- package/lib/mol-repr/volume/slice.js +1 -1
- package/lib/mol-script/language/builder.d.ts +0 -1
- package/lib/mol-theme/color/volume-value.d.ts +3 -2
- package/lib/mol-theme/color/volume-value.js +2 -4
- package/lib/mol-theme/color.d.ts +47 -38
- package/lib/mol-theme/theme.d.ts +8 -7
- package/lib/mol-theme/theme.js +1 -1
- package/package.json +162 -162
|
@@ -67,7 +67,9 @@ var Renderer;
|
|
|
67
67
|
var drawingBufferSize = linear_algebra_1.Vec2.create(gl.drawingBufferWidth, gl.drawingBufferHeight);
|
|
68
68
|
var bgColor = color_1.Color.toVec3Normalized((0, linear_algebra_1.Vec3)(), p.backgroundColor);
|
|
69
69
|
var transparentBackground = false;
|
|
70
|
-
var emptyDepthTexture = ctx.resources.texture('image-
|
|
70
|
+
var emptyDepthTexture = ctx.resources.texture('image-uint8', 'rgba', 'ubyte', 'nearest');
|
|
71
|
+
emptyDepthTexture.define(1, 1);
|
|
72
|
+
emptyDepthTexture.load({ array: new Uint8Array([255, 255, 255, 255]), width: 1, height: 1 });
|
|
71
73
|
var sharedTexturesList = [
|
|
72
74
|
['tDepth', emptyDepthTexture]
|
|
73
75
|
];
|
|
@@ -104,7 +106,7 @@ var Renderer;
|
|
|
104
106
|
uFogNear: mol_util_1.ValueCell.create(1),
|
|
105
107
|
uFogFar: mol_util_1.ValueCell.create(10000),
|
|
106
108
|
uFogColor: mol_util_1.ValueCell.create(bgColor),
|
|
107
|
-
|
|
109
|
+
uRenderMask: mol_util_1.ValueCell.create(0),
|
|
108
110
|
uMarkingDepthTest: mol_util_1.ValueCell.create(false),
|
|
109
111
|
uPickType: mol_util_1.ValueCell.create(0 /* None */),
|
|
110
112
|
uMarkingType: mol_util_1.ValueCell.create(0 /* None */),
|
|
@@ -223,14 +225,14 @@ var Renderer;
|
|
|
223
225
|
mol_util_1.ValueCell.updateIfChanged(globalUniforms.uFogNear, camera.fogNear);
|
|
224
226
|
mol_util_1.ValueCell.updateIfChanged(globalUniforms.uTransparentBackground, transparentBackground);
|
|
225
227
|
};
|
|
226
|
-
var updateInternal = function (group, camera, depthTexture,
|
|
228
|
+
var updateInternal = function (group, camera, depthTexture, renderMask, markingDepthTest) {
|
|
227
229
|
(0, array_1.arrayMapUpsert)(sharedTexturesList, 'tDepth', depthTexture || emptyDepthTexture);
|
|
228
230
|
mol_util_1.ValueCell.update(globalUniforms.uModel, group.view);
|
|
229
231
|
mol_util_1.ValueCell.update(globalUniforms.uModelView, linear_algebra_1.Mat4.mul(modelView, group.view, camera.view));
|
|
230
232
|
mol_util_1.ValueCell.update(globalUniforms.uInvModelView, linear_algebra_1.Mat4.invert(invModelView, modelView));
|
|
231
233
|
mol_util_1.ValueCell.update(globalUniforms.uModelViewProjection, linear_algebra_1.Mat4.mul(modelViewProjection, modelView, camera.projection));
|
|
232
234
|
mol_util_1.ValueCell.update(globalUniforms.uInvModelViewProjection, linear_algebra_1.Mat4.invert(invModelViewProjection, modelViewProjection));
|
|
233
|
-
mol_util_1.ValueCell.updateIfChanged(globalUniforms.
|
|
235
|
+
mol_util_1.ValueCell.updateIfChanged(globalUniforms.uRenderMask, renderMask);
|
|
234
236
|
mol_util_1.ValueCell.updateIfChanged(globalUniforms.uMarkingDepthTest, markingDepthTest);
|
|
235
237
|
state.enable(gl.SCISSOR_TEST);
|
|
236
238
|
state.colorMask(true, true, true, true);
|
|
@@ -244,7 +246,7 @@ var Renderer;
|
|
|
244
246
|
state.disable(gl.BLEND);
|
|
245
247
|
state.enable(gl.DEPTH_TEST);
|
|
246
248
|
state.depthMask(true);
|
|
247
|
-
updateInternal(group, camera, depthTexture,
|
|
249
|
+
updateInternal(group, camera, depthTexture, 0 /* All */, false);
|
|
248
250
|
mol_util_1.ValueCell.updateIfChanged(globalUniforms.uPickType, pickType);
|
|
249
251
|
var renderables = group.renderables;
|
|
250
252
|
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
@@ -257,17 +259,45 @@ var Renderer;
|
|
|
257
259
|
state.disable(gl.BLEND);
|
|
258
260
|
state.enable(gl.DEPTH_TEST);
|
|
259
261
|
state.depthMask(true);
|
|
260
|
-
updateInternal(group, camera, depthTexture,
|
|
262
|
+
updateInternal(group, camera, depthTexture, 0 /* All */, false);
|
|
261
263
|
var renderables = group.renderables;
|
|
262
264
|
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
263
265
|
renderObject(renderables[i], 'depth', 0 /* None */);
|
|
264
266
|
}
|
|
265
267
|
};
|
|
268
|
+
var renderDepthOpaque = function (group, camera, depthTexture) {
|
|
269
|
+
var _a;
|
|
270
|
+
state.disable(gl.BLEND);
|
|
271
|
+
state.enable(gl.DEPTH_TEST);
|
|
272
|
+
state.depthMask(true);
|
|
273
|
+
updateInternal(group, camera, depthTexture, 1 /* Opaque */, false);
|
|
274
|
+
var renderables = group.renderables;
|
|
275
|
+
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
276
|
+
var r = renderables[i];
|
|
277
|
+
if (r.state.opaque && r.values.transparencyAverage.ref.value !== 1 && !((_a = r.values.dXrayShaded) === null || _a === void 0 ? void 0 : _a.ref.value)) {
|
|
278
|
+
renderObject(r, 'depth', 0 /* None */);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
var renderDepthTransparent = function (group, camera, depthTexture) {
|
|
283
|
+
var _a;
|
|
284
|
+
state.disable(gl.BLEND);
|
|
285
|
+
state.enable(gl.DEPTH_TEST);
|
|
286
|
+
state.depthMask(true);
|
|
287
|
+
updateInternal(group, camera, depthTexture, 2 /* Transparent */, false);
|
|
288
|
+
var renderables = group.renderables;
|
|
289
|
+
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
290
|
+
var r = renderables[i];
|
|
291
|
+
if (!r.state.opaque || r.values.transparencyAverage.ref.value > 0 || ((_a = r.values.dXrayShaded) === null || _a === void 0 ? void 0 : _a.ref.value)) {
|
|
292
|
+
renderObject(r, 'depth', 0 /* None */);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
};
|
|
266
296
|
var renderMarkingDepth = function (group, camera, depthTexture) {
|
|
267
297
|
state.disable(gl.BLEND);
|
|
268
298
|
state.enable(gl.DEPTH_TEST);
|
|
269
299
|
state.depthMask(true);
|
|
270
|
-
updateInternal(group, camera, depthTexture,
|
|
300
|
+
updateInternal(group, camera, depthTexture, 0 /* All */, false);
|
|
271
301
|
mol_util_1.ValueCell.updateIfChanged(globalUniforms.uMarkingType, 1 /* Depth */);
|
|
272
302
|
var renderables = group.renderables;
|
|
273
303
|
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
@@ -281,7 +311,7 @@ var Renderer;
|
|
|
281
311
|
state.disable(gl.BLEND);
|
|
282
312
|
state.enable(gl.DEPTH_TEST);
|
|
283
313
|
state.depthMask(true);
|
|
284
|
-
updateInternal(group, camera, depthTexture,
|
|
314
|
+
updateInternal(group, camera, depthTexture, 0 /* All */, !!depthTexture);
|
|
285
315
|
mol_util_1.ValueCell.updateIfChanged(globalUniforms.uMarkingType, 2 /* Mask */);
|
|
286
316
|
var renderables = group.renderables;
|
|
287
317
|
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
@@ -300,14 +330,14 @@ var Renderer;
|
|
|
300
330
|
state.disable(gl.BLEND);
|
|
301
331
|
state.enable(gl.DEPTH_TEST);
|
|
302
332
|
state.depthMask(true);
|
|
303
|
-
updateInternal(group, camera, depthTexture,
|
|
333
|
+
updateInternal(group, camera, depthTexture, 1 /* Opaque */, false);
|
|
304
334
|
var renderables = group.renderables;
|
|
305
335
|
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
306
336
|
var r = renderables[i];
|
|
307
337
|
if (r.state.opaque) {
|
|
308
338
|
renderObject(r, 'colorBlended', 0 /* None */);
|
|
309
339
|
}
|
|
310
|
-
else if (((_a = r.values.uDoubleSided) === null || _a === void 0 ? void 0 : _a.ref.value) && ((_b = r.values.
|
|
340
|
+
else if (((_a = r.values.uDoubleSided) === null || _a === void 0 ? void 0 : _a.ref.value) && ((_b = r.values.dTransparentBackfaces) === null || _b === void 0 ? void 0 : _b.ref.value) === 'opaque') {
|
|
311
341
|
renderObject(r, 'colorBlended', 2 /* BlendedBack */);
|
|
312
342
|
}
|
|
313
343
|
}
|
|
@@ -315,7 +345,7 @@ var Renderer;
|
|
|
315
345
|
var renderBlendedTransparent = function (group, camera, depthTexture) {
|
|
316
346
|
var _a, _b;
|
|
317
347
|
state.enable(gl.DEPTH_TEST);
|
|
318
|
-
updateInternal(group, camera, depthTexture,
|
|
348
|
+
updateInternal(group, camera, depthTexture, 2 /* Transparent */, false);
|
|
319
349
|
var renderables = group.renderables;
|
|
320
350
|
if (transparentBackground) {
|
|
321
351
|
state.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
@@ -334,10 +364,10 @@ var Renderer;
|
|
|
334
364
|
state.depthMask(false);
|
|
335
365
|
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
336
366
|
var r = renderables[i];
|
|
337
|
-
if (!r.state.opaque && !r.state.writeDepth) {
|
|
367
|
+
if ((!r.state.opaque && !r.state.writeDepth) || r.values.transparencyAverage.ref.value > 0) {
|
|
338
368
|
if ((_a = r.values.uDoubleSided) === null || _a === void 0 ? void 0 : _a.ref.value) {
|
|
339
369
|
// render frontfaces and backfaces separately to avoid artefacts
|
|
340
|
-
if (
|
|
370
|
+
if (((_b = r.values.dTransparentBackfaces) === null || _b === void 0 ? void 0 : _b.ref.value) !== 'opaque') {
|
|
341
371
|
renderObject(r, 'colorBlended', 2 /* BlendedBack */);
|
|
342
372
|
}
|
|
343
373
|
renderObject(r, 'colorBlended', 1 /* BlendedFront */);
|
|
@@ -348,34 +378,14 @@ var Renderer;
|
|
|
348
378
|
}
|
|
349
379
|
}
|
|
350
380
|
};
|
|
351
|
-
var
|
|
352
|
-
var _a;
|
|
381
|
+
var renderBlendedVolume = function (group, camera, depthTexture) {
|
|
353
382
|
state.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
354
383
|
state.enable(gl.BLEND);
|
|
355
|
-
updateInternal(group, camera, depthTexture,
|
|
384
|
+
updateInternal(group, camera, depthTexture, 2 /* Transparent */, false);
|
|
356
385
|
var renderables = group.renderables;
|
|
357
386
|
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
358
387
|
var r = renderables[i];
|
|
359
|
-
|
|
360
|
-
// uAlpha is updated in "render" so we need to recompute it here
|
|
361
|
-
var alpha = (0, interpolate_1.clamp)(r.values.alpha.ref.value * r.state.alphaFactor, 0, 1);
|
|
362
|
-
if (alpha === 1 && r.values.transparencyAverage.ref.value !== 1 && !((_a = r.values.dXrayShaded) === null || _a === void 0 ? void 0 : _a.ref.value)) {
|
|
363
|
-
renderObject(r, 'colorBlended', 0 /* None */);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
var renderBlendedVolumeTransparent = function (group, camera, depthTexture) {
|
|
368
|
-
var _a;
|
|
369
|
-
state.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
370
|
-
state.enable(gl.BLEND);
|
|
371
|
-
updateInternal(group, camera, depthTexture, false, false);
|
|
372
|
-
var renderables = group.renderables;
|
|
373
|
-
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
374
|
-
var r = renderables[i];
|
|
375
|
-
// TODO: simplify, handle in renderable.state???
|
|
376
|
-
// uAlpha is updated in "render" so we need to recompute it here
|
|
377
|
-
var alpha = (0, interpolate_1.clamp)(r.values.alpha.ref.value * r.state.alphaFactor, 0, 1);
|
|
378
|
-
if (alpha < 1 || r.values.transparencyAverage.ref.value > 0 || ((_a = r.values.dXrayShaded) === null || _a === void 0 ? void 0 : _a.ref.value)) {
|
|
388
|
+
if (r.values.dGeometryType.ref.value === 'directVolume') {
|
|
379
389
|
renderObject(r, 'colorBlended', 0 /* None */);
|
|
380
390
|
}
|
|
381
391
|
}
|
|
@@ -385,21 +395,21 @@ var Renderer;
|
|
|
385
395
|
state.disable(gl.BLEND);
|
|
386
396
|
state.enable(gl.DEPTH_TEST);
|
|
387
397
|
state.depthMask(true);
|
|
388
|
-
updateInternal(group, camera, depthTexture,
|
|
398
|
+
updateInternal(group, camera, depthTexture, 1 /* Opaque */, false);
|
|
389
399
|
var renderables = group.renderables;
|
|
390
400
|
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
391
401
|
var r = renderables[i];
|
|
392
402
|
// TODO: simplify, handle in renderable.state???
|
|
393
403
|
// uAlpha is updated in "render" so we need to recompute it here
|
|
394
404
|
var alpha = (0, interpolate_1.clamp)(r.values.alpha.ref.value * r.state.alphaFactor, 0, 1);
|
|
395
|
-
if ((alpha === 1 && r.values.transparencyAverage.ref.value !== 1 && r.values.dGeometryType.ref.value !== 'directVolume' && ((_a = r.values.dPointStyle) === null || _a === void 0 ? void 0 : _a.ref.value) !== 'fuzzy' && !((_b = r.values.dXrayShaded) === null || _b === void 0 ? void 0 : _b.ref.value)) || ((_c = r.values.
|
|
405
|
+
if ((alpha === 1 && r.values.transparencyAverage.ref.value !== 1 && r.values.dGeometryType.ref.value !== 'directVolume' && ((_a = r.values.dPointStyle) === null || _a === void 0 ? void 0 : _a.ref.value) !== 'fuzzy' && !((_b = r.values.dXrayShaded) === null || _b === void 0 ? void 0 : _b.ref.value)) || ((_c = r.values.dTransparentBackfaces) === null || _c === void 0 ? void 0 : _c.ref.value) === 'opaque') {
|
|
396
406
|
renderObject(r, 'colorWboit', 0 /* None */);
|
|
397
407
|
}
|
|
398
408
|
}
|
|
399
409
|
};
|
|
400
410
|
var renderWboitTransparent = function (group, camera, depthTexture) {
|
|
401
411
|
var _a, _b;
|
|
402
|
-
updateInternal(group, camera, depthTexture,
|
|
412
|
+
updateInternal(group, camera, depthTexture, 2 /* Transparent */, false);
|
|
403
413
|
var renderables = group.renderables;
|
|
404
414
|
for (var i = 0, il = renderables.length; i < il; ++i) {
|
|
405
415
|
var r = renderables[i];
|
|
@@ -428,22 +438,31 @@ var Renderer;
|
|
|
428
438
|
}
|
|
429
439
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
430
440
|
},
|
|
431
|
-
clearDepth: function () {
|
|
441
|
+
clearDepth: function (packed) {
|
|
442
|
+
if (packed === void 0) { packed = false; }
|
|
432
443
|
state.enable(gl.SCISSOR_TEST);
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
444
|
+
if (packed) {
|
|
445
|
+
state.colorMask(true, true, true, true);
|
|
446
|
+
state.clearColor(1, 1, 1, 1);
|
|
447
|
+
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
state.enable(gl.DEPTH_TEST);
|
|
451
|
+
state.depthMask(true);
|
|
452
|
+
gl.clear(gl.DEPTH_BUFFER_BIT);
|
|
453
|
+
}
|
|
436
454
|
},
|
|
437
455
|
update: update,
|
|
438
456
|
renderPick: renderPick,
|
|
439
457
|
renderDepth: renderDepth,
|
|
458
|
+
renderDepthOpaque: renderDepthOpaque,
|
|
459
|
+
renderDepthTransparent: renderDepthTransparent,
|
|
440
460
|
renderMarkingDepth: renderMarkingDepth,
|
|
441
461
|
renderMarkingMask: renderMarkingMask,
|
|
442
462
|
renderBlended: renderBlended,
|
|
443
463
|
renderBlendedOpaque: renderBlendedOpaque,
|
|
444
464
|
renderBlendedTransparent: renderBlendedTransparent,
|
|
445
|
-
|
|
446
|
-
renderBlendedVolumeTransparent: renderBlendedVolumeTransparent,
|
|
465
|
+
renderBlendedVolume: renderBlendedVolume,
|
|
447
466
|
renderWboitOpaque: renderWboitOpaque,
|
|
448
467
|
renderWboitTransparent: renderWboitTransparent,
|
|
449
468
|
setProps: function (props) {
|
|
@@ -27,6 +27,7 @@ interface Scene extends Object3D {
|
|
|
27
27
|
clear: () => void;
|
|
28
28
|
forEach: (callbackFn: (value: GraphicsRenderable, key: GraphicsRenderObject) => void) => void;
|
|
29
29
|
getMarkerAverage: () => number;
|
|
30
|
+
getOpacityAverage: () => number;
|
|
30
31
|
}
|
|
31
32
|
declare namespace Scene {
|
|
32
33
|
interface Group extends Object3D {
|
|
@@ -16,6 +16,7 @@ var array_1 = require("../mol-util/array");
|
|
|
16
16
|
var boundary_helper_1 = require("../mol-math/geometry/boundary-helper");
|
|
17
17
|
var util_1 = require("../mol-data/util");
|
|
18
18
|
var render_item_1 = require("./webgl/render-item");
|
|
19
|
+
var interpolate_1 = require("../mol-math/interpolate");
|
|
19
20
|
var boundaryHelper = new boundary_helper_1.BoundaryHelper('98');
|
|
20
21
|
function calculateBoundingSphere(renderables, boundingSphere, onlyVisible) {
|
|
21
22
|
boundaryHelper.reset();
|
|
@@ -221,14 +222,38 @@ var Scene;
|
|
|
221
222
|
getMarkerAverage: function () {
|
|
222
223
|
if (primitives.length === 0 && volumes.length === 0)
|
|
223
224
|
return 0;
|
|
225
|
+
var count = 0;
|
|
224
226
|
var markerAverage = 0;
|
|
225
227
|
for (var i = 0, il = primitives.length; i < il; ++i) {
|
|
228
|
+
if (!primitives[i].state.visible)
|
|
229
|
+
continue;
|
|
226
230
|
markerAverage += primitives[i].values.markerAverage.ref.value;
|
|
231
|
+
count += 1;
|
|
227
232
|
}
|
|
228
233
|
for (var i = 0, il = volumes.length; i < il; ++i) {
|
|
234
|
+
if (!volumes[i].state.visible)
|
|
235
|
+
continue;
|
|
229
236
|
markerAverage += volumes[i].values.markerAverage.ref.value;
|
|
237
|
+
count += 1;
|
|
230
238
|
}
|
|
231
|
-
return markerAverage /
|
|
239
|
+
return count > 0 ? markerAverage / count : 0;
|
|
240
|
+
},
|
|
241
|
+
getOpacityAverage: function () {
|
|
242
|
+
if (primitives.length === 0)
|
|
243
|
+
return 0;
|
|
244
|
+
var count = 0;
|
|
245
|
+
var opacityAverage = 0;
|
|
246
|
+
for (var i = 0, il = primitives.length; i < il; ++i) {
|
|
247
|
+
var p = primitives[i];
|
|
248
|
+
if (!p.state.visible)
|
|
249
|
+
continue;
|
|
250
|
+
// TODO: simplify, handle in renderable.state???
|
|
251
|
+
// uAlpha is updated in "render" so we need to recompute it here
|
|
252
|
+
var alpha = (0, interpolate_1.clamp)(p.values.alpha.ref.value * p.state.alphaFactor, 0, 1);
|
|
253
|
+
opacityAverage += (1 - p.values.transparencyAverage.ref.value) * alpha;
|
|
254
|
+
count += 1;
|
|
255
|
+
}
|
|
256
|
+
return count > 0 ? opacityAverage / count : 0;
|
|
232
257
|
},
|
|
233
258
|
};
|
|
234
259
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const apply_interior_color = "\nif (interior) {\n if (uInteriorColorFlag) {\n gl_FragColor.rgb = uInteriorColor;\n } else {\n gl_FragColor.rgb *= 1.0 - uInteriorDarkening;\n }\n\n #ifdef
|
|
1
|
+
export declare const apply_interior_color = "\nif (interior) {\n if (uInteriorColorFlag) {\n gl_FragColor.rgb = uInteriorColor;\n } else {\n gl_FragColor.rgb *= 1.0 - uInteriorDarkening;\n }\n\n #ifdef dTransparentBackfaces_opaque\n gl_FragColor.a = 1.0;\n #endif\n}\n";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.apply_interior_color = void 0;
|
|
4
|
-
exports.apply_interior_color = "\nif (interior) {\n if (uInteriorColorFlag) {\n gl_FragColor.rgb = uInteriorColor;\n } else {\n gl_FragColor.rgb *= 1.0 - uInteriorDarkening;\n }\n\n #ifdef
|
|
4
|
+
exports.apply_interior_color = "\nif (interior) {\n if (uInteriorColorFlag) {\n gl_FragColor.rgb = uInteriorColor;\n } else {\n gl_FragColor.rgb *= 1.0 - uInteriorDarkening;\n }\n\n #ifdef dTransparentBackfaces_opaque\n gl_FragColor.a = 1.0;\n #endif\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const assign_material_color = "\n#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)\n float marker = uMarker;\n if (uMarker == -1.0) {\n marker = floor(vMarker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n#endif\n\n#if defined(dRenderVariant_color)\n #if defined(dUsePalette)\n vec4 material = vec4(texture2D(tPalette, vec2(vPaletteV, 0.5)).rgb, uAlpha);\n #elif defined(dColorType_uniform)\n vec4 material = vec4(uColor, uAlpha);\n #elif defined(dColorType_varying)\n vec4 material = vec4(vColor.rgb, uAlpha);\n #endif\n\n // mix material with overpaint\n #if defined(dOverpaint)\n material.rgb = mix(material.rgb, vOverpaint.rgb, vOverpaint.a);\n #endif\n\n float metalness = uMetalness;\n float roughness = uRoughness;\n float bumpiness = uBumpiness;\n #ifdef dSubstance\n metalness = mix(metalness, vSubstance.r, vSubstance.a);\n roughness = mix(roughness, vSubstance.g, vSubstance.a);\n bumpiness = mix(bumpiness, vSubstance.b, vSubstance.a);\n #endif\n#elif defined(dRenderVariant_pick)\n vec4 material = vColor;\n#elif defined(dRenderVariant_depth)\n #
|
|
1
|
+
export declare const assign_material_color = "\n#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)\n float marker = uMarker;\n if (uMarker == -1.0) {\n marker = floor(vMarker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n#endif\n\n#if defined(dRenderVariant_color)\n #if defined(dUsePalette)\n vec4 material = vec4(texture2D(tPalette, vec2(vPaletteV, 0.5)).rgb, uAlpha);\n #elif defined(dColorType_uniform)\n vec4 material = vec4(uColor, uAlpha);\n #elif defined(dColorType_varying)\n vec4 material = vec4(vColor.rgb, uAlpha);\n #endif\n\n // mix material with overpaint\n #if defined(dOverpaint)\n material.rgb = mix(material.rgb, vOverpaint.rgb, vOverpaint.a);\n #endif\n\n float metalness = uMetalness;\n float roughness = uRoughness;\n float bumpiness = uBumpiness;\n #ifdef dSubstance\n metalness = mix(metalness, vSubstance.r, vSubstance.a);\n roughness = mix(roughness, vSubstance.g, vSubstance.a);\n bumpiness = mix(bumpiness, vSubstance.b, vSubstance.a);\n #endif\n#elif defined(dRenderVariant_pick)\n vec4 material = vColor;\n#elif defined(dRenderVariant_depth)\n if (fragmentDepth > getDepth(gl_FragCoord.xy / uDrawingBufferSize)) {\n discard;\n }\n\n #ifndef dXrayShaded\n #if defined(dTransparency)\n float dta = 1.0 - vTransparency;\n if (vTransparency < 0.2) dta = 1.0; // hard cutoff looks better\n\n if (uRenderMask == MaskTransparent && uAlpha * dta == 1.0) {\n discard;\n } else if (uRenderMask == MaskOpaque && uAlpha * dta < 1.0) {\n discard;\n }\n #else\n if (uRenderMask == MaskTransparent && uAlpha == 1.0) {\n discard;\n } else if (uRenderMask == MaskOpaque && uAlpha < 1.0) {\n discard;\n }\n #endif\n #else\n if (uRenderMask == MaskOpaque) {\n discard;\n }\n #endif\n\n vec4 material = packDepthToRGBA(fragmentDepth);\n#elif defined(dRenderVariant_marking)\n vec4 material;\n if(uMarkingType == 1) {\n if (marker > 0.0)\n discard;\n #ifdef enabledFragDepth\n material = packDepthToRGBA(gl_FragDepthEXT);\n #else\n material = packDepthToRGBA(gl_FragCoord.z);\n #endif\n } else {\n if (marker == 0.0)\n discard;\n float depthTest = 1.0;\n if (uMarkingDepthTest) {\n depthTest = (fragmentDepth >= getDepthPacked(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;\n }\n bool isHighlight = intMod(marker, 2.0) > 0.1;\n float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);\n float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));\n if (fogFactor == 1.0)\n discard;\n material = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0 - fogFactor);\n }\n#endif\n\n// apply per-group transparency\n#if defined(dTransparency) && (defined(dRenderVariant_pick) || defined(dRenderVariant_color))\n float ta = 1.0 - vTransparency;\n if (vTransparency < 0.2) ta = 1.0; // hard cutoff looks better\n\n #if defined(dRenderVariant_pick)\n if (ta < uPickingAlphaThreshold)\n discard; // ignore so the element below can be picked\n #elif defined(dRenderVariant_color)\n material.a *= ta;\n\n #if defined(dRenderVariant_colorBlended)\n #if defined(dTransparentBackfaces_off)\n if ((uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0) ||\n (interior && material.a < 1.0)\n ) {\n discard;\n }\n #elif defined(dTransparentBackfaces_on)\n if ((uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0)\n ) {\n discard;\n }\n #elif defined(dTransparentBackfaces_opaque)\n if (interior) {\n material.a = 1.0;\n } else if (\n (uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0)\n ) {\n discard;\n }\n #endif\n #endif\n #endif\n#endif\n";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assign_material_color = void 0;
|
|
4
|
-
exports.assign_material_color = "\n#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)\n float marker = uMarker;\n if (uMarker == -1.0) {\n marker = floor(vMarker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n#endif\n\n#if defined(dRenderVariant_color)\n #if defined(dUsePalette)\n vec4 material = vec4(texture2D(tPalette, vec2(vPaletteV, 0.5)).rgb, uAlpha);\n #elif defined(dColorType_uniform)\n vec4 material = vec4(uColor, uAlpha);\n #elif defined(dColorType_varying)\n vec4 material = vec4(vColor.rgb, uAlpha);\n #endif\n\n // mix material with overpaint\n #if defined(dOverpaint)\n material.rgb = mix(material.rgb, vOverpaint.rgb, vOverpaint.a);\n #endif\n\n float metalness = uMetalness;\n float roughness = uRoughness;\n float bumpiness = uBumpiness;\n #ifdef dSubstance\n metalness = mix(metalness, vSubstance.r, vSubstance.a);\n roughness = mix(roughness, vSubstance.g, vSubstance.a);\n bumpiness = mix(bumpiness, vSubstance.b, vSubstance.a);\n #endif\n#elif defined(dRenderVariant_pick)\n vec4 material = vColor;\n#elif defined(dRenderVariant_depth)\n #
|
|
4
|
+
exports.assign_material_color = "\n#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)\n float marker = uMarker;\n if (uMarker == -1.0) {\n marker = floor(vMarker * 255.0 + 0.5); // rounding required to work on some cards on win\n }\n#endif\n\n#if defined(dRenderVariant_color)\n #if defined(dUsePalette)\n vec4 material = vec4(texture2D(tPalette, vec2(vPaletteV, 0.5)).rgb, uAlpha);\n #elif defined(dColorType_uniform)\n vec4 material = vec4(uColor, uAlpha);\n #elif defined(dColorType_varying)\n vec4 material = vec4(vColor.rgb, uAlpha);\n #endif\n\n // mix material with overpaint\n #if defined(dOverpaint)\n material.rgb = mix(material.rgb, vOverpaint.rgb, vOverpaint.a);\n #endif\n\n float metalness = uMetalness;\n float roughness = uRoughness;\n float bumpiness = uBumpiness;\n #ifdef dSubstance\n metalness = mix(metalness, vSubstance.r, vSubstance.a);\n roughness = mix(roughness, vSubstance.g, vSubstance.a);\n bumpiness = mix(bumpiness, vSubstance.b, vSubstance.a);\n #endif\n#elif defined(dRenderVariant_pick)\n vec4 material = vColor;\n#elif defined(dRenderVariant_depth)\n if (fragmentDepth > getDepth(gl_FragCoord.xy / uDrawingBufferSize)) {\n discard;\n }\n\n #ifndef dXrayShaded\n #if defined(dTransparency)\n float dta = 1.0 - vTransparency;\n if (vTransparency < 0.2) dta = 1.0; // hard cutoff looks better\n\n if (uRenderMask == MaskTransparent && uAlpha * dta == 1.0) {\n discard;\n } else if (uRenderMask == MaskOpaque && uAlpha * dta < 1.0) {\n discard;\n }\n #else\n if (uRenderMask == MaskTransparent && uAlpha == 1.0) {\n discard;\n } else if (uRenderMask == MaskOpaque && uAlpha < 1.0) {\n discard;\n }\n #endif\n #else\n if (uRenderMask == MaskOpaque) {\n discard;\n }\n #endif\n\n vec4 material = packDepthToRGBA(fragmentDepth);\n#elif defined(dRenderVariant_marking)\n vec4 material;\n if(uMarkingType == 1) {\n if (marker > 0.0)\n discard;\n #ifdef enabledFragDepth\n material = packDepthToRGBA(gl_FragDepthEXT);\n #else\n material = packDepthToRGBA(gl_FragCoord.z);\n #endif\n } else {\n if (marker == 0.0)\n discard;\n float depthTest = 1.0;\n if (uMarkingDepthTest) {\n depthTest = (fragmentDepth >= getDepthPacked(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;\n }\n bool isHighlight = intMod(marker, 2.0) > 0.1;\n float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);\n float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));\n if (fogFactor == 1.0)\n discard;\n material = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0 - fogFactor);\n }\n#endif\n\n// apply per-group transparency\n#if defined(dTransparency) && (defined(dRenderVariant_pick) || defined(dRenderVariant_color))\n float ta = 1.0 - vTransparency;\n if (vTransparency < 0.2) ta = 1.0; // hard cutoff looks better\n\n #if defined(dRenderVariant_pick)\n if (ta < uPickingAlphaThreshold)\n discard; // ignore so the element below can be picked\n #elif defined(dRenderVariant_color)\n material.a *= ta;\n\n #if defined(dRenderVariant_colorBlended)\n #if defined(dTransparentBackfaces_off)\n if ((uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0) ||\n (interior && material.a < 1.0)\n ) {\n discard;\n }\n #elif defined(dTransparentBackfaces_on)\n if ((uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0)\n ) {\n discard;\n }\n #elif defined(dTransparentBackfaces_opaque)\n if (interior) {\n material.a = 1.0;\n } else if (\n (uRenderMask == MaskOpaque && material.a < 1.0) ||\n (uRenderMask == MaskTransparent && material.a == 1.0)\n ) {\n discard;\n }\n #endif\n #endif\n #endif\n#endif\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const check_picking_alpha = "\nfloat viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);\nfloat fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));\nfloat alpha = (1.0 - fogFactor) * uAlpha;\n// if not opaque enough ignore so the element below can be picked\nif (uAlpha < uPickingAlphaThreshold || alpha < 0.1) {\n #ifdef
|
|
1
|
+
export declare const check_picking_alpha = "\nfloat viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);\nfloat fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));\nfloat alpha = (1.0 - fogFactor) * uAlpha;\n// if not opaque enough ignore so the element below can be picked\nif (uAlpha < uPickingAlphaThreshold || alpha < 0.1) {\n #ifdef dTransparentBackfaces_opaque\n if (!interior) discard;\n #else\n discard;\n #endif\n}\n";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.check_picking_alpha = void 0;
|
|
4
|
-
exports.check_picking_alpha = "\nfloat viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);\nfloat fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));\nfloat alpha = (1.0 - fogFactor) * uAlpha;\n// if not opaque enough ignore so the element below can be picked\nif (uAlpha < uPickingAlphaThreshold || alpha < 0.1) {\n #ifdef
|
|
4
|
+
exports.check_picking_alpha = "\nfloat viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);\nfloat fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));\nfloat alpha = (1.0 - fogFactor) * uAlpha;\n// if not opaque enough ignore so the element below can be picked\nif (uAlpha < uPickingAlphaThreshold || alpha < 0.1) {\n #ifdef dTransparentBackfaces_opaque\n if (!interior) discard;\n #else\n discard;\n #endif\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const common_frag_params = "\nuniform int uObjectId;\nuniform int uInstanceCount;\nuniform int uGroupCount;\n\nuniform int uPickType;\nuniform int uMarkingType;\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\n #if defined(dClipping)\n #if __VERSION__ == 100\n varying float vClipping;\n #else\n flat in float vClipping;\n #endif\n #endif\n#endif\n\nuniform vec3 uHighlightColor;\nuniform vec3 uSelectColor;\nuniform float uHighlightStrength;\nuniform float uSelectStrength;\nuniform int uMarkerPriority;\n\n#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)\n uniform float uMarker;\n #if __VERSION__ == 100\n varying float vMarker;\n #else\n flat in float vMarker;\n #endif\n#endif\n\nvarying vec3 vModelPosition;\nvarying vec3 vViewPosition;\n\nuniform vec2 uViewOffset;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uIsOrtho;\n\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\n\nuniform float uAlpha;\nuniform float uPickingAlphaThreshold;\nuniform bool uTransparentBackground;\n\nuniform bool uDoubleSided;\nuniform float uInteriorDarkening;\nuniform bool uInteriorColorFlag;\nuniform vec3 uInteriorColor;\nbool interior;\n\nuniform float uXrayEdgeFalloff;\n\nuniform mat4 uProjection;\n\nuniform
|
|
1
|
+
export declare const common_frag_params = "\nuniform int uObjectId;\nuniform int uInstanceCount;\nuniform int uGroupCount;\n\nuniform int uPickType;\nuniform int uMarkingType;\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\n #if defined(dClipping)\n #if __VERSION__ == 100\n varying float vClipping;\n #else\n flat in float vClipping;\n #endif\n #endif\n#endif\n\nuniform vec3 uHighlightColor;\nuniform vec3 uSelectColor;\nuniform float uHighlightStrength;\nuniform float uSelectStrength;\nuniform int uMarkerPriority;\n\n#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)\n uniform float uMarker;\n #if __VERSION__ == 100\n varying float vMarker;\n #else\n flat in float vMarker;\n #endif\n#endif\n\nvarying vec3 vModelPosition;\nvarying vec3 vViewPosition;\n\nuniform vec2 uViewOffset;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uIsOrtho;\n\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\n\nuniform float uAlpha;\nuniform float uPickingAlphaThreshold;\nuniform bool uTransparentBackground;\n\nuniform bool uDoubleSided;\nuniform float uInteriorDarkening;\nuniform bool uInteriorColorFlag;\nuniform vec3 uInteriorColor;\nbool interior;\n\nuniform float uXrayEdgeFalloff;\n\nuniform mat4 uProjection;\n\nuniform int uRenderMask;\nuniform bool uMarkingDepthTest;\n\nuniform sampler2D tDepth;\nuniform vec2 uDrawingBufferSize;\n\nfloat getDepthPacked(const in vec2 coords) {\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n}\n\nfloat getDepth(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepth, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n #endif\n}\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\n// \"Bump Mapping Unparametrized Surfaces on the GPU\" Morten S. Mikkelsen\n// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf\nvec3 perturbNormal(in vec3 position, in vec3 normal, in float height, in float scale) {\n vec3 sigmaS = dFdx(position);\n vec3 sigmaT = dFdy(position);\n\n vec3 r1 = cross(sigmaT, normal);\n vec3 r2 = cross(normal, sigmaS);\n float det = dot(sigmaS, r1);\n\n float bs = dFdx(height);\n float bt = dFdy(height);\n\n vec3 surfGrad = sign(det) * (bs * r1 + bt * r2);\n return normalize(abs(det) * normal - scale * surfGrad);\n}\n\nfloat hash(in float h) {\n return fract(sin(h) * 43758.5453123);\n}\n\nfloat noise(in vec3 x) {\n vec3 p = floor(x);\n vec3 f = fract(x);\n f = f * f * (3.0 - 2.0 * f);\n\n float n = p.x + p.y * 157.0 + 113.0 * p.z;\n return mix(\n mix(mix(hash(n + 0.0), hash(n + 1.0), f.x),\n mix(hash(n + 157.0), hash(n + 158.0), f.x), f.y),\n mix(mix(hash(n + 113.0), hash(n + 114.0), f.x),\n mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z);\n}\n\nfloat fbm(in vec3 p) {\n float f = 0.0;\n f += 0.5 * noise(p);\n p *= 2.01;\n f += 0.25 * noise(p);\n p *= 2.02;\n f += 0.125 * noise(p);\n\n return f;\n}\n";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.common_frag_params = void 0;
|
|
4
|
-
exports.common_frag_params = "\nuniform int uObjectId;\nuniform int uInstanceCount;\nuniform int uGroupCount;\n\nuniform int uPickType;\nuniform int uMarkingType;\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\n #if defined(dClipping)\n #if __VERSION__ == 100\n varying float vClipping;\n #else\n flat in float vClipping;\n #endif\n #endif\n#endif\n\nuniform vec3 uHighlightColor;\nuniform vec3 uSelectColor;\nuniform float uHighlightStrength;\nuniform float uSelectStrength;\nuniform int uMarkerPriority;\n\n#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)\n uniform float uMarker;\n #if __VERSION__ == 100\n varying float vMarker;\n #else\n flat in float vMarker;\n #endif\n#endif\n\nvarying vec3 vModelPosition;\nvarying vec3 vViewPosition;\n\nuniform vec2 uViewOffset;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uIsOrtho;\n\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\n\nuniform float uAlpha;\nuniform float uPickingAlphaThreshold;\nuniform bool uTransparentBackground;\n\nuniform bool uDoubleSided;\nuniform float uInteriorDarkening;\nuniform bool uInteriorColorFlag;\nuniform vec3 uInteriorColor;\nbool interior;\n\nuniform float uXrayEdgeFalloff;\n\nuniform mat4 uProjection;\n\nuniform
|
|
4
|
+
exports.common_frag_params = "\nuniform int uObjectId;\nuniform int uInstanceCount;\nuniform int uGroupCount;\n\nuniform int uPickType;\nuniform int uMarkingType;\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\n #if defined(dClipping)\n #if __VERSION__ == 100\n varying float vClipping;\n #else\n flat in float vClipping;\n #endif\n #endif\n#endif\n\nuniform vec3 uHighlightColor;\nuniform vec3 uSelectColor;\nuniform float uHighlightStrength;\nuniform float uSelectStrength;\nuniform int uMarkerPriority;\n\n#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)\n uniform float uMarker;\n #if __VERSION__ == 100\n varying float vMarker;\n #else\n flat in float vMarker;\n #endif\n#endif\n\nvarying vec3 vModelPosition;\nvarying vec3 vViewPosition;\n\nuniform vec2 uViewOffset;\n\nuniform float uNear;\nuniform float uFar;\nuniform float uIsOrtho;\n\nuniform float uFogNear;\nuniform float uFogFar;\nuniform vec3 uFogColor;\n\nuniform float uAlpha;\nuniform float uPickingAlphaThreshold;\nuniform bool uTransparentBackground;\n\nuniform bool uDoubleSided;\nuniform float uInteriorDarkening;\nuniform bool uInteriorColorFlag;\nuniform vec3 uInteriorColor;\nbool interior;\n\nuniform float uXrayEdgeFalloff;\n\nuniform mat4 uProjection;\n\nuniform int uRenderMask;\nuniform bool uMarkingDepthTest;\n\nuniform sampler2D tDepth;\nuniform vec2 uDrawingBufferSize;\n\nfloat getDepthPacked(const in vec2 coords) {\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n}\n\nfloat getDepth(const in vec2 coords) {\n #ifdef depthTextureSupport\n return texture2D(tDepth, coords).r;\n #else\n return unpackRGBAToDepth(texture2D(tDepth, coords));\n #endif\n}\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\n// \"Bump Mapping Unparametrized Surfaces on the GPU\" Morten S. Mikkelsen\n// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf\nvec3 perturbNormal(in vec3 position, in vec3 normal, in float height, in float scale) {\n vec3 sigmaS = dFdx(position);\n vec3 sigmaT = dFdy(position);\n\n vec3 r1 = cross(sigmaT, normal);\n vec3 r2 = cross(normal, sigmaS);\n float det = dot(sigmaS, r1);\n\n float bs = dFdx(height);\n float bt = dFdy(height);\n\n vec3 surfGrad = sign(det) * (bs * r1 + bt * r2);\n return normalize(abs(det) * normal - scale * surfGrad);\n}\n\nfloat hash(in float h) {\n return fract(sin(h) * 43758.5453123);\n}\n\nfloat noise(in vec3 x) {\n vec3 p = floor(x);\n vec3 f = fract(x);\n f = f * f * (3.0 - 2.0 * f);\n\n float n = p.x + p.y * 157.0 + 113.0 * p.z;\n return mix(\n mix(mix(hash(n + 0.0), hash(n + 1.0), f.x),\n mix(hash(n + 157.0), hash(n + 158.0), f.x), f.y),\n mix(mix(hash(n + 113.0), hash(n + 114.0), f.x),\n mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z);\n}\n\nfloat fbm(in vec3 p) {\n float f = 0.0;\n f += 0.5 * noise(p);\n p *= 2.01;\n f += 0.25 * noise(p);\n p *= 2.02;\n f += 0.125 * noise(p);\n\n return f;\n}\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const common = "\n// TODO find a better place for these convenience defines\n\n#if defined(dRenderVariant_colorBlended) || defined(dRenderVariant_colorWboit)\n #define dRenderVariant_color\n#endif\n\n#if defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance) || defined(dColorType_vertex) || defined(dColorType_vertexInstance)\n #define dColorType_texture\n#endif\n\n#if defined(dColorType_volume) || defined(dColorType_volumeInstance)\n #define dColorType_grid\n#endif\n\n#if defined(dColorType_attribute) || defined(dColorType_texture) || defined(dColorType_grid)\n #define dColorType_varying\n#endif\n\n//\n\n#define PI 3.14159265\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n\n#define saturate(a) clamp(a, 0.0, 1.0)\n\n#if __VERSION__ == 100\n #define round(x) floor((x) + 0.5)\n#endif\n\nfloat intDiv(const in float a, const in float b) { return float(int(a) / int(b)); }\nvec2 ivec2Div(const in vec2 a, const in vec2 b) { return vec2(ivec2(a) / ivec2(b)); }\nfloat intMod(const in float a, const in float b) { return a - b * float(int(a) / int(b)); }\nint imod(const in int a, const in int b) { return a - b * (a / b); }\n\nfloat pow2(const in float x) { return x * x; }\n\nvec3 packIntToRGB(in float value) {\n value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0;\n vec3 c = vec3(0.0);\n c.b = mod(value, 256.0);\n value = floor(value / 256.0);\n c.g = mod(value, 256.0);\n value = floor(value / 256.0);\n c.r = mod(value, 256.0);\n return c / 255.0;\n}\nfloat unpackRGBToInt(const in vec3 rgb) {\n return (floor(rgb.r * 255.0 + 0.5) * 256.0 * 256.0 + floor(rgb.g * 255.0 + 0.5) * 256.0 + floor(rgb.b * 255.0 + 0.5)) - 1.0;\n}\n\nvec2 packUnitIntervalToRG(const in float v) {\n vec2 enc;\n enc.xy = vec2(fract(v * 256.0), v);\n enc.y -= enc.x * (1.0 / 256.0);\n enc.xy *= 256.0 / 255.0;\n\n return enc;\n}\n\nfloat unpackRGToUnitInterval(const in vec2 enc) {\n return dot(enc, vec2(255.0 / (256.0 * 256.0), 255.0 / 256.0));\n}\n\nvec3 screenSpaceToViewSpace(const in vec3 ssPos, const in mat4 invProjection) {\n vec4 p = vec4(ssPos * 2.0 - 1.0, 1.0);\n p = invProjection * p;\n return p.xyz / p.w;\n}\n\nconst float PackUpscale = 256.0 / 255.0; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255.0 / 256.0; // 0..1 -> fraction (excluding 1)\nconst vec3 PackFactors = vec3(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0);\nconst vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.0);\nconst float ShiftRight8 = 1.0 / 256.0;\n\nvec4 packDepthToRGBA(const in float v) {\n vec4 r = vec4(fract(v * PackFactors), v);\n r.yzw -= r.xyz * ShiftRight8; // tidy overflow\n return r * PackUpscale;\n}\nfloat unpackRGBAToDepth(const in vec4 v) {\n return dot(v, UnpackFactors);\n}\n\nvec4 sRGBToLinear(const in vec4 c) {\n return vec4(mix(pow(c.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), c.rgb * 0.0773993808, vec3(lessThanEqual(c.rgb, vec3(0.04045)))), c.a);\n}\nvec4 linearTosRGB(const in vec4 c) {\n return vec4(mix(pow(c.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), c.rgb * 12.92, vec3(lessThanEqual(c.rgb, vec3(0.0031308)))), c.a);\n}\n\nfloat linearizeDepth(const in float depth, const in float near, const in float far) {\n return (2.0 * near) / (far + near - depth * (far - near));\n}\n\nfloat perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {\n return (near * far) / ((far - near) * invClipZ - far);\n}\n\nfloat orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {\n return linearClipZ * (near - far) - near;\n}\n\nfloat depthToViewZ(const in float isOrtho, const in float linearClipZ, const in float near, const in float far) {\n return isOrtho == 1.0 ? orthographicDepthToViewZ(linearClipZ, near, far) : perspectiveDepthToViewZ(linearClipZ, near, far);\n}\n\n#if __VERSION__ == 100\n // transpose\n\n float transpose(const in float m) {\n return m;\n }\n\n mat2 transpose2(const in mat2 m) {\n return mat2(\n m[0][0], m[1][0],\n m[0][1], m[1][1]\n );\n }\n\n mat3 transpose3(const in mat3 m) {\n return mat3(\n m[0][0], m[1][0], m[2][0],\n m[0][1], m[1][1], m[2][1],\n m[0][2], m[1][2], m[2][2]\n );\n }\n\n mat4 transpose4(const in mat4 m) {\n return mat4(\n m[0][0], m[1][0], m[2][0], m[3][0],\n m[0][1], m[1][1], m[2][1], m[3][1],\n m[0][2], m[1][2], m[2][2], m[3][2],\n m[0][3], m[1][3], m[2][3], m[3][3]\n );\n }\n\n // inverse\n\n float inverse(const in float m) {\n return 1.0 / m;\n }\n\n mat2 inverse2(const in mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n }\n\n mat3 inverse3(const in mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n }\n\n mat4 inverse4(const in mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n }\n\n #define isNaN(x) ((x) != (x))\n #define isInf(x) ((x) == (x) + 1.0)\n#else\n #define transpose2(m) transpose(m)\n #define transpose3(m) transpose(m)\n #define transpose4(m) transpose(m)\n\n #define inverse2(m) inverse(m)\n #define inverse3(m) inverse(m)\n #define inverse4(m) inverse(m)\n\n #define isNaN isnan\n #define isInf isinf\n#endif\n";
|
|
1
|
+
export declare const common = "\n// TODO find a better place for these convenience defines\n\n#if defined(dRenderVariant_colorBlended) || defined(dRenderVariant_colorWboit)\n #define dRenderVariant_color\n#endif\n\n#if defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance) || defined(dColorType_vertex) || defined(dColorType_vertexInstance)\n #define dColorType_texture\n#endif\n\n#if defined(dColorType_volume) || defined(dColorType_volumeInstance)\n #define dColorType_grid\n#endif\n\n#if defined(dColorType_attribute) || defined(dColorType_texture) || defined(dColorType_grid)\n #define dColorType_varying\n#endif\n\n#define MaskAll 0\n#define MaskOpaque 1\n#define MaskTransparent 2\n\n//\n\n#define PI 3.14159265\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n\n#define saturate(a) clamp(a, 0.0, 1.0)\n\n#if __VERSION__ == 100\n #define round(x) floor((x) + 0.5)\n#endif\n\nfloat intDiv(const in float a, const in float b) { return float(int(a) / int(b)); }\nvec2 ivec2Div(const in vec2 a, const in vec2 b) { return vec2(ivec2(a) / ivec2(b)); }\nfloat intMod(const in float a, const in float b) { return a - b * float(int(a) / int(b)); }\nint imod(const in int a, const in int b) { return a - b * (a / b); }\n\nfloat pow2(const in float x) { return x * x; }\n\nvec3 packIntToRGB(in float value) {\n value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0;\n vec3 c = vec3(0.0);\n c.b = mod(value, 256.0);\n value = floor(value / 256.0);\n c.g = mod(value, 256.0);\n value = floor(value / 256.0);\n c.r = mod(value, 256.0);\n return c / 255.0;\n}\nfloat unpackRGBToInt(const in vec3 rgb) {\n return (floor(rgb.r * 255.0 + 0.5) * 256.0 * 256.0 + floor(rgb.g * 255.0 + 0.5) * 256.0 + floor(rgb.b * 255.0 + 0.5)) - 1.0;\n}\n\nvec2 packUnitIntervalToRG(const in float v) {\n vec2 enc;\n enc.xy = vec2(fract(v * 256.0), v);\n enc.y -= enc.x * (1.0 / 256.0);\n enc.xy *= 256.0 / 255.0;\n\n return enc;\n}\n\nfloat unpackRGToUnitInterval(const in vec2 enc) {\n return dot(enc, vec2(255.0 / (256.0 * 256.0), 255.0 / 256.0));\n}\n\nvec3 screenSpaceToViewSpace(const in vec3 ssPos, const in mat4 invProjection) {\n vec4 p = vec4(ssPos * 2.0 - 1.0, 1.0);\n p = invProjection * p;\n return p.xyz / p.w;\n}\n\nconst float PackUpscale = 256.0 / 255.0; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255.0 / 256.0; // 0..1 -> fraction (excluding 1)\nconst vec3 PackFactors = vec3(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0);\nconst vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.0);\nconst float ShiftRight8 = 1.0 / 256.0;\n\nvec4 packDepthToRGBA(const in float v) {\n vec4 r = vec4(fract(v * PackFactors), v);\n r.yzw -= r.xyz * ShiftRight8; // tidy overflow\n return r * PackUpscale;\n}\nfloat unpackRGBAToDepth(const in vec4 v) {\n return dot(v, UnpackFactors);\n}\n\nvec4 sRGBToLinear(const in vec4 c) {\n return vec4(mix(pow(c.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), c.rgb * 0.0773993808, vec3(lessThanEqual(c.rgb, vec3(0.04045)))), c.a);\n}\nvec4 linearTosRGB(const in vec4 c) {\n return vec4(mix(pow(c.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), c.rgb * 12.92, vec3(lessThanEqual(c.rgb, vec3(0.0031308)))), c.a);\n}\n\nfloat linearizeDepth(const in float depth, const in float near, const in float far) {\n return (2.0 * near) / (far + near - depth * (far - near));\n}\n\nfloat perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {\n return (near * far) / ((far - near) * invClipZ - far);\n}\n\nfloat orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {\n return linearClipZ * (near - far) - near;\n}\n\nfloat depthToViewZ(const in float isOrtho, const in float linearClipZ, const in float near, const in float far) {\n return isOrtho == 1.0 ? orthographicDepthToViewZ(linearClipZ, near, far) : perspectiveDepthToViewZ(linearClipZ, near, far);\n}\n\n#if __VERSION__ == 100\n // transpose\n\n float transpose(const in float m) {\n return m;\n }\n\n mat2 transpose2(const in mat2 m) {\n return mat2(\n m[0][0], m[1][0],\n m[0][1], m[1][1]\n );\n }\n\n mat3 transpose3(const in mat3 m) {\n return mat3(\n m[0][0], m[1][0], m[2][0],\n m[0][1], m[1][1], m[2][1],\n m[0][2], m[1][2], m[2][2]\n );\n }\n\n mat4 transpose4(const in mat4 m) {\n return mat4(\n m[0][0], m[1][0], m[2][0], m[3][0],\n m[0][1], m[1][1], m[2][1], m[3][1],\n m[0][2], m[1][2], m[2][2], m[3][2],\n m[0][3], m[1][3], m[2][3], m[3][3]\n );\n }\n\n // inverse\n\n float inverse(const in float m) {\n return 1.0 / m;\n }\n\n mat2 inverse2(const in mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n }\n\n mat3 inverse3(const in mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n }\n\n mat4 inverse4(const in mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n }\n\n #define isNaN(x) ((x) != (x))\n #define isInf(x) ((x) == (x) + 1.0)\n#else\n #define transpose2(m) transpose(m)\n #define transpose3(m) transpose(m)\n #define transpose4(m) transpose(m)\n\n #define inverse2(m) inverse(m)\n #define inverse3(m) inverse(m)\n #define inverse4(m) inverse(m)\n\n #define isNaN isnan\n #define isInf isinf\n#endif\n";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.common = void 0;
|
|
4
|
-
exports.common = "\n// TODO find a better place for these convenience defines\n\n#if defined(dRenderVariant_colorBlended) || defined(dRenderVariant_colorWboit)\n #define dRenderVariant_color\n#endif\n\n#if defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance) || defined(dColorType_vertex) || defined(dColorType_vertexInstance)\n #define dColorType_texture\n#endif\n\n#if defined(dColorType_volume) || defined(dColorType_volumeInstance)\n #define dColorType_grid\n#endif\n\n#if defined(dColorType_attribute) || defined(dColorType_texture) || defined(dColorType_grid)\n #define dColorType_varying\n#endif\n\n//\n\n#define PI 3.14159265\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n\n#define saturate(a) clamp(a, 0.0, 1.0)\n\n#if __VERSION__ == 100\n #define round(x) floor((x) + 0.5)\n#endif\n\nfloat intDiv(const in float a, const in float b) { return float(int(a) / int(b)); }\nvec2 ivec2Div(const in vec2 a, const in vec2 b) { return vec2(ivec2(a) / ivec2(b)); }\nfloat intMod(const in float a, const in float b) { return a - b * float(int(a) / int(b)); }\nint imod(const in int a, const in int b) { return a - b * (a / b); }\n\nfloat pow2(const in float x) { return x * x; }\n\nvec3 packIntToRGB(in float value) {\n value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0;\n vec3 c = vec3(0.0);\n c.b = mod(value, 256.0);\n value = floor(value / 256.0);\n c.g = mod(value, 256.0);\n value = floor(value / 256.0);\n c.r = mod(value, 256.0);\n return c / 255.0;\n}\nfloat unpackRGBToInt(const in vec3 rgb) {\n return (floor(rgb.r * 255.0 + 0.5) * 256.0 * 256.0 + floor(rgb.g * 255.0 + 0.5) * 256.0 + floor(rgb.b * 255.0 + 0.5)) - 1.0;\n}\n\nvec2 packUnitIntervalToRG(const in float v) {\n vec2 enc;\n enc.xy = vec2(fract(v * 256.0), v);\n enc.y -= enc.x * (1.0 / 256.0);\n enc.xy *= 256.0 / 255.0;\n\n return enc;\n}\n\nfloat unpackRGToUnitInterval(const in vec2 enc) {\n return dot(enc, vec2(255.0 / (256.0 * 256.0), 255.0 / 256.0));\n}\n\nvec3 screenSpaceToViewSpace(const in vec3 ssPos, const in mat4 invProjection) {\n vec4 p = vec4(ssPos * 2.0 - 1.0, 1.0);\n p = invProjection * p;\n return p.xyz / p.w;\n}\n\nconst float PackUpscale = 256.0 / 255.0; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255.0 / 256.0; // 0..1 -> fraction (excluding 1)\nconst vec3 PackFactors = vec3(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0);\nconst vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.0);\nconst float ShiftRight8 = 1.0 / 256.0;\n\nvec4 packDepthToRGBA(const in float v) {\n vec4 r = vec4(fract(v * PackFactors), v);\n r.yzw -= r.xyz * ShiftRight8; // tidy overflow\n return r * PackUpscale;\n}\nfloat unpackRGBAToDepth(const in vec4 v) {\n return dot(v, UnpackFactors);\n}\n\nvec4 sRGBToLinear(const in vec4 c) {\n return vec4(mix(pow(c.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), c.rgb * 0.0773993808, vec3(lessThanEqual(c.rgb, vec3(0.04045)))), c.a);\n}\nvec4 linearTosRGB(const in vec4 c) {\n return vec4(mix(pow(c.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), c.rgb * 12.92, vec3(lessThanEqual(c.rgb, vec3(0.0031308)))), c.a);\n}\n\nfloat linearizeDepth(const in float depth, const in float near, const in float far) {\n return (2.0 * near) / (far + near - depth * (far - near));\n}\n\nfloat perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {\n return (near * far) / ((far - near) * invClipZ - far);\n}\n\nfloat orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {\n return linearClipZ * (near - far) - near;\n}\n\nfloat depthToViewZ(const in float isOrtho, const in float linearClipZ, const in float near, const in float far) {\n return isOrtho == 1.0 ? orthographicDepthToViewZ(linearClipZ, near, far) : perspectiveDepthToViewZ(linearClipZ, near, far);\n}\n\n#if __VERSION__ == 100\n // transpose\n\n float transpose(const in float m) {\n return m;\n }\n\n mat2 transpose2(const in mat2 m) {\n return mat2(\n m[0][0], m[1][0],\n m[0][1], m[1][1]\n );\n }\n\n mat3 transpose3(const in mat3 m) {\n return mat3(\n m[0][0], m[1][0], m[2][0],\n m[0][1], m[1][1], m[2][1],\n m[0][2], m[1][2], m[2][2]\n );\n }\n\n mat4 transpose4(const in mat4 m) {\n return mat4(\n m[0][0], m[1][0], m[2][0], m[3][0],\n m[0][1], m[1][1], m[2][1], m[3][1],\n m[0][2], m[1][2], m[2][2], m[3][2],\n m[0][3], m[1][3], m[2][3], m[3][3]\n );\n }\n\n // inverse\n\n float inverse(const in float m) {\n return 1.0 / m;\n }\n\n mat2 inverse2(const in mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n }\n\n mat3 inverse3(const in mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n }\n\n mat4 inverse4(const in mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n }\n\n #define isNaN(x) ((x) != (x))\n #define isInf(x) ((x) == (x) + 1.0)\n#else\n #define transpose2(m) transpose(m)\n #define transpose3(m) transpose(m)\n #define transpose4(m) transpose(m)\n\n #define inverse2(m) inverse(m)\n #define inverse3(m) inverse(m)\n #define inverse4(m) inverse(m)\n\n #define isNaN isnan\n #define isInf isinf\n#endif\n";
|
|
4
|
+
exports.common = "\n// TODO find a better place for these convenience defines\n\n#if defined(dRenderVariant_colorBlended) || defined(dRenderVariant_colorWboit)\n #define dRenderVariant_color\n#endif\n\n#if defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance) || defined(dColorType_vertex) || defined(dColorType_vertexInstance)\n #define dColorType_texture\n#endif\n\n#if defined(dColorType_volume) || defined(dColorType_volumeInstance)\n #define dColorType_grid\n#endif\n\n#if defined(dColorType_attribute) || defined(dColorType_texture) || defined(dColorType_grid)\n #define dColorType_varying\n#endif\n\n#define MaskAll 0\n#define MaskOpaque 1\n#define MaskTransparent 2\n\n//\n\n#define PI 3.14159265\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n\n#define saturate(a) clamp(a, 0.0, 1.0)\n\n#if __VERSION__ == 100\n #define round(x) floor((x) + 0.5)\n#endif\n\nfloat intDiv(const in float a, const in float b) { return float(int(a) / int(b)); }\nvec2 ivec2Div(const in vec2 a, const in vec2 b) { return vec2(ivec2(a) / ivec2(b)); }\nfloat intMod(const in float a, const in float b) { return a - b * float(int(a) / int(b)); }\nint imod(const in int a, const in int b) { return a - b * (a / b); }\n\nfloat pow2(const in float x) { return x * x; }\n\nvec3 packIntToRGB(in float value) {\n value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0;\n vec3 c = vec3(0.0);\n c.b = mod(value, 256.0);\n value = floor(value / 256.0);\n c.g = mod(value, 256.0);\n value = floor(value / 256.0);\n c.r = mod(value, 256.0);\n return c / 255.0;\n}\nfloat unpackRGBToInt(const in vec3 rgb) {\n return (floor(rgb.r * 255.0 + 0.5) * 256.0 * 256.0 + floor(rgb.g * 255.0 + 0.5) * 256.0 + floor(rgb.b * 255.0 + 0.5)) - 1.0;\n}\n\nvec2 packUnitIntervalToRG(const in float v) {\n vec2 enc;\n enc.xy = vec2(fract(v * 256.0), v);\n enc.y -= enc.x * (1.0 / 256.0);\n enc.xy *= 256.0 / 255.0;\n\n return enc;\n}\n\nfloat unpackRGToUnitInterval(const in vec2 enc) {\n return dot(enc, vec2(255.0 / (256.0 * 256.0), 255.0 / 256.0));\n}\n\nvec3 screenSpaceToViewSpace(const in vec3 ssPos, const in mat4 invProjection) {\n vec4 p = vec4(ssPos * 2.0 - 1.0, 1.0);\n p = invProjection * p;\n return p.xyz / p.w;\n}\n\nconst float PackUpscale = 256.0 / 255.0; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255.0 / 256.0; // 0..1 -> fraction (excluding 1)\nconst vec3 PackFactors = vec3(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0);\nconst vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.0);\nconst float ShiftRight8 = 1.0 / 256.0;\n\nvec4 packDepthToRGBA(const in float v) {\n vec4 r = vec4(fract(v * PackFactors), v);\n r.yzw -= r.xyz * ShiftRight8; // tidy overflow\n return r * PackUpscale;\n}\nfloat unpackRGBAToDepth(const in vec4 v) {\n return dot(v, UnpackFactors);\n}\n\nvec4 sRGBToLinear(const in vec4 c) {\n return vec4(mix(pow(c.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), c.rgb * 0.0773993808, vec3(lessThanEqual(c.rgb, vec3(0.04045)))), c.a);\n}\nvec4 linearTosRGB(const in vec4 c) {\n return vec4(mix(pow(c.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), c.rgb * 12.92, vec3(lessThanEqual(c.rgb, vec3(0.0031308)))), c.a);\n}\n\nfloat linearizeDepth(const in float depth, const in float near, const in float far) {\n return (2.0 * near) / (far + near - depth * (far - near));\n}\n\nfloat perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {\n return (near * far) / ((far - near) * invClipZ - far);\n}\n\nfloat orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {\n return linearClipZ * (near - far) - near;\n}\n\nfloat depthToViewZ(const in float isOrtho, const in float linearClipZ, const in float near, const in float far) {\n return isOrtho == 1.0 ? orthographicDepthToViewZ(linearClipZ, near, far) : perspectiveDepthToViewZ(linearClipZ, near, far);\n}\n\n#if __VERSION__ == 100\n // transpose\n\n float transpose(const in float m) {\n return m;\n }\n\n mat2 transpose2(const in mat2 m) {\n return mat2(\n m[0][0], m[1][0],\n m[0][1], m[1][1]\n );\n }\n\n mat3 transpose3(const in mat3 m) {\n return mat3(\n m[0][0], m[1][0], m[2][0],\n m[0][1], m[1][1], m[2][1],\n m[0][2], m[1][2], m[2][2]\n );\n }\n\n mat4 transpose4(const in mat4 m) {\n return mat4(\n m[0][0], m[1][0], m[2][0], m[3][0],\n m[0][1], m[1][1], m[2][1], m[3][1],\n m[0][2], m[1][2], m[2][2], m[3][2],\n m[0][3], m[1][3], m[2][3], m[3][3]\n );\n }\n\n // inverse\n\n float inverse(const in float m) {\n return 1.0 / m;\n }\n\n mat2 inverse2(const in mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n }\n\n mat3 inverse3(const in mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n }\n\n mat4 inverse4(const in mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n }\n\n #define isNaN(x) ((x) != (x))\n #define isInf(x) ((x) == (x) + 1.0)\n#else\n #define transpose2(m) transpose(m)\n #define transpose3(m) transpose(m)\n #define transpose4(m) transpose(m)\n\n #define inverse2(m) inverse(m)\n #define inverse3(m) inverse(m)\n #define inverse4(m) inverse(m)\n\n #define isNaN isnan\n #define isInf isinf\n#endif\n";
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
5
5
|
* @author Áron Samuel Kovács <aron.kovacs@mail.muni.cz>
|
|
6
6
|
*/
|
|
7
|
-
export declare const wboit_write = "\n#if defined(dRenderVariant_colorWboit)\n if (
|
|
7
|
+
export declare const wboit_write = "\n#if defined(dRenderVariant_colorWboit)\n if (uRenderMask == MaskOpaque) {\n if (preFogAlpha < 1.0) {\n discard;\n }\n } else if (uRenderMask == MaskTransparent) {\n // the 'fragmentDepth > 0.99' check is to handle precision issues with packed depth\n if (preFogAlpha != 1.0 && (fragmentDepth < getDepth(gl_FragCoord.xy / uDrawingBufferSize) || fragmentDepth > 0.99)) {\n #ifdef dTransparentBackfaces_off\n if (interior) discard;\n #endif\n float alpha = gl_FragColor.a;\n float wboitWeight = alpha * clamp(pow(1.0 - fragmentDepth, 2.0), 0.01, 1.0);\n gl_FragColor = vec4(gl_FragColor.rgb * alpha * wboitWeight, alpha);\n // extra alpha is to handle pre-multiplied alpha\n #ifndef dGeometryType_directVolume\n gl_FragData[1] = vec4((uTransparentBackground ? alpha : 1.0) * alpha * wboitWeight);\n #else\n gl_FragData[1] = vec4(alpha * alpha * wboitWeight);\n #endif\n } else {\n discard;\n }\n }\n#endif\n";
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.wboit_write = void 0;
|
|
10
|
-
exports.wboit_write = "\n#if defined(dRenderVariant_colorWboit)\n if (
|
|
10
|
+
exports.wboit_write = "\n#if defined(dRenderVariant_colorWboit)\n if (uRenderMask == MaskOpaque) {\n if (preFogAlpha < 1.0) {\n discard;\n }\n } else if (uRenderMask == MaskTransparent) {\n // the 'fragmentDepth > 0.99' check is to handle precision issues with packed depth\n if (preFogAlpha != 1.0 && (fragmentDepth < getDepth(gl_FragCoord.xy / uDrawingBufferSize) || fragmentDepth > 0.99)) {\n #ifdef dTransparentBackfaces_off\n if (interior) discard;\n #endif\n float alpha = gl_FragColor.a;\n float wboitWeight = alpha * clamp(pow(1.0 - fragmentDepth, 2.0), 0.01, 1.0);\n gl_FragColor = vec4(gl_FragColor.rgb * alpha * wboitWeight, alpha);\n // extra alpha is to handle pre-multiplied alpha\n #ifndef dGeometryType_directVolume\n gl_FragData[1] = vec4((uTransparentBackground ? alpha : 1.0) * alpha * wboitWeight);\n #else\n gl_FragData[1] = vec4(alpha * alpha * wboitWeight);\n #endif\n } else {\n discard;\n }\n }\n#endif\n";
|
|
@@ -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 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 bool uRenderWboit;\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 mat3 normalMatrix = transpose3(inverse3(mat3(uModelView * vTransform)));\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 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\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 #include wboit_write\n}\n";
|
|
7
|
+
export declare const 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 int uRenderMask;\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 return texture2D(tDepth, coords).r;\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 mat3 normalMatrix = transpose3(inverse3(mat3(uModelView * vTransform)));\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 #include wboit_write\n}\n";
|