pickPosition with alpha cut off?


Could someone help me on this challenge I am struggling with:

I want to use scene.pickPosition to pick position only if alpha-value is lower than 0.3. So any “too transparent” result should be ignored.

I see “alpha cut off” type implementation in the source code, but do not really understand could I utilize it for this task… It would be fine to modify some GLSL shader globally to render pickDepthBuffer like this, but I don’t seem to find the right place to edit the code.

This is how I pick now:

scene.pickTranslucentDepth = true;

// TODO: Setup something here to discard fragments where color.a < 0.3


tempScenePos = pickGlobe(controller, controller._aggregator._currentMousePosition, tempScenePos);

scene.pickTranslucentDepth = false;


There’s nothing built it in to do this, but this is the line you’d have to edit:

to change == 0 to <= 0.3.

That might not work for everything since some things have custom pick shaders. Let me know how it goes!

Actually the one you posted solves the pick! But not the “pickPosition”. Pick is for entityId:s I think?

Anyways… I have been investigating this and I think it needs a special case in 3d tileset shader code.

My next question would be: How can I pass a custom uniform to Cesium 3d tileset shader pipeline?

Or, a broader version of the same: how can I pass a custom shader to 3d tileset? :slight_smile:

I think that depends on what type of content is in your 3D Tiles. For example, if you’ve got buildings that are b3dm, then they’ll be created as Batched3DModelTileContent:

Which uses the Model class (https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Batched3DModel3DTileContent.js#L369) to create its content. So you could potentially add in a custom material there.