Skip to content

Commit a74b4e5

Browse files
authored
Merge pull request #28 from EarthyScience/Plot-Alphas
Added appropriate alphas to the nan values.
2 parents d951d72 + 218cf9a commit a74b4e5

File tree

6 files changed

+34
-28
lines changed

6 files changed

+34
-28
lines changed

src/components/PlotObjects.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,10 @@ export const PointCloud = ({textures} : {textures:PCProps} )=>{
245245
},
246246
vertexShader:pointVert,
247247
fragmentShader:pointFrag,
248-
blending: THREE.NoBlending,
249248
depthWrite: true,
249+
transparent: true,
250+
blending:THREE.NormalBlending,
251+
side:THREE.DoubleSide,
250252
});
251253

252254
return (

src/components/TextureMakers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function ArrayTo3D(array: Array){
6363
});
6464

6565
const normed = data.map((i)=>(i-minVal)/(maxVal-minVal))
66-
const textureData = new Uint8Array(normed.map((i)=>i*255));
66+
const textureData = new Uint8Array(normed.map((i)=>isNaN(i) ? 255 : i*254));
6767
const volTexture = new THREE.Data3DTexture(textureData, lx, ly, lz);
6868
volTexture.format = THREE.RedFormat;
6969
volTexture.minFilter = THREE.NearestFilter;

src/utils/colormap.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export function GetColorMapTexture(
3838
colData[lastIndex + 1] = to_nan[1];
3939
colData[lastIndex + 2] = to_nan[2];
4040
colData[lastIndex + 3] = nan_alpha;
41-
4241
if (texture) {
4342
// Update the existing texture data
4443
(texture.image.data as Uint8Array).set(colData);

src/utils/shaders/fragment.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ void main() {
7676

7777
if (cond) {
7878
vec4 col = texture(cmap, vec2(d, 0.5));
79-
// Change this later back to intensity then delete comment
80-
float alpha = 1.;
79+
// Change this later back to use intensity then delete comment. Or maybe we don't need intensity
80+
float alpha = float(col.a > 0.);
8181

8282
accumColor.rgb += (1.0 - alphaAcc) * alpha * col.rgb;
8383
alphaAcc += alpha * (1.0 - alphaAcc);

src/utils/shaders/pointFrag.glsl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
out vec4 Color;
2-
3-
varying float vValue;
4-
uniform sampler2D cmap;
5-
6-
void main() {
7-
8-
Color = texture(cmap, vec2(vValue, 0.1));
9-
Color.a = 1.;
10-
//Color = vec4(vec3(vValue),1.);
11-
12-
}
1+
out vec4 Color;
2+
3+
varying float vValue;
4+
uniform sampler2D cmap;
5+
6+
void main() {
7+
8+
vec4 color = texture(cmap, vec2(vValue, 0.5));
9+
color.a = 1.;
10+
11+
Color = color;
12+
13+
}

src/utils/shaders/pointVertex.glsl

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
attribute float value;
2-
varying float vValue;
3-
uniform float pointSize;
4-
uniform bool scalePoints;
5-
6-
void main() {
7-
vValue = value/255.;
8-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
9-
float pointScale = pointSize/gl_Position.w;
10-
gl_PointSize = scalePoints ? pointScale*pow(vValue,2.) : pointScale ;
11-
}
1+
attribute float value;
2+
varying float vValue;
3+
uniform float pointSize;
4+
uniform bool scalePoints;
5+
6+
void main() {
7+
vValue = value/255.;
8+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
9+
//If it is nan we just yeet it tf out of the screen space. LMAO I love this solution
10+
if (value == 255.){
11+
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
12+
}
13+
float pointScale = pointSize/gl_Position.w;
14+
gl_PointSize = scalePoints ? pointScale*pow(vValue,2.) : pointScale ;
15+
}

0 commit comments

Comments
 (0)