Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ctwhome committed Mar 14, 2024
1 parent aae5ef5 commit e174364
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/lib/shaders/volume_transfer.frag
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// This code is based upon Janelia's web-vol-viewer
// https://github.com/JaneliaSciComp/web-vol-viewer

precision highp float;
precision mediump float;
in vec3 rayDirUnnorm;
in vec3 lightDir;

uniform sampler2D transferTex;
// uniform lowp sampler3D volumeTex;
uniform lowp sampler3D volumeTex;
uniform lowp sampler3D coarseVolumeTex;
uniform float dtScale;
uniform float finalGamma;
uniform vec3 sunLightColor;
Expand Down Expand Up @@ -66,7 +66,7 @@ void main(void){

tBox.x=max(tBox.x,0.);

ivec3 volumeTexSize=textureSize(volumeTex,0);
ivec3 volumeTexSize=textureSize(coarseVolumeTex,0);
// vec3 dt0 = 1.0 / (vec3(volumeTexSize) * abs(rayDir));
vec3 dt0=1./(vec3(volumeTexSize)*abs(rayDir));
float dt=min(dt0.x,min(dt0.y,dt0.z)) * 0.5;
Expand Down Expand Up @@ -101,8 +101,8 @@ void main(void){
vec3 random=fract(sin(gl_FragCoord.x*12.9898+gl_FragCoord.y*78.233)*43758.5453)*dt*rayDir/8.0;
for(float t=tBox.x;t<tBox.y;t+=dt){

float value=texture(volumeTex, pSized).r;
if(value != 0.0){
float value=texture(coarseVolumeTex, pSized).r;
if(value != 100.0){
#pragma unroll_loop_start
for(int i = 0; i < 8; ++i)
{
Expand Down
10 changes: 6 additions & 4 deletions src/routes/viewer/sceneSetup/updateMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as THREE from 'three';
import { get } from 'svelte/store';
import { volumeSizes } from '../stores/allSlices.store';
import { boxes } from './boxSetup';
import { coarseData } from '../fetchAndPrepareData/coarseData';


// Be caruful with these valies, they can clip the data in the 3D scene
Expand Down Expand Up @@ -49,14 +50,18 @@ export function updateMaterial({ variable, dataUint8 }) {
break;

case 'qr':
volumeTexture = new THREE.Data3DTexture(dataUint8, sizes[0] / 8, sizes[1] / 8, sizes[2] / 8);
// uniforms?.coarseVolumeTex?.value?.dispose();

volumeTexture = new THREE.Data3DTexture(dataUint8, sizes[0], sizes[1], sizes[2]);
volumeTexture.format = THREE.RedFormat;
volumeTexture.minFilter = THREE.NearestFilter; // TODO: is this the best filter?
volumeTexture.magFilter = THREE.NearestFilter;
uniforms.dataScale.value = qrScale;
uniforms.dtScale.value = dtScale;
uniforms.alphaNorm.value = 2.0;
uniforms.finalGamma.value = finalGamma;

uniforms.coarseVolumeTex.value = new THREE.Data3DTexture(coarseData(sizes, dataUint8), sizes[0] / 8, sizes[1] / 8, sizes[2] / 8);;
break;

case 'thetavmix':
Expand All @@ -76,7 +81,4 @@ export function updateMaterial({ variable, dataUint8 }) {
//
uniforms.volumeTex.value = volumeTexture;




}

0 comments on commit e174364

Please sign in to comment.