CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
13.04k stars 3.51k forks source link

EDL doesn't work with translucent styles #8550

Open hpinkos opened 4 years ago

hpinkos commented 4 years ago

EDL looks great when all alpha values are 1.0: image

But it doesn't work at all if any of the points have a transparency: image

var viewer = new Cesium.Viewer('cesiumContainer', {
    terrainProvider: Cesium.createWorldTerrain()
});

// A ~10 billion point 3D Tileset of the city of Montreal, Canada captured in 2015 with a resolution of 20 cm. Tiled and hosted by Cesium ion.
var tileset = viewer.scene.primitives.add(
    new Cesium.Cesium3DTileset({
        url: Cesium.IonResource.fromAssetId(28945),
        pointCloudShading: {
            attenuation: true,
            maximumAttenuation: 2
        }
    })
);

// Fly to a nice overview of the city.
viewer.camera.flyTo({
    destination : new Cesium.Cartesian3(1223285.2286828577, -4319476.080312792, 4562579.020145769),
    orientation : {
        direction : new Cesium.Cartesian3(0.63053223097472, 0.47519958296727743, -0.6136892226931869),
        up : new Cesium.Cartesian3(0.7699959023135587, -0.4824455703743441, 0.41755548379407276)
    },
    easingFunction: Cesium.EasingFunction.QUADRATIC_IN_OUT
});

Sandcastle.addDefaultToolbarButton('Opaque style', function() {
    var styleObject = {
    color:{
        conditions:[
            ["${Classification} === 1","rgb(47,14,159)"],
            ["true","rgb(200,200,200)"]
        ]}};

    tileset.style = new Cesium.Cesium3DTileStyle(styleObject);
});

Sandcastle.addToolbarButton('Translucent style', function() {
    var styleObject = {
    color:{
        conditions:[
            ["${Classification} === 1","rgba(47,14,159,0.8)"],
            ["true","rgb(200,200,200)"]
        ]}};

    tileset.style = new Cesium.Cesium3DTileStyle(styleObject);
});
lilleyse commented 4 years ago

Some thoughts on fixing this:

This is much easier to solve if all points are opaque or all points are translucent. Having a mix of the two is the complicated part.

DanRiess commented 1 year ago

Hey guys,

I just wanted to add that EDL also doesn't work when the pointcloud tileset has a custom shader with translucencyMode: CustomShaderTranslucencyMode.TRANSLUCENT applied to it.

Is there by any chance a workaround for that nowadays? Either with styles or custom shaders?