Open lilleyse opened 4 years ago
Another option is setting one of the coordinates to a NaN value. See
From @loshjawrence
I wish I had seen this sooner, for ModelExperimental
we've been doing yet a different way: positionMC *= 0.0
(see CPUStylingStageVS.glsl
). This makes an assumption that WebGL won't render zero-area triangles as a single pixel. We'd have to refactor the shader a bit. If we just switched to gl_Position
, the value is likely to get clobbered by later shader stages.
But also, in this forum thread I saw a use case where a user wanted to hide a specific building in a vertex shader so something else could be rendered in its place. We'd need another variable in custom shaders to hide a vertex, as positionMC
doesn't have a w
component.
There are several systems that batch features together into a single draw call and hide individual features in the vertex shader by accessing their show property in the batch table and forcing them to be clipped. All these systems have a slightly different way of doing this.
gl_Position *= show;
inCesium3DTileBatchTable.js
PointCloud.js
(for 3D Tiles) usesgl_Position.w *= float(show);
(see https://github.com/AnalyticalGraphicsInc/cesium/pull/8538) andgl_PointSize *= float(show);
Primitive.js
distance display condition usesgl_Position *= show;
PointPrimitiveCollection
gl_PointSize = totalSize * show;
andgl_Position *= show;
and sets alpha to 0.0 (see https://github.com/AnalyticalGraphicsInc/cesium/pull/8054).positionEC.xyz = vec3(0.0, 0.0, 1.0);
(see https://github.com/AnalyticalGraphicsInc/cesium/pull/8542/).positionEC.xyz = vec3(0.0);
.BillboardCollection
usespositionEC.xyz = vec3(0.0);
for small eye distance scales and eye distance translucency.The
gl_Position.w *= show
approach is probably the easiest to use everywhere and is the easiest one to implement as a built-in function. Another thing to look at is how log depth affects all this, especially anything inDerivedCommand.createLogDepthCommand
.