Skip to content

Commit

Permalink
refactor(PtVisi): change discard to transparency
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Nov 5, 2024
1 parent a0b6f14 commit 8622f8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
7 changes: 7 additions & 0 deletions src/Renderer/PointsMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ class PointsMaterial extends THREE.ShaderMaterial {
}

recomputeVisibleTexture() {
let needTransparency;
const texture = this.visiTexture;
const scheme = this.classificationScheme;

Expand All @@ -415,9 +416,15 @@ class PointsMaterial extends THREE.ShaderMaterial {
}

data[i] = visible ? 255 : 0;
needTransparency = needTransparency || visible === false;
}
texture.needsUpdate = true;

this.userData.needTransparency[PNTS_MODE.CLASSIFICATION] = needTransparency;
this.userData.needTransparency[PNTS_MODE.RETURN_NUMBER] = needTransparency;
this.userData.needTransparency[PNTS_MODE.RETURN_TYPE] = needTransparency;
this.userData.needTransparency[PNTS_MODE.RETURN_COUNT] = needTransparency;
this.userData.needTransparency[PNTS_MODE.POINT_SOURCE_ID] = needTransparency;

this.dispatchEvent({
type: 'material_property_changed',
Expand Down
5 changes: 0 additions & 5 deletions src/Renderer/Shader/PointsFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>

varying float visible;

uniform vec3 diffuse;
uniform float opacity;

Expand All @@ -20,9 +18,6 @@ void main() {

// Early discard (clipping planes and shape)
#include <clipping_planes_fragment>
if (visible < 0.5) {
discard;
}
if (shape == PNTS_SHAPE_CIRCLE) {
//circular rendering in glsl
if ((length(gl_PointCoord - 0.5) > 0.5)) {
Expand Down
6 changes: 4 additions & 2 deletions src/Renderer/Shader/PointsVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec4 vColor; // color_pars_vertex
varying float visible;

#ifdef USE_POINTS_UV
varying vec2 vUv;
Expand Down Expand Up @@ -43,7 +42,6 @@ attribute float scanAngle;

void main() {
vec2 uv = vec2(classification/255., 0.5);
visible = texture2D(visiTexture, uv).r;

vColor = vec4(1.0);
if (picking) {
Expand Down Expand Up @@ -107,6 +105,10 @@ void main() {
}
}

if (texture2D(visiTexture, uv).r == 0.) {
vColor.a = 0.;
}

#define USE_COLOR_ALPHA
#include <morphcolor_vertex>
#include <begin_vertex>
Expand Down

0 comments on commit 8622f8a

Please sign in to comment.