CesiumGS / cesium

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

groundprimitive not supported in IdTexture? #7095

Open flyingdq opened 6 years ago

flyingdq commented 6 years ago

GroundPrimitive can be picked when mouse move. But in postProcess stage, I cann't get it in IdTexture.

hpinkos commented 6 years ago

@lb999255 can you please put together a Sandcastle example to reproduce the error you're seeing?

flyingdq commented 6 years ago

Hi, I modified the 'Custom Per-Feature Post Process' example. I added a primitive and a ground primitive. In post-processing fs, I let them show yellow when idtexture is not null by default. And it will be highlighted when selected, but only the model is on the right way. My Example

flyingdq commented 6 years ago

I checked the code in excuteCommands function, Scene.js and found commands of TERRAIN_CLASSIFICATION or CLASSIFICATION not invoked when renderring to IdTexture.

`var originalFramebuffer = passState.framebuffer; passState.framebuffer = scene._sceneFramebuffer.getIdFramebuffer();

        // reset frustum
        frustum.near = index !== 0 ? frustumCommands.near * scene.opaqueFrustumNearOffset : frustumCommands.near;
        frustum.far = frustumCommands.far;
        us.updateFrustum(frustum);

        us.updatePass(Pass.GLOBE);
        commands = frustumCommands.commands[Pass.GLOBE];
        length = frustumCommands.indices[Pass.GLOBE];
        for (j = 0; j < length; ++j) {
            executeIdCommand(commands[j], scene, context, passState);
        }

        if (clearGlobeDepth) {
            clearDepth.framebuffer = passState.framebuffer;
            clearDepth.execute(context, passState);
            clearDepth.framebuffer = undefined;
        }

        if (clearGlobeDepth && useDepthPlane) {
            depthPlane.execute(context, passState);
        }

        us.updatePass(Pass.CESIUM_3D_TILE);
        commands = frustumCommands.commands[Pass.CESIUM_3D_TILE];
        length = frustumCommands.indices[Pass.CESIUM_3D_TILE];
        for (j = 0; j < length; ++j) {
            executeIdCommand(commands[j], scene, context, passState);
        }

        us.updatePass(Pass.OPAQUE);
        commands = frustumCommands.commands[Pass.OPAQUE];
        length = frustumCommands.indices[Pass.OPAQUE];
        for (j = 0; j < length; ++j) {
            executeIdCommand(commands[j], scene, context, passState);
        }

        us.updatePass(Pass.TRANSLUCENT);
        commands = frustumCommands.commands[Pass.TRANSLUCENT];
        length = frustumCommands.indices[Pass.TRANSLUCENT];
        for (j = 0; j < length; ++j) {
            executeIdCommand(commands[j], scene, context, passState);
        }

        passState.framebuffer = originalFramebuffer;`
hpinkos commented 6 years ago

Thanks for the extra information @lb999255!

@bagnell is the new post processing feature supposed to work for geometry?