From 97252205a2f38aabed91e6aa0ab9595298c050e2 Mon Sep 17 00:00:00 2001 From: Stefan Steinheber Date: Sun, 15 Jan 2023 14:02:44 +0100 Subject: [PATCH] removed unused --- index.html | 2 -- js/shader_exm.js | 30 ------------------------------ js/shader_impl.js | 33 +++++++++++++++++++++++++-------- js/shader_iso.js | 13 ------------- js/vis1.js | 19 +++---------------- shaders/volume_frag.essl | 6 ------ 6 files changed, 28 insertions(+), 75 deletions(-) delete mode 100644 js/shader_exm.js delete mode 100644 js/shader_iso.js diff --git a/index.html b/index.html index 1b1a3b5..f0e227c 100644 --- a/index.html +++ b/index.html @@ -17,8 +17,6 @@ - - diff --git a/js/shader_exm.js b/js/shader_exm.js deleted file mode 100644 index 486186c..0000000 --- a/js/shader_exm.js +++ /dev/null @@ -1,30 +0,0 @@ -class ShaderExm extends Shader { - constructor(data, colorMap, dims, renderMode, indicators) { - super("volume_vert", "volume_frag"); - this.setUniform("volume", data, "sampler3D"); - this.setUniform("transfer_fcn", colorMap, "sampler2D"); - this.setUniform("volume_dims", new THREE.Vector3(dims[0], dims[1], dims[2]), 'vec3'); - this.setUniform("render_mode", renderMode, "int"); - this.setUniform("indicators", this.prepareIndicators(indicators), "Indicator"); - this.material.transparent = true; - this.material.depthWrite = false; - this.material.side = THREE.DoubleSide; - } - - updateIndicators(indicators) { - this.material.uniforms.indicators.value = this.prepareIndicators(indicators); - this.material.needsUpdate = true; - } - - prepareIndicators(indicators) { - return Array.from({ - ...indicators.map(({ xValue, yValue, ...keep }) => keep), - length: 5 - }, (v) => v || { - opacity: 0, - density: 0, - color: new THREE.Vector3(1, 1, 1) - }); - } - -} \ No newline at end of file diff --git a/js/shader_impl.js b/js/shader_impl.js index 62deb73..6925a97 100644 --- a/js/shader_impl.js +++ b/js/shader_impl.js @@ -1,12 +1,29 @@ class ShaderImpl extends Shader { - constructor(size, style, iso, cLimit, data, colorMap) { - super("mip_vert", "mip_frag"); - this.setUniform("size", new THREE.Vector3(size[0], size[1], size[2]), "vec3"); - this.setUniform("renderStyle", style, "int"); - this.setUniform("isoThreshold", iso, "float"); - this.setUniform("cLimit", new THREE.Vector2(cLimit[0], cLimit[1]), "vec2"); - this.setUniform("data", data, "sampler3D"); - this.setUniform("colorMap", colorMap, "sampler2D"); + constructor(data, dims, renderMode, indicators) { + super("volume_vert", "volume_frag"); + this.setUniform("volume", data, "sampler3D"); + this.setUniform("volume_dims", new THREE.Vector3(dims[0], dims[1], dims[2]), 'vec3'); + this.setUniform("render_mode", renderMode, "int"); + this.setUniform("indicators", this.prepareIndicators(indicators), "Indicator"); + this.material.transparent = true; + this.material.depthWrite = false; + this.material.side = THREE.DoubleSide; + } + + updateIndicators(indicators) { + this.material.uniforms.indicators.value = this.prepareIndicators(indicators); + this.material.needsUpdate = true; + } + + prepareIndicators(indicators) { + return Array.from({ + ...indicators.map(({ xValue, yValue, ...keep }) => keep), + length: 5 + }, (v) => v || { + opacity: 0, + density: 0, + color: new THREE.Vector3(1, 1, 1) + }); } } \ No newline at end of file diff --git a/js/shader_iso.js b/js/shader_iso.js deleted file mode 100644 index cdf3f70..0000000 --- a/js/shader_iso.js +++ /dev/null @@ -1,13 +0,0 @@ -class ShaderISO extends Shader { - constructor(size, style, iso, cLimit, data, colorMap) { - super("iso_vert", "iso_frag"); - this.setUniform("isoValue", iso, "float"); - // this.setUniform("size", new THREE.Vector3(size[0], size[1], size[2]), "vec3"); - // this.setUniform("renderStyle", style, "int"); - // this.setUniform("isoThreshold", iso, "float"); - // this.setUniform("cLimit", new THREE.Vector2(cLimit[0], cLimit[1]), "vec2"); - // this.setUniform("data", data, "sampler3D"); - // this.setUniform("colorMap", colorMap, "sampler2D"); - } - -} \ No newline at end of file diff --git a/js/vis1.js b/js/vis1.js index 9cf500d..f78de87 100644 --- a/js/vis1.js +++ b/js/vis1.js @@ -96,26 +96,15 @@ async function resetVis() { scene = new THREE.Scene(); camera = new THREE.PerspectiveCamera(75, canvasWidth / canvasHeight, 0.1, 1000); volumeToDataTexture3D(); - // const shader = new ShaderImpl( - // [volume.width, volume.height, volume.depth], - // 0, - // .34, [0, 1], - // dataTexture, - // await new THREE.TextureLoader().load('textures/cm_viridis.png')); - - const max = Math.max(volume.width, volume.height, volume.depth); - - shader = new ShaderExm( - dataTexture, - await new THREE.TextureLoader().load('textures/cm_viridis.png'), [volume.width, volume.height, volume.depth], + + shader = new ShaderImpl( + dataTexture, [volume.width, volume.height, volume.depth], document.getElementById("renderModes").selectedIndex.toString(), indicators ); await shader.load(); const domain = new THREE.BoxGeometry(volume.width, volume.depth, volume.height); - // domain.translate(volume.width / 2, volume.depth / 2, volume.height / 4); - // position markers domainMesh = new THREE.Mesh(domain, shader.material); scene.add(domainMesh); // our camera orbits around an object centered at (0,0,0) @@ -133,7 +122,6 @@ function paint() { } } - function volumeToDataTexture3D() { dataTexture = new THREE.Data3DTexture(volume.voxels, volume.width, volume.height, volume.depth); dataTexture.format = THREE.RedFormat; @@ -257,7 +245,6 @@ function setupD3() { .attr("style", "user-select: none") .call(d3.axisTop(x)); - // Append the y-axis to the visualization svg.append("g") .attr("class", "axis") .attr("transform", "translate(" + margin.left + ",0)") diff --git a/shaders/volume_frag.essl b/shaders/volume_frag.essl index 343a7e0..68a3afa 100644 --- a/shaders/volume_frag.essl +++ b/shaders/volume_frag.essl @@ -13,7 +13,6 @@ uniform Indicator indicators[NUM_INDICATORS]; uniform highp sampler3D volume; -uniform highp sampler2D transfer_fcn; uniform vec3 volume_dims; uniform lowp int render_mode; uniform mediump float iso_value; @@ -57,11 +56,6 @@ vec2 intersect_box(vec3 orig, vec3 dir) { return vec2(t0, t1); } - -vec4 sampleColor(float val) { - return texture2D(transfer_fcn, vec2(val, 0.5)); -} - void main() { // Step 1: Normalize the view ray