Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Transparent individual pointcloud classes don't get rendered as transparent #2323

Closed
airnez opened this issue May 2, 2024 · 5 comments · Fixed by #2327
Closed

[BUG] Transparent individual pointcloud classes don't get rendered as transparent #2323

airnez opened this issue May 2, 2024 · 5 comments · Fixed by #2327

Comments

@airnez
Copy link
Contributor

airnez commented May 2, 2024

Context

I am using classified pointclouds provided as 3D Tiles.
I am setting a custom classificationScheme to choose color and opacity for each individual pointcloud class.
Setting colors works fine. Reducing opacity will however fade the point color to white instead of making it transparent.
On the screenshot bellow the buildings are excpected to look half-transparent red but appear pink and opaque instead.

image

Steps to Reproduce

  1. Render a classified point cloud 3D Tile source (https://raw.githubusercontent.com/iTowns/iTowns2-sample-data/master/pointclouds/pnts-sete-2021-0756_6256/tileset.json)
  2. Set a custom classification scheme with a transparent class (here buildings are set red and half-transparent and the rest is black) :
layer.classification = {
                    6: { visible: true, color: new THREE.Color(1, 0, 0), opacity: 0.5 },
                    DEFAULT: { visible: true, color: new THREE.Color(0, 0, 0), opacity: 1 }
}

Expected Behavior

The classified points should be rendered as transparent.

Actual Behavior

The classified point are getting whiter.

Possible Cause/Fix/Solution

It seems that the point material transparent property is not set correctly. Thus it renders the color alpha as color intensity instead of transparency. This happens because the layer opacity is set to 1. Even if we try to set the whole layer material transparent, the transparent property getter overwrites the value depending on the opacity. See here :

Object.defineProperty(material, 'transparent', {
get: () => {
if (transparent != material.layer.opacity < 1.0) {
material.needsUpdate = true;
transparent = material.layer.opacity < 1.0;
}
return transparent;
},
});

@ftoromanoff
Copy link
Contributor

ftoromanoff commented May 14, 2024

Linked with your issue, I noticed a similar bug on PointCloudLayer (entwine and Potree).
I started a PR #2327 to fix that issue, but currently I only look up for PointCloud and not yet other 3D Layer type (as 3D tiles you are refering to here)

@ftoromanoff
Copy link
Contributor

The last commits of the PR #2327 should fix it. @airnez You can try to see if it is what you wanted ?
It might get reworked, but it might be good to know if the issue you pointed out is resolved like that.

@airnez
Copy link
Contributor Author

airnez commented May 17, 2024

I tested your fix, and I couldn't make it work for 3dTiles. I suspect that the problem is linked to the fact that the 3dTiles pointsMaterial is instanciated here :

function pntsParse(data, layer) {
return PntsParser.parse(data, layer.registeredExtensions).then((result) => {
const material = layer.material ?
layer.material.clone() :
new PointsMaterial({
size: 0.05,
mode: layer.pntsMode,
shape: layer.pntsShape,
classification: layer.classification,
sizeMode: layer.pntsSizeMode,
minAttenuatedSize: layer.pntsMinAttenuatedSize,
maxAttenuatedSize: layer.pntsMaxAttenuatedSize,
});
// refer material properties in the layer so when layers opacity and visibility is updated, the material is
// automatically updated
ReferLayerProperties(material, layer);

It seems that something like what you implemented here is needed : https://github.com/ftoromanoff/itowns/blob/41fbaa3780245939b50cbc8b19cc79287de8aa2f/src/Layer/PointCloudLayer.js#L197

@ftoromanoff
Copy link
Contributor

ftoromanoff commented May 21, 2024

Should be fixed now.
I indeed did a last little change that i forgot to apply on 3dTilesLayer...

@airnez
Copy link
Contributor Author

airnez commented May 23, 2024

Tested, it seems fixed ! Thank you @ftoromanoff

@ftoromanoff ftoromanoff linked a pull request May 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants